Luup Scene for Dimmable Plug-in Module

Ok I am trying to write a simple Luup scene that if my 6 year old son turns on his TV between 21:00 Hrs and 23:00 Hrs it will turn the plug-in module off. I had it on a timer which worked well until he figured out he could press the button on it and turn it back on.

I tried the below but it doesn’t seem to work. Any Suggestions?

current_second = os.date(‘*t’,os.time())[“hour”] * 3600 + os.date(‘*t’,os.time())[“min”] * 60 + os.date(‘*t’,os.time())[“sec”]

min_time_in_seconds = 21 * 3600 + 0 * 60
max_time_in_seconds = 23 * 3600 + 15 * 60

if (current_second > min_time_in_seconds) and (current_second < max_time_in_seconds)
then
luup.call_action(“urn:upnp-org:serviceId:BinaryLight1”,“SetTarget”,{ newTargetValue=“0” },43)

return false

end

What are you using to trigger the scene? Did you check that you have the timezone set properly on your Vera?

On another note: You don’t think we would realize that he can just remove the plug-in module and plug the TV directly into the wall?

After taking another look, I believe you have the service id wrong. The BinaryLight device uses the SwitchPower service:

luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },43)

At that point I will buy a Zwave power strip and let him figure away around that too! LOL

Yeah SwitchPower1 doesn’t seem to do it either. I have tried the Node ID and Device ID’s and it just doesn’t seem to fire.

What is your trigger or event that activates the scene? Are you sure it is firing?

You could try putting the following as the Luup Event and using the GUI command section to send the off command:

current_second = os.date(‘*t’,os.time())[“hour”] * 3600 + os.date(‘*t’,os.time())[“min”] * 60 + os.date(‘*t’,os.time())[“sec”]

min_time_in_seconds = 21 * 3600 + 0 * 60
max_time_in_seconds = 23 * 3600 + 15 * 60

if (current_second > min_time_in_seconds) and (current_second < max_time_in_seconds)
then
return true
else
return false
end

Returning false in the Luup Event when not in your time range is supposed to cancel the scene and run the commands. I haven’t used that technique yet in my own system, but that is what the documentation says.

The trigger is the device being turned on. I will give you suggestion a try today.

Ok it works I was being an idiot and somehow disabled the triggering event.

Cool. If he starts plugging the TV directly into the wall, you could superglue the TV’s plug to the module :wink:

Or replace the power outlet with the Z-Wave one, although one of two sockets is “always on”… Just disable it, I guess :slight_smile:

I’m just wondering what happens when your son gets old enough, and starts turning the tables on you. Locking out of your TV, Turning the lights on and off at strange hours just to mess with your head. 8)

hilarious! ;D

Well, there’s always the no TV in the kids bedroom rule too … Not as technologically sophisticated of a solution though.

I personally like the super glue idea!!