Guest User

script_device_activiy_shower.lua

a guest
Dec 23rd, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. --[[
  2. -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  3.  
  4. script_device_activity_shower.lua
  5. @author : Siewert Lameijer
  6. @since : 1-1-2015
  7. @updated: 24-12-2016
  8. @Script to switch OFF livingroom lights when one person at home and is taking a shower
  9.  
  10. -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  11. --]]
  12.  
  13. -- Logging: 0 = None, 1 = All
  14. local verbose = 1
  15.  
  16. -- Lights -- IsDark Switches
  17. local shower_light = 'Test Dummy_1' local isdark_dinner_table = 'IsDonker_Eettafel'
  18. local dinner_table_light = 'Woonkamer Eettafel Lamp' local isdark_sunset = 'Sunrise/Sunset'
  19.  
  20. -- Devices -- Variables
  21. local phone_1 = 'Jerina GSM' local isshower_variable = 'IsDouchen'
  22. local phone_2 = 'Siewert GSM' local iskerst = 'Var_IsKerst'
  23. local phone_3 = 'Natalya GSM' local livingroom_lights_timeout = 30
  24. local television = 'Televisie' local dinnertable_lights_timeout = 40
  25.  
  26. -- Door/Window Sensors -- Various Switches
  27. local frontdoor = 'Voor Deur' local someonehome = 'Iemand Thuis'
  28. local backdoor = 'Achter Deur' local network = 'Netwerk'
  29. local livingroom_door = 'Kamer Deur'
  30. local sliding_door = 'Schuifpui' -- Scenes
  31. local scullery_door = 'Bijkeuken Deur' local stage_2 = 'Woonkamer_Stage_2'
  32. local stage_2_xmas = 'Woonkamer_Kerst_2'
  33.  
  34. -- Determine how many phones are at home
  35. if otherdevices[phone_1] == 'On' then a=1 else a=0 end
  36. if otherdevices[phone_2] == 'On' then b=1 else b=0 end
  37. if otherdevices[phone_3] == 'On' then c=1 else c=0 end
  38. online=a + b + c
  39.  
  40. --
  41. -- **********************************************************
  42. -- Livingroom Lights ON/OFF when 1 person is at home and showering
  43. -- **********************************************************
  44. --
  45.  
  46. if devicechanged[shower_light] == 'On'
  47. and uservariables[isshower_variable] == 0
  48. and otherdevices[isdark_dinner_table] == 'On'
  49. and otherdevices[someonehome] == 'On'
  50. --and otherdevices[television] == 'Off'
  51. and otherdevices[network] == 'On'
  52. and otherdevices[frontdoor] == 'Closed'
  53. and otherdevices[backdoor] == 'Closed'
  54. and otherdevices[scullery_door] == 'Closed'
  55. and otherdevices[livingroom_door] == 'Closed'
  56. then
  57. if online == 1 then
  58. if verbose == 1 then
  59. 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>')
  60. end
  61. if uservariables[iskerst] == 0 then
  62. commandArray["Scene:" ..stage_2.. ""]='Off AFTER '..livingroom_lights_timeout..''
  63. commandArray[dinner_table_light]='Off AFTER '..dinnertable_lights_timeout..''
  64. else
  65. commandArray["Scene:" ..stage_2_xmas.. ""]='Off AFTER '..livingroom_lights_timeout..''
  66. commandArray[dinner_table_light]='Off AFTER '..dinnertable_lights_timeout..''
  67. end
  68. commandArray["Variable:" .. isshower_variable .. ""]= '1'
  69. end
  70.  
  71. if online > 1 then
  72. if verbose == 1 then
  73. 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>')
  74. end
  75. end
  76.  
  77. end
  78.  
  79. -- Someone entering the home via Frontdoor and reactivating the light scene
  80. if devicechanged[frontdoor]
  81. and uservariables[isshower_variable] == 1
  82. then
  83. if verbose == 1 then
  84. print('<font color="Darkblue">-- '..isshower_variable..' ==> '..someonehome..' via '..frontdoor..', Livingroom lights will be switched ON...</font>')
  85. end
  86. commandArray[someonehome]='On AFTER 5'
  87. commandArray["Variable:" .. isshower_variable .. ""]= '0'
  88. end
  89.  
  90. -- Someone entering the home via Backdoor and reactivating the light scene
  91. if devicechanged[backdoor]
  92. and uservariables[isshower_variable] == 1
  93. then
  94. if verbose == 1 then
  95. print('<font color="Darkblue">-- '..isshower_variable..' ==> '..someonehome..' via '..backdoor..', Livingroom lights will be switched ON...</font>')
  96. end
  97. commandArray[someonehome]='On AFTER 5'
  98. commandArray["Variable:" .. isshower_variable .. ""]= '0'
  99. end
  100.  
  101. -- Someone entering the home via Livingroom door and reactivating the light scene
  102. if devicechanged[livingroom_door]
  103. and uservariables[isshower_variable] == 1
  104. then
  105. if verbose == 1 then
  106. print('<font color="Darkblue">-- '..isshower_variable..' ==> '..someonehome..' via '..livingroom_door..', Livingroom lights will be switched ON...</font>')
  107. end
  108. commandArray[someonehome]='On AFTER 5'
  109. commandArray["Variable:" .. isshower_variable .. ""]= '0'
  110. end
  111.  
  112. -- Someone entering the home via Sliding_door and reactivating the light scene
  113. if devicechanged[sliding_door]
  114. and uservariables[isshower_variable] == 1
  115. then
  116. if verbose == 1 then
  117. print('<font color="Darkblue">-- '..isshower_variable..' ==> '..someonehome..' via '..sliding_door..', Livingroom lights will be switched ON...</font>')
  118. end
  119. commandArray[someonehome]='On AFTER 5'
  120. commandArray["Variable:" .. isshower_variable .. ""]= '0'
  121. end
  122.  
  123. -- Someone entering the home via scullery_door and reactivating the light scene
  124. if devicechanged[scullery_door]
  125. and uservariables[isshower_variable] == 1
  126. then
  127. if verbose == 1 then
  128. print('<font color="Darkblue">-- '..isshower_variable..' ==> '..someonehome..' via '..scullery_door..', Livingroom lights will be switched ON...</font>')
  129. end
  130. commandArray[someonehome]='On AFTER 5'
  131. commandArray["Variable:" .. isshower_variable .. ""]= '0'
  132. end
Advertisement
Add Comment
Please, Sign In to add comment