of course! seeing a parallel to the presence automations where this is used in the conditions:
condition: template
value_template: {{ trigger.to_state.state in ['home','not_home'] }}
would this be possible here too (mind you, considering i have more triggering entities, which dont fall into the to:‘on’ to:‘off’ category, so id have to use the entity_id in this condition.
condition: template
value_template: {{ states('binary_sensor.zp_opbrengst_threshold')
in ['on','off'] }}
adding that, and the timer to not have it toggle around the threshold, and a check it doesnt trigger to a state it came from, would then lead to this:
- alias: Boiler switch
id: 'Boiler switch'
trigger:
- platform: state
entity_id: sensor.huidig_tarief
- platform: state
entity_id: binary_sensor.zp_opbrengst_threshold_input
condition:
- condition: template
value_template: >
{{ trigger.to_state.state is not none and
trigger.from_state.state is not none and
trigger.to_state.state != trigger.from_state.state }}
- condition: template
value_template: >
{{ states('binary_sensor.zp_opbrengst_threshold_input') in ['on','off'] }}
- condition: template
value_template: >
{{ (as_timestamp(now()) -
as_timestamp(state_attr('automation.boiler_switch','last_triggered'))
| default(0) | int > 240) }}
action:
- service_template: >
switch.turn_{{'on' if is_state('binary_sensor.zp_opbrengst_threshold_input','on') or
is_state('sensor.huidig_tarief', '1') else 'off'}}
entity_id: switch.sw_boiler_bijkeuken_template
- condition: template
value_template: >
{{ is_state('input_boolean.notify_notify', 'on')}}
- service: notify.notify
data_template:
message: >
Threshold: {{states('binary_sensor.zp_opbrengst_threshold_input')}}, ZP {{states('sensor.zp_actuele_opbrengst')}}, Tarief {{states('sensor.huidig_tarief')}}:
Switching Boiler: {{'on' if is_state('binary_sensor.zp_opbrengst_threshold_input','on') or
is_state('sensor.huidig_tarief', '1') else 'off' }}.