Ok Try if this works. You have to create one more input_boolean. Then add that to the scheduler card along with the heater schedule. Make sure that this input_boolean is turned on and off outside the condition of the first input boolean (input_boolean.microondas_boolean). Then create an automation with this new input_boolean turning on as trigger. Provide condition to check input_boolean.microondas_boolean is on. In actions just use the wait template or wait until trigger to trigger the automation after input_boolean.microondas_boolean is off.
Thank you. I’ll reread several times your answer and will try tomorrow. I’ll let you know if I succeed.
I think I have it. I describe it just in case it is useful for somebody else. All the credit goes to @sheminasalam .
I have an input_boolean, microondas_boolean
, activated when the microwave is on, which is connected to a sonoff switch (sonoff_001
).
I suppose I have two heaters. So, I have created two input_booleans to control their activation: radiador_salon_boolean
and radiador_dormitorio_piso_boolean
.
And finally I have the heater switches: sonoff_002
and sonoff_003
.
I’ve created one scheduler-card for each heater, but instead of switching on and off the real switches, I switch on and off the input_boolean.radiador_salon_boolean
or input_boolean.radiador_dormitorio_piso_boolean
.
And finally I need one automation to react to microondas_boolean
switch-on, and two for each heater (one to react to the switch-off and other to react to the switch-on).
- id: '1611676133932'
alias: Microwave on
description: 'Reacts to microondas_boolean off->on'
trigger:
- platform: state
entity_id: switch.sonoff_001
from: 'off'
to: 'on'
condition: []
action:
- service: scene.create
data:
scene_id: before
snapshot_entities: switch.sonoff_002, switch.sonoff_003
- service: switch.turn_off
data: {}
entity_id: switch.sonoff_002, switch.sonoff_003
- delay: 00:04:00
- service: scene.turn_on
data: {}
entity_id: scene.before
- service: switch.turn_off
data: {}
entity_id: switch.sonoff_001
mode: single
- id: '1611675414527'
alias: Radiador_salon_off
description: 'Reacts to radiador_salon_boolean on->off'
trigger:
- platform: state
entity_id: input_boolean.radiador_salon_boolean
from: 'on'
to: 'off'
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.microondas_boolean
state: 'off'
sequence:
- service: switch.turn_off
data: {}
entity_id: switch.sonoff_002
- conditions:
- condition: state
entity_id: input_boolean.microondas_boolean
state: 'on'
sequence:
- wait_for_trigger:
- platform: state
entity_id: input_boolean.microondas_boolean
from: 'on'
to: 'off'
timeout: 00:05:00
- service: switch.turn_off
data: {}
entity_id: switch.sonoff_002
default: []
mode: single
- id: '1611675593754'
alias: Radiador_salon_on
description: 'Reacts to radiador_salon_boolean off->on'
trigger:
- platform: state
entity_id: input_boolean.radiador_salon_boolean
from: 'off'
to: 'on'
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.microondas_boolean
state: 'off'
sequence:
- service: switch.turn_on
data: {}
entity_id: switch.sonoff_002
- conditions:
- condition: state
entity_id: input_boolean.microondas_boolean
state: 'on'
sequence:
- wait_for_trigger:
- platform: state
entity_id: input_boolean.microondas_boolean
from: 'on'
to: 'off'
timeout: 00:05:00
- service: switch.turn_on
data: {}
entity_id: switch.sonoff_002
default: []
mode: single
Just throwing in what i’ve made:
I’ve done the same with a lamp i’ve got next to my TV. When watching (or playing anything for that matter) i want it to save the device state and turn off said light, and return it when i’ve paused the tv. I have an extra challenge since i’m using adaptive lighting to change the brightness and temperature automatically and want it to return as well if it dynamic lighting was in control of the lamp. I’ve managed to solve it as such:
- id: '1707252879092'
alias: Adaptive TV Lights
description: ''
trigger:
- platform: device
device_id: 3ec6ef175958a430ac6d57bd12082edc
domain: media_player
entity_id: e51e99b670de8b444c8c7444ca2a1d4c
type: playing
- platform: device
device_id: 3ec6ef175958a430ac6d57bd12082edc
domain: media_player
entity_id: e51e99b670de8b444c8c7444ca2a1d4c
type: paused
- platform: device
type: turned_off
device_id: 3ec6ef175958a430ac6d57bd12082edc
entity_id: 237221e2341ef13cacd5882d4f9b57b2
domain: remote
condition: []
action:
- if:
- condition: device
device_id: 3ec6ef175958a430ac6d57bd12082edc
domain: media_player
entity_id: e51e99b670de8b444c8c7444ca2a1d4c
type: is_playing
then:
- service: input_boolean.turn_{{ 'on' if state_attr('light.table_lamp', 'color_temp_kelvin')
and state_attr('light.table_lamp', 'color_temp_kelvin') >= state_attr('switch.adaptive_lighting_common_lights',
'color_temp_kelvin') and state_attr('light.table_lamp', 'color_temp_kelvin')
< state_attr('switch.adaptive_lighting_common_lights', 'color_temp_kelvin')
+ 10 else 'off' }}
metadata: {}
data: {}
target:
entity_id: input_boolean.give_table_lamp_to_dynamic_lighting
- if:
- condition: state
entity_id: input_boolean.give_table_lamp_to_dynamic_lighting
state: 'off'
then:
- service: scene.create
metadata: {}
data:
scene_id: adaptive_tv_lights
snapshot_entities:
- light.table_lamp
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.table_lamp
else:
- if:
- condition: state
entity_id: input_boolean.give_table_lamp_to_dynamic_lighting
state: 'off'
then:
- service: scene.turn_on
metadata: {}
target:
entity_id: scene.adaptive_tv_lights
- service: scene.delete
metadata: {}
data: {}
target:
entity_id: scene.adaptive_tv_lights
else:
- service: light.turn_on
metadata: {}
data: {}
target:
entity_id: light.table_lamp
mode: single
This works fine for me, but i’d also love a simpler way to record a device state. Adding temporary scenes doesn’t seem like the right solution but it works for now.