Automation Condition - Based on Scene Active/Inactive?

I’m getting my feet wet with automation and I have some lights coming on when motion is detected from a zigbee sensor (via DeCONZ) and it’s working wonderfully. I then have these lights going off when the motion isn’t detected for five minutes. For the most part this new automation is working well - but it’s also the sitting room, and motion isn’t the best indicator if people are just hanging out.

I have a few options but not sure how to do them through the UI if that’s my method right now but I’m not even sure how to run them through the UI;

  • Use the brightness of the lights as the condition (i.e. if manually set higher, don’t run)
  • Ideally - use the scene itself, if it’s active or still active, let the automation run

I didn’t see the second anywhere, the first I think I have to get into the config files and likely lose the UI abilities - which is fine, but since I’m starting on automation I’m trying to keep it super simple for now.

Do you have any other devices in the “sitting rooms” that are turned on when you are just sitting there, like a pc or some speakers? If so yxou can have a condition to only turn off the lights if there was no motion for 5 minutes AND non of the “override” entities is turned on.

In this room, I don’t - we only really have the hue bulbs there and I started to automate that with the sensor because previously we only walk through the room if we don’t have company. So we had it coming on with the sun state, but all night (on low).

Wondering, can I create a dummy sensor and after motion is detected for X minutes set it to ON, and then use that to then make it manual turn off (i.e. tell Google to shut it off)? I’m sure there are 12 ways to do this, but I’m not sure yet about doing some behind the scenes hacks.

I have some lights

How many lights do you have in the room?

In my lounge, where I can sit quite still for longer than the no-movement time out I use a smart bulb in a table lamp as the override for the no-movement automation.

  1. Movement turns on all the overhead lights in the room but not the lamp.
  2. If no movement is detected for xx minutes the lights turn off - but only if the lamp is off.

Perhaps you could pick one of your lights to be manually controlled as the override for your lights off automation?

Very easy to add as a condition.

There are just two bulbs, in opposite corners of the room. Here’s what I just thought of;

  • After 5 minutes of movement, make lights 100% via a different scene (right now the scene is basically low light).
  • Add a numeric state condition to check the brightness value.

I was just looking at the above, but I’m not sure I understand it really - i.e. how to extract the numeric value out of this since the states are on/off. I see the Automation Condition page that does this, I think I need to do this via the value template?

Totally get that most of this escapes the UI and gets into the config files, just having a disconnect on that vs what I see typically and understanding the formatting. I think once I understand the notation I’ll get it (is it JSON?)

EDIT:

Like here’s the room’s state & attributes once they are at 100% brightness;

min_mireds: 153
max_mireds: 500
effect_list: colorloop,random
brightness: 254
is_hue_group: true
friendly_name: dining room
supported_features: 63

So what I’m missing is how to check the attribute of ‘brightness’ in the condition.

condition:
  - condition: template
    value_template: "{{ state_attr('light.your_light', 'brightness')|int > 128 }}"
1 Like

Tom, that’s perfect - this is going to open a whole other world. I realized I get the lux values from the same sensor, one in the bedroom, living room, etc.

Now I get the format, very helpful. Now I only need to figure out those stupid Aqara vibration sensors lol. Seems everyone has the same issue and the hack is to figure out the time since the last report (lastupdate) and after x minutes report that it’s not moving any more. Then the wife will really be impressed.