The error (or problem is a better word) is that after startup of HA before the first trigger it starts with the wrong value. So I want to have the correct value immediately after the power value has been measured.
it will only do that when the there is a threshold change during the restart. So e.g. someone was warming water when you pressed the restart button, and is no longer doing that when HA started again. Otherwise it will be on the right value after the restart.
To mitigate that, change the automation to:
- id: '123452135311'
triggers:
- alias: trigger on every state change of the power sensor
trigger: state
entity_id: sensor.wp_power
not_to: unavailable
- alias: trigger on start of Home Assistant
trigger: homeassistant
event: start
actions:
- alias: determine which state the select entity should be on
if:
- alias: Heatpump power value is below 500
condition: numeric_state
entity_id: sensor.wp_power
below: 500
then:
- alias: Set select entity to Verwarming
action: select.select_option
target:
entity_id: select.heatpump
data:
option: Verwarming # make sure this matches the option from the select dropdown for verwarming
else:
- alias: Set select entity to Tapwater
action: select.select_option
target:
entity_id: select.heatpump
data:
option: Tapwater # make sure this matches the option from the select dropdown for tapwater
Thanks a lot again! Where can I find a good training to build these scripts myself? To me it looks like the Home Assistant documentation is quite limited.
Triggers are documented here: https://www.home-assistant.io/docs/automation/trigger/
Conditions (not used in this automation) are documented here: https://www.home-assistant.io/docs/automation/condition/
Actions are documented here: https://www.home-assistant.io/docs/scripts/