Dear community,
recently, we got a a new heat pump water heater . (is that the correct english term?)
In the same room in the basement, we have our washing machine and an air de-humidifier to dry the clothes.
I track the energy consumption of both, water heater and air de-humidifier, via Sonoff POW R2 devices. (I created a boolean sensor based on the energy consumption, which show, if the device is on or off .)
As both, water heater and de-humidifier, dry the air, I don’t want them to run at the same time.
use case 1:
de-humidifier is running → water heater starts → de-humidifier should pause, until the water heater switches off
use case 2:
de-humidifier is off → water heater starts → when the water heater stops, the de-humidifier must not start
Question : what is the best/easiest way to implement this? Any input is very much appreciated.
What do you think of my current idea: I create a boolean helper sensor “restart water heater TRUE/FALSE”. Then, I write an automation:
If de-humidifier is running AND water-heater switches “on” → set helper to TRUE → switch off de-humidifier.
If helper is TRUE, de-humidifier is “off” and water-heater switches to “off” → set helper to FALSE → switch on de-humidifier.
(Can I capture the state of a sensor and the state change of a sensor in the conditions of an automation?)
best regards from Switzerland,
Chris
my current dashboard for that room:
[1] current energy consumption
[2] history of when device was “on” or “off”
[3] daily energy consumption
[4] monthly energy consumption
I tried to build an automation - but it does not work.
The issue seems to be…
that the automation is triggered by changes in two sensors.
that I cannot define, for which sensor the trigger-on-state-change will be calculated.
How do I get around this?
I want to check if sensor [A] is in state “on” and if sensor [B] changes state - and vice versa.
not working automation:
alias: Bautrockner restart
description: >-
pausiert den Bautrockner, wenn der Boiler sich einschaltet, bis der Boiler
wieder abschaltet.
trigger:
- platform: state
entity_id:
- binary_sensor.boiler_status
- binary_sensor.bautrockner_status
from: null
to: null
condition: []
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.bautrockner_status
state: "on"
- condition: template
value_template: >-
{{ trigger.from_state.state == 'off' and
trigger.to_state.state == 'on' }}
alias: Boiler schaltet ein
sequence:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.bautrockner_restart
- service: switch.turn_off
data: {}
target:
entity_id: switch.sonoff_100142a7d7
- conditions:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.bautrockner_restart
state: "on"
- condition: template
value_template: >-
{{ trigger.from_state.state == 'on' and trigger.to_state.state
== 'off' }}
alias: Boiler schaltet ab
sequence:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.bautrockner_restart
- service: switch.turn_on
data: {}
target:
entity_id: switch.sonoff_100142a7d7
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.boiler_status
state: "on"
- condition: template
value_template: >-
{{ trigger.from_state.state == 'off' and
trigger.to_state.state == 'on' }}
alias: Bautrockner schaltet ein
sequence:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.bautrockner_restart
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- service: switch.turn_off
data: {}
target:
entity_id: switch.sonoff_100142a7d7
mode: single
I still need to test it, but this could work:
alias: Bautrockner restart
description: >-
pausiert den Bautrockner, wenn der Boiler sich einschaltet, bis der Boiler
wieder abschaltet.
trigger:
- platform: state
entity_id:
- binary_sensor.boiler_status
from: "on"
to: "off"
- platform: state
entity_id:
- binary_sensor.boiler_status
from: "off"
to: "on"
- platform: state
entity_id:
- binary_sensor.bautrockner_status
from: "off"
to: "on"
condition: []
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.bautrockner_status
state: "on"
- condition: template
value_template: "{{trigger.id == '1'}}"
alias: Boiler schaltet ein
sequence:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.bautrockner_restart
- service: switch.turn_off
data: {}
target:
entity_id: switch.sonoff_100142a7d7
- conditions:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.bautrockner_restart
state: "on"
- condition: template
value_template: "{{trigger.id == '0'}}"
alias: Boiler schaltet ab
sequence:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.bautrockner_restart
- service: switch.turn_on
data: {}
target:
entity_id: switch.sonoff_100142a7d7
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.boiler_status
state: "on"
- condition: template
value_template: "{{trigger.id == '2'}}"
alias: Bautrockner schaltet ein
sequence:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.bautrockner_restart
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- service: switch.turn_off
data: {}
target:
entity_id: switch.sonoff_100142a7d7
mode: single
many thanks to:
Interesting request but it’s not too difficult to do now, using your first example, or in shorthand notation:
choose:
- conditions: "{{trigger.to_state.state == 'on'}}"
If I specifically want from off to on, it’s simply this in shorthand notation:
choose:
- conditions:
- "{{trigger.from_state.state == 'off'}}"
- "{{trigger.to_state.state == 'on'}}"
If the automation already has a trigger that listens for the “from off to on” state-change, and it’s the first of several trigger…