Improve Envoy detection and support multiple Envoys ()

* Bump envoy_reader to 0.8.6, fix missing dependency

* Support for optional name in config

* Replace str.format with f-strings
pull/26635/head^2
Jesse Rizzo 2019-09-17 13:24:03 -05:00 committed by Martin Hjelmare
parent ed13cab8d6
commit 4060f1346a
1 changed files with 8 additions and 2 deletions
homeassistant/components/enphase_envoy

View File

@ -9,6 +9,7 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.const import (
CONF_IP_ADDRESS,
CONF_MONITORED_CONDITIONS,
CONF_NAME,
POWER_WATT,
ENERGY_WATT_HOUR,
)
@ -44,6 +45,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
vol.Optional(CONF_MONITORED_CONDITIONS, default=list(SENSORS)): vol.All(
cv.ensure_list, [vol.In(list(SENSORS))]
),
vol.Optional(CONF_NAME, default=""): cv.string,
}
)
@ -54,6 +56,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
ip_address = config[CONF_IP_ADDRESS]
monitored_conditions = config[CONF_MONITORED_CONDITIONS]
name = config[CONF_NAME]
entities = []
# Iterate through the list of sensors
@ -66,14 +69,17 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
Envoy(
ip_address,
condition,
"{} {}".format(SENSORS[condition][0], inverter),
f"{name}{SENSORS[condition][0]} {inverter}",
SENSORS[condition][1],
)
)
else:
entities.append(
Envoy(
ip_address, condition, SENSORS[condition][0], SENSORS[condition][1]
ip_address,
condition,
f"{name}{SENSORS[condition][0]}",
SENSORS[condition][1],
)
)
async_add_entities(entities)