Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. return {
  2.     on = {
  3.         devices = {'Кнопка кухня'}
  4.     },
  5.     logging = {
  6.         level = domoticz.LOG_ERROR
  7.     },
  8.     execute = function(dz, item)
  9.  
  10.          local Lights = dz.devices().filter({'Кухня Бра ЛЕВ', 'Кухня Бра ПРАВ'})
  11.          local bright = 100
  12.  
  13.         Lights.forEach(function(Light)
  14.            if (item.name == 'Кнопка кухня' and item.state ~= 'Off') then
  15.                   if (item.levelName == 'Click') then
  16.                          if (Light.state ~= 'Off') then
  17.                              Light.switchOff()
  18.                          else
  19.                              Light.dimTo(bright)
  20.                          end
  21.                   end    
  22.                   if (item.levelName == 'Double Click') then
  23.                          if (Light.state ~= 'Off') then
  24.                              bright = Light.level
  25.                              Light.dimTo(bright - 20)
  26.                          end
  27.                   end      
  28.                   if (item.levelName == 'Long Click') then
  29.                          if (Light.state ~= 'Off') then
  30.                              bright = Light.level
  31.                                 if (bright <= 80) then
  32.                                     Light.dimTo(bright + 20)
  33.                                 end    
  34.                          end
  35.                   end
  36.                item.switchOff()  
  37.            end      
  38.         end)
  39.     end
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement