Recurring lights Auto-off after 'x' minutes

1.6k views Asked by At

I've been looking for a feature that will automatically turn the lights off after 'x' minutes if they have been on. Basically if someone forgets to turn the light off, I want it to turn off after some time interval. Does something like this exist already?

The stock IOS app has a timer function, but it is not recurring. All the other routines want a specific day/time to do something but I don't care about day/time.

I wrote some sample code in Python that pulls the state of the group at an interval and if it exceeds the threshold, it turns the light off. If there is something out there that does this already, I won't go further...but if it doesn't exist, I will continue writing the code.

2

There are 2 answers

0
kapsalis On

This is an old topic, but I was looking for the same information. After a while, I realized that it is more simple to create a rule with the following body, to turn off the light (in my case is a hue smart plug) 8 minutes after it turned on.

{
    "name": "Turn off automatically",
    "conditions": [
        {
            "address": "/lights/12/state/on",
            "operator": "eq",
            "value": "true"
        },
        {
            "address": "/lights/12/state/on",
            "operator": "ddx",
            "value": "PT00:08:00"
        }
    ],
    "actions": [
        {
            "address": "/lights/12/state",
            "method": "PUT",
            "body": {
                "on": false
            }
        }
    ]
}
0
miknik On

Depending on how you turn on the lights you could set this up as a rule within the bridge pretty easily. You'll probably have to use the API to configure it though.

Create 2 new generic sensors within the bridge. Add a condition to the rule which switches on the lights to also update the value of sensor 1 every time the lights are turned on. Let's say we are going to set it to 1 each time the lights are switched on.

Create a timer within the bridge to update sensor 2 every minute (or whatever), doesn't matter what it updates it with.

Finally create a rule which will only trigger if the value for sensor 2 changes (DX operator) and sensor 1 is has been set to 1 for 2 hours (or whatever your timeout period is) using the STABLE operator. Have that rule switch off the lights.

Include the IN/NOT IN parameters to narrow your rule down to certain times of day