How do I save a state for a light?

I have a very nice light that I control via an RF remote, or in my case, HA and sonoff rfbridge.
I would very much like to save the state of the light, as it can change color, and have different effects in it.
So of course I have a light defined that can turn on and off.
And that stores the on/off state, but it also has a lot of color settings and I don’t know how to save that?
I’ve made a panel for controlling the light, which mimics the remote control:


And the ‘on’ button is of course reacting on the state of the light but I would very much like to have the ‘color buttons’ react as well, but that requires that I have a ‘state’ somehow I can use.

Do you have an example of the event payload from the light/rf bridge?

Does it include state information about the colour and brightness?

1 Like

The light doesn’t report a status, it’s a status I have to set when one of the commands are sent to the light.
So my idea was to use the existing panel, so that when I do the call-service, it also sets a status for the light.
Of course this will not work if the lights own remote is used, but that’s a negligeble problem for me :slight_smile:

So you don’t get a reply when you send the command?

1 Like

Nope, nothing.

Then the solution I can think of is this:

  • A button toggles an input_boolean.
  • An automation triggers on the input_boolean turning on, it’s actions are to send the command.

Your button can then use the input_boolean state to change it’s appearance.

You could perhaps use only one automation that triggers on all the input booleans, then use a template to select the correct command to send. Or use an automation for each input boolean (easier to understand, but requires more configuration).

1 Like

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'
  trigger:
  - entity_id: binary_sensor.doorbell_button 
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      scene_id: doorbell_notification_revert
      snapshot_entities: 'light.living_room,light.kitchen'
    service: scene.create
  - data:
      effect: Facebook
      entity_id: light.living_room
    service: light.turn_on
  - data:
      effect: Facebook
      entity_id: light.kitchen
    service: light.turn_on
  - delay: 00:00:04
  - data:
      entity_id: scene.doorbell_notification_revert
    service: scene.turn_on
2 Likes