Help using a presence sensor to turn off lights inside Room Lighting

Hi folks, been using Hubitat for a few years but only scratching the surface of its capabilities. I'm starting to implement some more sophisticated automations and as a start I'm trying to move some of my existing Rule Machine rules over into Room Lighting so I can eventually expand them further inside Room Lighting.

I've hit my first roadblock and need some help!

Currently, I use Rule Machine with motion/occupancy sensors (Eve and Ecobee) to turn off Master Bedroom (MBR) lights 30 minutes after they report vacancy. Pertinent to this question is that these are HomeKit sensors that are connected to HomeKit and brought into HE via the official HomeKit integration. I use the Virtual Presence with Switch device and some simple automations on the HomeKit side to mirror the HomeKit sensor state into the HE Virtual Presence sensor, which is then used by HE automations. This all works fine for my Rule Machine automation.

HE Virtual Presence with Switch device:

HomeKit automations to mirror HomeKit sensors into HE virtual sensor:

Existing Rule Machine rule that turns lights off 30 minutes after the sensor reports vacancy:


Now I'm trying to implement this in Room Lighting. Problem is I can't figure out how to implement the "turn lights off 30 minutes after the sensor reports vacancy" in the Room Lighting app. This is what I have so far. I'm using Presence Sensors that all leave, but I can't figure out how to add the 30 minute cancellable delay.

It looks like using All Motions stays inactive as a Means to Turn off Lights would do what I want, but the problem, I think, is that Virtual Presence with Switch device is a Presence sensor not a Motion sensor and as such it is not selectable for All Motions stays in active:

I assume a Virtual Motion with Switch (instead of Virtual Presence with Switch) would do what I want, but this doesn't seem to exist, at least not officially. I tried some of the community drivers for Virtual Motion with Switch and I can't expose them to HomeKit, only the official Virtual Presence with Switch.

How do I solve this?
If I'm doing something weird (plausible), please educate me. :slight_smile:


Can you just define the virtual device in HE as a virtual motion sensor rather than virtual presence sensor?

I don't think so. In order to mirror sensor state from HomeKit into HE, I have to use a 'hybrid' device, that is, with sensor and switch capabilities, such as Virtual Presence with Switch.

I can use HomeKit sensors to set the state of a Virtual Switch (including hybrid sensor+switch like Virtual Presence with Switch), but I cannot use HomeKit sensors to set the stage of a Virtual Sensor (of any type). I think this means I'm limited to Virtual Presence with Switch which far as I'm aware is the only hybrid sensor/switch that I can expose to HomeKit for mirroring.

But maybe I'm missing something here and there's another way..?

You could use the "delay turning off" option to set a period between vacancy and the lights turning off. I'm not sure what will happen if presence recurs during that delay--hopefully the rule starts over and cancels delayed actions (as it does in Rule Machine when a rule is re-triggered).

Thanks. I saw that option, but assumed it was a non-cancellable delay meant for folks needing a short (<60 seconds) delay enabling them to flick a switch or hit a button and walk out of a room before the light goes out on them. Especially since this delay only adjusts in 'seconds of delay'.

I can't find any documentation on it though, so I'll try it, but it still doesn't feel right. I'd like to be able to specify in hours/minutes without having to use a calculator to figure out how many seconds that is.

I'm still wondering why there isn't a corresponding Virtual Motion with Switch device, as that would solve this.

I am thinking you should use the switch portion of the virtual device. Present and On are identical, Not Present and Off are identical. Use Presence where presence makes sense, use on/off where a switch makes sense.

1 Like

It doesn't look like a switch turning off allows for a number of minutes before turning the lights off.

You could create a virtual motion sensor and then make a Rule Machine rule that says when the presence sensor shows presence, set the virtual motion sensor to active, and when presence ends, set the virtual motion sensor to inactive. (Use run custom action.) Then use the virtual motion sensor in Room Lighting.


Thanks, I appreciate your help. That does seem like an option, but (a) it seems a bit janky (mirroring across two sets of dummy/virtual devices - one from HK->HE, and another from presence->motion), and (b) the whole point of this exercise was to leave Rule Machine and control the room from Room Lighting. If I can only make my Room Lighting automation work by implementing helper rules in Rule Machine, then I'll just stick with Rule Machine.

Hubitat refers to Room Lighting as the One Lighting App to Rule Them All, so I'm hoping there is (or will be!) some way to do this without workarounds. Hoping one of the official Hubitat folks will see this and chime in.

Afraid I'm not following you here. In this case I'm using Presence (or trying to) because that's what makes sense for my use case. I'm triggering an action when no-one is present, not in response to any switch activity or state. Not clear why it would make more sense to use the Switch capability in this situation. The only reason a Switch is involved at all is because this is what I have to use on the HomeKit side to mirror the sensor state back into HE.

In any case, I tried using the switch portion of the hybrid virtual device inside the Room Lighting but it doesn't solve the issue. If for Means to Turn Off Lights I use Switch turns off (pointing to the Switch portion of my hybrid virtual device, like you suggest) then the only delay option I have is the same non-cancellable Delay Turning Off option that @eelton mentioned in post #4. I need a cancellable delay.