Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
- script_device_activity_shower.lua
- @author : Siewert Lameijer
- @since : 1-1-2015
- @updated: 24-12-2016
- @Script to switch OFF livingroom lights when one person at home and is taking a shower
- -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
- --]]
- -- Logging: 0 = None, 1 = All
- local verbose = 1
- -- Lights -- IsDark Switches
- local shower_light = 'Test Dummy_1' local isdark_dinner_table = 'IsDonker_Eettafel'
- local dinner_table_light = 'Woonkamer Eettafel Lamp' local isdark_sunset = 'Sunrise/Sunset'
- -- Devices -- Variables
- local phone_1 = 'Jerina GSM' local isshower_variable = 'IsDouchen'
- local phone_2 = 'Siewert GSM' local iskerst = 'Var_IsKerst'
- local phone_3 = 'Natalya GSM' local livingroom_lights_timeout = 30
- local television = 'Televisie' local dinnertable_lights_timeout = 40
- -- Door/Window Sensors -- Various Switches
- local frontdoor = 'Voor Deur' local someonehome = 'Iemand Thuis'
- local backdoor = 'Achter Deur' local network = 'Netwerk'
- local livingroom_door = 'Kamer Deur'
- local sliding_door = 'Schuifpui' -- Scenes
- local scullery_door = 'Bijkeuken Deur' local stage_2 = 'Woonkamer_Stage_2'
- local stage_2_xmas = 'Woonkamer_Kerst_2'
- -- Determine how many phones are at home
- if otherdevices[phone_1] == 'On' then a=1 else a=0 end
- if otherdevices[phone_2] == 'On' then b=1 else b=0 end
- if otherdevices[phone_3] == 'On' then c=1 else c=0 end
- online=a + b + c
- --
- -- **********************************************************
- -- Livingroom Lights ON/OFF when 1 person is at home and showering
- -- **********************************************************
- --
- if devicechanged[shower_light] == 'On'
- and uservariables[isshower_variable] == 0
- and otherdevices[isdark_dinner_table] == 'On'
- and otherdevices[someonehome] == 'On'
- --and otherdevices[television] == 'Off'
- and otherdevices[network] == 'On'
- and otherdevices[frontdoor] == 'Closed'
- and otherdevices[backdoor] == 'Closed'
- and otherdevices[scullery_door] == 'Closed'
- and otherdevices[livingroom_door] == 'Closed'
- then
- if online == 1 then
- if verbose == 1 then
- print('<font color="Darkblue">-- '..isshower_variable..' ==> There seems to be just '..online..' person at home and is probably taking a shower, Livingroom lights will be switched OFF in '..livingroom_lights_timeout..' seconds...</font>')
- end
- if uservariables[iskerst] == 0 then
- commandArray["Scene:" ..stage_2.. ""]='Off AFTER '..livingroom_lights_timeout..''
- commandArray[dinner_table_light]='Off AFTER '..dinnertable_lights_timeout..''
- else
- commandArray["Scene:" ..stage_2_xmas.. ""]='Off AFTER '..livingroom_lights_timeout..''
- commandArray[dinner_table_light]='Off AFTER '..dinnertable_lights_timeout..''
- end
- commandArray["Variable:" .. isshower_variable .. ""]= '1'
- end
- if online > 1 then
- if verbose == 1 then
- print('<font color="Darkblue">-- '..isshower_variable..' ==> There seems to be '..online..' persons at home and 1 is probably taking a shower, No changes to Livingroom lights will be made...</font>')
- end
- end
- end
- -- Someone entering the home via Frontdoor and reactivating the light scene
- if devicechanged[frontdoor]
- and uservariables[isshower_variable] == 1
- then
- if verbose == 1 then
- print('<font color="Darkblue">-- '..isshower_variable..' ==> '..someonehome..' via '..frontdoor..', Livingroom lights will be switched ON...</font>')
- end
- commandArray[someonehome]='On AFTER 5'
- commandArray["Variable:" .. isshower_variable .. ""]= '0'
- end
- -- Someone entering the home via Backdoor and reactivating the light scene
- if devicechanged[backdoor]
- and uservariables[isshower_variable] == 1
- then
- if verbose == 1 then
- print('<font color="Darkblue">-- '..isshower_variable..' ==> '..someonehome..' via '..backdoor..', Livingroom lights will be switched ON...</font>')
- end
- commandArray[someonehome]='On AFTER 5'
- commandArray["Variable:" .. isshower_variable .. ""]= '0'
- end
- -- Someone entering the home via Livingroom door and reactivating the light scene
- if devicechanged[livingroom_door]
- and uservariables[isshower_variable] == 1
- then
- if verbose == 1 then
- print('<font color="Darkblue">-- '..isshower_variable..' ==> '..someonehome..' via '..livingroom_door..', Livingroom lights will be switched ON...</font>')
- end
- commandArray[someonehome]='On AFTER 5'
- commandArray["Variable:" .. isshower_variable .. ""]= '0'
- end
- -- Someone entering the home via Sliding_door and reactivating the light scene
- if devicechanged[sliding_door]
- and uservariables[isshower_variable] == 1
- then
- if verbose == 1 then
- print('<font color="Darkblue">-- '..isshower_variable..' ==> '..someonehome..' via '..sliding_door..', Livingroom lights will be switched ON...</font>')
- end
- commandArray[someonehome]='On AFTER 5'
- commandArray["Variable:" .. isshower_variable .. ""]= '0'
- end
- -- Someone entering the home via scullery_door and reactivating the light scene
- if devicechanged[scullery_door]
- and uservariables[isshower_variable] == 1
- then
- if verbose == 1 then
- print('<font color="Darkblue">-- '..isshower_variable..' ==> '..someonehome..' via '..scullery_door..', Livingroom lights will be switched ON...</font>')
- end
- commandArray[someonehome]='On AFTER 5'
- commandArray["Variable:" .. isshower_variable .. ""]= '0'
- end
Advertisement
Add Comment
Please, Sign In to add comment