Hello everyone!
I’m making electric load balancing automation using some XiaomiZigbee sockets.
The task is to turn off low-priority (LP) electrical consumers when high-priority (HP) consumer turns off, and return LP-switches consumers to previous state after HP consumer stops.
My automations look like this:
Automations.yaml
#Turning off everything, when kettle consumes electrical power
- alias: Kettle_work
initial_state: true
description: ' '
trigger:
- platform: numeric_state
entity_id: sensor.158d00039bb07f_load
above: '500'
action:
- service: scene.create
data_template:
scene_id: Ke_Before #saving switches status
snapshot_entities:
- switch.plug_158d00039bb085
- switch.plug_158d00039bb0a2
- service: switch.turn_off
entity_id:
- switch.plug_158d00039bb0a2
- switch.plug_158d00039bb085
#Turning sockets to previous status
- alias: Kettle_off
initial_state: true
description: ' '
trigger:
- platform: state
entity_id: sensor.158d00039bb07f_usage #Kettle usage sensor
from: '1'
to: '0'
action:
- service: scene.turn_on
entity_id: scene.Ke_Before
My automation “Kettle_work” doesn’t turn off specific sockets, and also I don’t know, if the scene is creating during automation execution.
Please, tell me, what I’m doing wrong? Or is there exist more rational way to fix switches state, like declaring variables in .yaml?