Lights automation and device tracker

That makes more sense

Edit: just saw the other reply from @Burningstone about transitions, scriptsā€¦

Huh. I never would have even thought to use scenes within scenes. Clever. Guess I never really used them extensively enough to even consider it. Any idea if that is the only limitation now or have they changed anything else? Honestly, I donā€™t see myself using them for much other than lighting anytime soon. Even then itā€™s limited to when I need to store current lighting to restore after some event that affects the lighting.

I used to use Philā€™s light store python script (and still do in some places) to accomplish this but I noticed the new scene.create service so I thought Iā€™d try it out. It works so I left it. Hereā€™s one example I have for the automation when my garage door opens. arrive_home_lights is actually a light group that includes the lights in my garage, my side entrance, porch light etc.

    - service: scene.create
      data_template:
        scene_id: garage_door_lights
        entities:
          light.arrive_home_lights:
            state: "{{ states('light.arrive_home_lights') }}"
            brightness: "{{ state_attr('light.arrive_home_lights','brightness') }}"

    - service: script.turn_light_on
      data_template:
        light_name: 'garage_lights'
        brightness: 30
        ignore_user_state: 'true'

    - wait_template: "{{ is_state('sensor.side_entrance_motion','off') }}"
      timeout: '1:00:00'
      continue_on_timeout: true

    - delay: '0:05:00'

    - service: scene.turn_on
      entity_id: scene.garage_door_lights
2 Likes

Iā€™m generally a fan of Phil but actually I donā€™t use any of his components (Iā€™m a liar, I use life360 and virtually every occupancy tip heā€™s ever posted because I donā€™t use ā€˜personā€™) but not come across that. Hmmm interesting, Iā€™ll look at that later.
Of the above I donā€™t recognise the bit you I (itā€™s getting late) quoted (feel free to explain)
All the rest of it though could easily be done in a script soā€¦ What am I missing ? (its usually big and grey with a trunk)

Absolutely nothing! Different strokes for different folks! I just like exploring all the different options.

Itā€™s a parameter for a script that prevents automation from changing entities if the occupant has recently used it. So say if I turn on a light in the living room no automatons will change that lightā€™s state (until the associated timer runs out) unless ignore_user_state was set to true (for example the smoke alarm - the lights turn on no matter what the user state is). If youā€™re interested I can put into a gist for you.

1 Like

I think this is a perfect example of a use case for the ā€œnewā€ scenes. I would use it the same way if I would use scenes :rofl:

I think all of it can be done with scripts, itā€™s just ā€œeasierā€ with scenes.

Here is a good explanation I found on Github on how scenes work and why you canā€™t call scripts/scenes from them:

Scenes are based on the state of an entity. All entities that provide a meaningful state can be used in a scene.

Scripts and scenes and some other entities do not have a meaningful state, so they cannot be used in scenes. Scenes do not notice whether they are active or not, they are always scening . Scripts are on or off indeed, but this is only a momentary state and you donā€™t want the script to be on , you want it to have been executed in the past.

Long story short, neither scripts nor scenes will be usable in scenes in the near future.

2 Likes

@jazzyisj Jason (reply is to burning but you first) but I understood that scenes were one shots, so the point is moot.
I always want things how I set them so if I want them that way I set them that way.
I just donā€™t see the point in scenes.

Burning, thanks for that, the best explanation Iā€™ve ever ā€˜seenā€™ (ha ha) So Iā€™ll stick with scripts (never used a scene in my life - though maybe if I was doing theatre ??? (but then Iā€™d have access to much better hardware)

Thank you both for the education. :smiley:

1 Like

Not sure if Iā€™m high jacking this but Iā€™m also planning to implement something similar to this, one difference would be i have a zigbee wall switch controlling a WiZ light. I havenā€™t wire them up, in process of renovations.

Iā€™m thinking the tracker would trigger and check the conditions if to turn on the zigbee switch, though then (where Iā€™m stuck) need to wait for the WiZ light to come online and connect, then switch the the appropriate scene. Or am i wrong to assume HA will only fire off to set a scene once regardless if device is online, and ends the automation. So if my WiZ was slow in connecting, it basically wont change to appropriate scene?

Why do you want to have a zigbee switch between the light? Why not direclty connect the light to the power?

Cause I would like to be able to turn lights on/off via physical switches, and with my mobile without having to walk to the switch.