Merge pull request #1842 from home-assistant/add_imperial_meter
Add support for imperial gas meter and user specified gas calorific value.
This commit is contained in:
commit
5b0ab5c118
2 changed files with 15 additions and 3 deletions
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue