Improve lists for MQTT integration (#113184)
* Improve lists for MQTT integration * Extra diagnostics tests * Revert changes where the original version was probably faster * Revert change to gather and await in series
This commit is contained in:
parent
b1346f3ccd
commit
488dae43d4
11 changed files with 144 additions and 116 deletions
|
@ -661,15 +661,12 @@ class MqttClimate(MqttTemperatureControlEntity, ClimateEntity):
|
|||
self._optimistic or CONF_PRESET_MODE_STATE_TOPIC not in config
|
||||
)
|
||||
|
||||
value_templates: dict[str, Template | None] = {}
|
||||
for key in VALUE_TEMPLATE_KEYS:
|
||||
value_templates[key] = None
|
||||
if CONF_VALUE_TEMPLATE in config:
|
||||
value_templates = {
|
||||
key: config.get(CONF_VALUE_TEMPLATE) for key in VALUE_TEMPLATE_KEYS
|
||||
}
|
||||
for key in VALUE_TEMPLATE_KEYS & config.keys():
|
||||
value_templates[key] = config[key]
|
||||
value_templates: dict[str, Template | None] = {
|
||||
key: config.get(CONF_VALUE_TEMPLATE) for key in VALUE_TEMPLATE_KEYS
|
||||
}
|
||||
value_templates.update(
|
||||
{key: config[key] for key in VALUE_TEMPLATE_KEYS & config.keys()}
|
||||
)
|
||||
self._value_templates = {
|
||||
key: MqttValueTemplate(
|
||||
template,
|
||||
|
@ -678,11 +675,10 @@ class MqttClimate(MqttTemperatureControlEntity, ClimateEntity):
|
|||
for key, template in value_templates.items()
|
||||
}
|
||||
|
||||
self._command_templates = {}
|
||||
for key in COMMAND_TEMPLATE_KEYS:
|
||||
self._command_templates[key] = MqttCommandTemplate(
|
||||
config.get(key), entity=self
|
||||
).async_render
|
||||
self._command_templates = {
|
||||
key: MqttCommandTemplate(config.get(key), entity=self).async_render
|
||||
for key in COMMAND_TEMPLATE_KEYS
|
||||
}
|
||||
|
||||
support = ClimateEntityFeature.TURN_ON | ClimateEntityFeature.TURN_OFF
|
||||
if (self._topic[CONF_TEMP_STATE_TOPIC] is not None) or (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue