Need some help here (got tip to use trigger.from_state.state but dont know how to use it)
Scenario:
When my Alarmpanel triggers alarm I put all switches to on and all lights on with brightness 255 (removed som lines for all switches and lights to simplify):
- id: Alarm Panel Restored
alias: Alarm Panel Restored
trigger:
- platform: state
entity_id: binary_sensor.alarm_panel_alarm
from: 'on'
to: 'off'
How can I get all lights and switches back to the state they were before the alarm (could have been anything depending on the time of the day)?
At the moment I just solved it to get switches off and lights to 128 brightness
You can use Scenes for this if it’s a static brightness on a set number of lights. Otherwise you might have to use helpers to store the values or use a template entity with attributes that lay out the values and devices you want to modify, then tap into those attributes to do what you want.
When added all my entities (21 pieces), this does not work that great anymore,
After some testing I found out that Light Groups seems to trigger but cannot restore to previous state.
The lights in the group seems to go into all kind of different states.
You have to break out the light groups into individual lights when creating scenes on the fly. Otherwise the light group will treat all grouped lights the same. I.e. each light will be set to what the group is set to.
@petro, that is what i want to all go back to what all was before. Invidual lights in the group seems to go into all different states an brightnesses. Will try to ignore the groups and go per device instead.
Yes, that’s what I said… It can handle light groups but it’s not going to restore the individual lights inside it. It will restore all individual lights to what the group had.
e.g.
Your light group is on. Lights A, B and C make up the group. THe light group is on because A is on, B and C are off.
If you restore that light group state, A, B and C will turn on because it’s restoring the “on” state of the group.
Yes, that what I woudl like to have, but it does not work like that for me.
Example:
Have a group “Living Room Windows” consiting of 2 lights grouped into a group entity.
On “trigger” they both go up to 255 brghtness, but on the restore one goes back to the old value the other can go to something else, 75% often as it seems.
Both started at the same brightness before alarm
Your question was answered in the same answer above about the hardware.
I will go with the theory that “scenes-on-the-fly” cannot use light groups and try to map it by device instead.