Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.67 KB | None | 0 0
  1. return {
  2.     on = {
  3.         timer = {'every minute'},
  4.         devices = {'Спальня Light', 'Спальня Switch'}
  5.     },
  6.     logging = {
  7.         level = domoticz.LOG_ERROR
  8.     },
  9.     execute = function(dz, item)
  10.        
  11.          local Light = dz.devices('Спальня Light')
  12.          local IP    = '192.168.1.37'
  13.          local PORT  = '55443'
  14.          local t     = dz.time
  15.  
  16.         if (t.matchesRule('at 00:00-08:00')) then bright = 1   param = "[\"color\", 16750848, "..bright.."]" end
  17.         if (t.matchesRule('at 08:00-23:00')) then bright = 100 param = "[\"ct\", 3812, "..bright.."]" end
  18.         if (t.matchesRule('at 23:00-00:00')) then bright = 10  param = "[\"ct\", 3812, "..bright.."]" end
  19.          
  20.  function LightOn()
  21.     SetScene = "sudo echo -ne '{\"id\":1, \"method\":\"set_scene\", \"params\":"..param.."}\\r\\n' | nc -w1 " ..IP.." " ..PORT..""
  22.     dz.utils.osExecute('('..SetScene..' > /dev/null)&')
  23.     Light.dimTo(bright).afterSec(0.5)
  24.  end
  25.  
  26.         if (item.isDevice) then
  27.                if (item.name == 'Спальня Switch' and item.state ~= 'Off') then
  28.                       if (item.levelName == 'Click') then
  29.                              if (Light.state ~= 'Off') then
  30.                                  Light.switchOff()
  31.                              else
  32.                                  LightOn()
  33.                              end
  34.                       end
  35.                       if (item.levelName == 'Double Click') then
  36.                           bright = 25
  37.                           param = "[\"ct\", 3812,"..bright.."]"
  38.                           LightOn()
  39.                       end
  40.                       if (item.levelName == 'Long Click') then
  41.                           bright = 100
  42.                           param = "[\"color\", 16766634,"..bright.."]"
  43.                           LightOn()
  44.                       end
  45.                end
  46.         end
  47.         if (item.isTimer) then
  48.                if (Light.state ~= 'Off') then
  49.                       if (t.rawTime == '0:1:0') then
  50.                           bright = 1
  51.                           param = "[\"color\", 16750848, "..bright.."]"
  52.                           LightOn()
  53.                       end
  54.                       if (t.rawTime == '8:0:0') then
  55.                           bright = 100
  56.                           param = "[\"ct\", 3812,"..bright.."]"
  57.                           LightOn()
  58.                       end
  59.                       if (t.rawTime == '22:59:0') then
  60.                           bright = 10
  61.                           param = "[\"ct\", 3812,"..bright.."]"
  62.                           LightOn()
  63.                       end
  64.                end
  65.         end
  66.     end
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement