Skip to content

Commit

Permalink
Merge pull request home-assistant#1842 from home-assistant/add_imperi…
Browse files Browse the repository at this point in the history
…al_meter

Add support for imperial gas meter and user specified gas calorific value.
  • Loading branch information
pavoni committed Apr 18, 2016
2 parents 276c207 + 31f061f commit 5b0ab5c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions homeassistant/components/sensor/loopenergy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

from homeassistant.helpers.entity import Entity
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.util import convert

_LOGGER = logging.getLogger(__name__)

DOMAIN = "loopenergy"

REQUIREMENTS = ['pyloopenergy==0.0.7']
REQUIREMENTS = ['pyloopenergy==0.0.10']


def setup_platform(hass, config, add_devices, discovery_info=None):
Expand All @@ -24,6 +25,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
elec_secret = config.get('electricity_secret')
gas_serial = config.get('gas_serial')
gas_secret = config.get('gas_secret')
gas_type = config.get('gas_type', 'metric')
gas_calorific = convert(config.get('gas_calorific'), float, 39.11)

if not (elec_serial and elec_secret):
_LOGGER.error(
Expand All @@ -39,11 +42,20 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
"serial and secret tokens")
return None

if gas_type not in ['imperial', 'metric']:
_LOGGER.error(
"Configuration Error, 'gas_type' "
"can only be 'imperial' or 'metric' ")
return None

# pylint: disable=too-many-function-args
controller = pyloopenergy.LoopEnergy(
elec_serial,
elec_secret,
gas_serial,
gas_secret
gas_secret,
gas_type,
gas_calorific
)

def stop_loopenergy(event):
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pyfttt==0.3
pyicloud==0.7.2

# homeassistant.components.sensor.loopenergy
pyloopenergy==0.0.7
pyloopenergy==0.0.10

# homeassistant.components.device_tracker.netgear
pynetgear==0.3.3
Expand Down

0 comments on commit 5b0ab5c

Please sign in to comment.