Kids that never turn off the tv?

I have a solution, this is how i manage solve this “irritating problem”.

I assume that you have a Z-wave base, mine is a raspberryPi with a razberry chip and with software domoticz.

You shoppinglist:
1pcs Inline Smart Energy Switch from Aeon Labs
1pcs Motion sensor from Fibaro
In sweden you can get all you need at

Aeon Labs – Switch

Fibaro motion sensor


And I use a LUA script named script_time_PIR-tv.lua. So after 20 minutes of inactivity in livingroom, the tv shutsdown… Simply as that!

function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
commandArray = {}
-- Set length of time light should be on for in seconds
timeon = 1200
-- Calculate time since time PIR was last activated
difference = timedifference(otherdevices_lastupdate['Vardagsrum motion'])
-- If the time since last activation was within 1 minute of time for light to stay on
if (difference > timeon and difference < (timeon + 61)) then
tempdiff = tostring(difference)
tempmessage = "Switch1 Light Off - after at least " .. (timeon+1) .. "secs up - actually - " .. tempdiff .. "seconds"
-- Switch off Switch1
commandArray['Tv'] = 'Off'
return commandArray


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.