Update to EnvoyReader 0.2, support for more hardware (#16212)

* Add support for older Envoy models

* Stop requiring envoy model name in config

* Update to envoy_reader0.2

* Minor formatting fixes

* run script/gen_requirements_all.py

* Minor formatting fixes

* Change some strings to constants, use getattr to call function
This commit is contained in:
Jesse Rizzo 2018-09-01 16:45:47 -05:00 committed by Fabian Affolter
parent e75a1690d1
commit 2b0b431a2a
2 changed files with 9 additions and 28 deletions

View File

@ -14,25 +14,27 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.const import (CONF_IP_ADDRESS, CONF_MONITORED_CONDITIONS)
REQUIREMENTS = ['envoy_reader==0.1']
REQUIREMENTS = ['envoy_reader==0.2']
_LOGGER = logging.getLogger(__name__)
SENSORS = {
"production": ("Envoy Current Energy Production", 'W'),
"daily_production": ("Envoy Today's Energy Production", "Wh"),
"7_days_production": ("Envoy Last Seven Days Energy Production", "Wh"),
"seven_days_production": ("Envoy Last Seven Days Energy Production", "Wh"),
"lifetime_production": ("Envoy Lifetime Energy Production", "Wh"),
"consumption": ("Envoy Current Energy Consumption", "W"),
"daily_consumption": ("Envoy Today's Energy Consumption", "Wh"),
"7_days_consumption": ("Envoy Last Seven Days Energy Consumption", "Wh"),
"seven_days_consumption": ("Envoy Last Seven Days Energy Consumption",
"Wh"),
"lifetime_consumption": ("Envoy Lifetime Energy Consumption", "Wh")
}
ICON = 'mdi:flash'
CONST_DEFAULT_HOST = "envoy"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_IP_ADDRESS): cv.string,
vol.Optional(CONF_IP_ADDRESS, default=CONST_DEFAULT_HOST): cv.string,
vol.Optional(CONF_MONITORED_CONDITIONS, default=list(SENSORS)):
vol.All(cv.ensure_list, [vol.In(list(SENSORS))])})
@ -81,27 +83,6 @@ class Envoy(Entity):
def update(self):
"""Get the energy production data from the Enphase Envoy."""
import envoy_reader
from envoy_reader import EnvoyReader
if self._type == "production":
self._state = int(envoy_reader.production(self._ip_address))
elif self._type == "daily_production":
self._state = int(envoy_reader.daily_production(self._ip_address))
elif self._type == "7_days_production":
self._state = int(envoy_reader.seven_days_production(
self._ip_address))
elif self._type == "lifetime_production":
self._state = int(envoy_reader.lifetime_production(
self._ip_address))
elif self._type == "consumption":
self._state = int(envoy_reader.consumption(self._ip_address))
elif self._type == "daily_consumption":
self._state = int(envoy_reader.daily_consumption(
self._ip_address))
elif self._type == "7_days_consumption":
self._state = int(envoy_reader.seven_days_consumption(
self._ip_address))
elif self._type == "lifetime_consumption":
self._state = int(envoy_reader.lifetime_consumption(
self._ip_address))
self._state = getattr(EnvoyReader(self._ip_address), self._type)()

View File

@ -321,7 +321,7 @@ enocean==0.40
# envirophat==0.0.6
# homeassistant.components.sensor.enphase_envoy
envoy_reader==0.1
envoy_reader==0.2
# homeassistant.components.sensor.season
ephem==3.7.6.0