From 31f061f4d3f86941afb94eab39a2a4f08d7e084b Mon Sep 17 00:00:00 2001 From: pavoni Date: Sun, 17 Apr 2016 18:34:40 +0100 Subject: [PATCH] Add support for imperial meter and user soecified calorific value. --- homeassistant/components/sensor/loopenergy.py | 16 ++++++++++++++-- requirements_all.txt | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/sensor/loopenergy.py b/homeassistant/components/sensor/loopenergy.py index 7745116e82f..31b957192d9 100644 --- a/homeassistant/components/sensor/loopenergy.py +++ b/homeassistant/components/sensor/loopenergy.py @@ -8,12 +8,13 @@ import logging 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): @@ -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( @@ -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): diff --git a/requirements_all.txt b/requirements_all.txt index ed1ad1bcdf2..fb69679b846 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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