mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
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-strings
This commit is contained in:
parent
ed13cab8d6
commit
4060f1346a
@ -9,6 +9,7 @@ import homeassistant.helpers.config_validation as cv
|
|||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_IP_ADDRESS,
|
CONF_IP_ADDRESS,
|
||||||
CONF_MONITORED_CONDITIONS,
|
CONF_MONITORED_CONDITIONS,
|
||||||
|
CONF_NAME,
|
||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
ENERGY_WATT_HOUR,
|
ENERGY_WATT_HOUR,
|
||||||
)
|
)
|
||||||
@ -44,6 +45,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
vol.Optional(CONF_MONITORED_CONDITIONS, default=list(SENSORS)): vol.All(
|
vol.Optional(CONF_MONITORED_CONDITIONS, default=list(SENSORS)): vol.All(
|
||||||
cv.ensure_list, [vol.In(list(SENSORS))]
|
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]
|
ip_address = config[CONF_IP_ADDRESS]
|
||||||
monitored_conditions = config[CONF_MONITORED_CONDITIONS]
|
monitored_conditions = config[CONF_MONITORED_CONDITIONS]
|
||||||
|
name = config[CONF_NAME]
|
||||||
|
|
||||||
entities = []
|
entities = []
|
||||||
# Iterate through the list of sensors
|
# Iterate through the list of sensors
|
||||||
@ -66,14 +69,17 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
Envoy(
|
Envoy(
|
||||||
ip_address,
|
ip_address,
|
||||||
condition,
|
condition,
|
||||||
"{} {}".format(SENSORS[condition][0], inverter),
|
f"{name}{SENSORS[condition][0]} {inverter}",
|
||||||
SENSORS[condition][1],
|
SENSORS[condition][1],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
entities.append(
|
entities.append(
|
||||||
Envoy(
|
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)
|
async_add_entities(entities)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user