Improve Envoy detection and support multiple Envoys (#26665)
* Bump envoy_reader to 0.8.6, fix missing dependency * Support for optional name in config * Replace str.format with f-stringspull/26635/head^2
parent
ed13cab8d6
commit
4060f1346a
homeassistant/components/enphase_envoy
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue