Resume previous light state after scene ends

I’ve created a scene that after sunset if motion is detected my drive lights go full brightness with RGB [255,255,255] for a minute and then turns off.
If my driveway lights are already on say at 30% and red before the scene runs, can I somehow save that state and resume it after the motion scene ends?

Short answer is: yes you can. :slight_smile:

A little bit more serious is that you can use template sensor(s) and create automation(s) to assign value(s) to template sensor(s). Then you hide the template sensor(s) from the gui, and ther you go.

cheers
tom

or template switch, which you turn on when your driveway light are at 30%.

Hi,

I want to alter the brightness and colour of a Lifx globe for a certain time, then return it to the previous colour and brightness, and came across this thread which looks the same. In it, towme says it’s possible with templates… but I’m sorry, I just don’t see how!

To my mind, I’d want to have some temporary variables which hold the normal setting values - copy the light’s values to the temporaries before changing the brightness and colour, then copy them back at the end.

Thanks for any help!

In HA, the different components have nothing to do with the hardware you have. So if you have 5 lights in your home you can still have 10 switches.
Or you can use groups, but in my opinion goruping is not that flexible as having virtual thingies.
Maybe a better example is how my heating works. Depending on the outside temperature an automation sets, an input_select value, which in return controls the heating. So if it is -5 outside than the input_select value becomes 22, and if the temperature is under 22 in the living room, then the living room heating turns on.
After creating the input_select you can decide to make it appear on the frontend or stay hidden.

You just have to find the right component. If you want to store on/off states then an input_boolean is enough, but if you want to store multiple (list like) states input_select can be used.

Real world example (“This is how we do it”):

First automation: which sets the “control” temperature

# Minus outside
  alias: 'HEAT - Minus outside'
  trigger:
    - platform: template
      value_template: "{{ (states.sensor.dark_sky_temperature.state|float) < -2 }}"

  action:
    - service: input_select.select_option
      data:
        entity_id: input_select.living_temp
        option: '24'
    - service: input_select.select_option
      data:
        entity_id: input_select.kitchen_temp
        option: '26' 

Second automation: Which turns on heating

# Living room heating ON
  alias: 'HEAT - Livingroom ON'
  trigger:
    - platform: template
      value_template: "{{ (states.sensor.livingroom.state|float) - (states.input_select.livingroom_temp.state|float) < 0 }}"

  condition:
    condition: and
    conditions:
      - condition: template
        value_template: "{{ (states.sensor.livingroom.state|float) > 0 }}"
      - condition: state
        entity_id: switch.livingroom_heater_1
        state: 'off'

  action:
    - service: homeassistant.turn_on
      entity_id: switch.livingroom_heater_1
    - service: homeassistant.turn_on
      entity_id: switch.livingroom_heater_2 

The input_select does not need any predefined list. You can make up your own.
like:
“Oh my god it is so dark”
“It would be nice to have some more light”
“Oh no! I am getting blind”
but of course it is little bit harder to check these kind of states :slight_smile:

good luck
tom

Thanks Tom! Great example.

So…

input_select.select_option is like the name of a dictionary, input_select.living_temp is like a key, and option: denotes the value.

Would this also work for the RGB value of the light, or would I have to extract R,G and B?

Thanks again!
Karl

The current LIFX effects flash between two colors. It seems that a light effect that just temporarily changes to a solid color could be useful. I will try implementing that for HA 0.47.

Thanks Amelchio,

The use-case I have is where I have a corridor with three Lifx globes and a couple of movement sensors. The lights only need to be on at night.

Because the Lifxs have RBG and group effects, I like to have different colours for each (I use the Lifx app’s group themes), and automatically light the way ahead of people as they go through the corridor at night.

However, there are also cupboards there, and it is very hard to get things out of the cupboards when the lighting is e.g. a deep blue. Worse is when the lights turn off and you have to move around to get them to turn them on again. You almost need a torch!

Obviously, the solution is to have an override - a switch which turns all the globes to white and full brightness for, say up to 20 minutes. Then, if you flip the switch, or wait the 20 minutes, the lights should revert to their previous settings.

The interesting thing about this is that once you decouple the globe from the switch that used to turn it on and off, you get more advantages. That is, rather than simply doing what you would normally do because you are too lazy to get up from the couch, you get more.

1/ The home automation system works to give the globe a default behaviour - turns on when there’s movement late at night, randomly turns on and off when you’re away, turns to particular settings in response to scenes, etc.

2/ A manual override gives you the normal feature of a globe which is under your control.

Both of these can work with the same globe and don’t have to interfere with each other…

Just for the record, this was indeed added in version 0.47.

    action:
      - service: light.lifx_effect_pulse
        data:
          entity_id: light.office
          mode: solid
          kelvin: 2800
          brightness_pct: 100
          period: 1200