Return light to previous state after automation

Hello everyone, what is the best way to remember current light (state, colour, brightness) and return it later in automation or script if required? I thought I would hold global variables as MQTT sensors, so in automation I’m able to save state but I’m unable to apply settings to the light when needed.


thank you, super easy :slight_smile:

For those still wanting to accomplish this without jumping through too many hoops.
You can make use of scenes to save the state beforehand and then reapply it when you want to revert back to the previous state. Better than creating many inputs in the config. Can save the state of many entities in one go.

- id: 'doorbell_pressed'
  alias: 'Doorbell Pressed'
  description: 'Flash lights light blue when someone presses the doorbell'
  - entity_id: binary_sensor.doorbell_button 
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  - data:
      scene_id: doorbell_notification_revert
      snapshot_entities: 'light.living_room,'
    service: scene.create
  - data:
      effect: Facebook
      entity_id: light.living_room
    service: light.turn_on
  - data:
      effect: Facebook
    service: light.turn_on
  - delay: 00:00:04
  - data:
      entity_id: scene.doorbell_notification_revert
    service: scene.turn_on

How did you get this to work?

I have one automation that does this:

and then another one that does this.

But it doesnt revert?