mirror of
https://github.com/esphome/esphome.git
synced 2026-10-16 19:22:49 +00:00
Find the action target's config through its declared id path
This commit is contained in:
@@ -338,8 +338,9 @@ class ApplyField:
|
||||
Double a literal brace in a template. ``conf_key`` may be a path into nested sections.
|
||||
``type_`` may be a C++ type string using ``{parent}`` when the type is only known per
|
||||
instance. ``const_fn(config, value)`` renders a constant's argument text when ``cg.safe_exp``
|
||||
is not the right spelling (unit conversion belongs in the validator); a lambda or an id
|
||||
bypasses it, so the target must also take a plain ``type_``. An absent key emits nothing.
|
||||
is not the right spelling, or the value depends on another entity's config, such as the unit
|
||||
a climate reports in; a lambda or an id bypasses it, so the target must also take a plain
|
||||
``type_``. An absent key emits nothing.
|
||||
"""
|
||||
|
||||
conf_key: str | tuple[str, ...]
|
||||
|
||||
@@ -167,10 +167,8 @@ def temperature_unit_of(config: ConfigType) -> str:
|
||||
|
||||
def temperature_unit_of_id(climate_id: ID) -> str:
|
||||
"""The unit of the climate with this id, for actions that take static temperatures."""
|
||||
for conf in CORE.config.get(DOMAIN, []):
|
||||
if conf[CONF_ID] == climate_id:
|
||||
return temperature_unit_of(conf)
|
||||
raise KeyError(f"No climate with id {climate_id}")
|
||||
path = CORE.config.get_path_for_id(climate_id)[:-1]
|
||||
return temperature_unit_of(CORE.config.get_config_for_path(path))
|
||||
|
||||
|
||||
def temperature_in_entity_unit(
|
||||
|
||||
@@ -54,10 +54,8 @@ def temperature_unit_of(config: ConfigType) -> str:
|
||||
|
||||
def temperature_unit_of_id(water_heater_id: ID) -> str:
|
||||
"""The unit of the water heater with this id, for actions that take static temperatures."""
|
||||
for conf in CORE.config.get(DOMAIN, []):
|
||||
if conf[CONF_ID] == water_heater_id:
|
||||
return temperature_unit_of(conf)
|
||||
raise KeyError(f"No water heater with id {water_heater_id}")
|
||||
path = CORE.config.get_path_for_id(water_heater_id)[:-1]
|
||||
return temperature_unit_of(CORE.config.get_config_for_path(path))
|
||||
|
||||
|
||||
def _visual_temperatures_in_entity_unit(config: ConfigType) -> ConfigType:
|
||||
|
||||
Reference in New Issue
Block a user