Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. --[[ à faire :
  2.  
  3.  - creer un interrupteur virtuel (interrupteur on / off)
  4.  - modifier les noms de devices (servo_on, servo_pourcent)
  5.  - modifier l'url (<ip esp>, <gpio>)
  6.  - vérifier le calcul (les coeff :  30 + device.percentage * 1.50  )
  7.  
  8.  
  9. ]]--
  10. -- http://www.domoticz.com/wiki/%27dzVents%27:_next_generation_LUA_scripting
  11. return {
  12.  
  13.     -- 'active' controls if this entire script is considered or not
  14.     active = true, -- set to false to disable this script
  15.  
  16.     -- trigger
  17.     -- can be a combination:
  18.     on = {
  19.         devices = {
  20.             -- scripts is executed if the device that was updated matches with one of these triggers
  21.             'servo_on', -- interr ON SERVO
  22.             'servo_pourcent'
  23.         },
  24.  
  25.     },
  26.  
  27.     -- actual event code
  28.     -- in case of a timer event or security event, device == nil
  29.     execute = function(domoticz, device)
  30.         if (device.name == 'servo_on') then
  31.             if (device.state == 'On') then
  32.                 domoticz.devices("servo_pourcent").updatePercentage(60)     -- met à 60% instantanement
  33.                 domoticz.devices("servo_pourcent").updatePercentage(0).afterSec(2)  -- puis à 0% 2s plus tard
  34.             else
  35.                 -- commande off ?
  36.                 domoticz.devices("servo_pourcent").updatePercentage(0)
  37.             end
  38.         elseif (device.namme == 'servo_pourcent') then
  39.             valeur = math.floor(30 + device.percentage * 1.50);
  40.             url = "http://<i esp>/control?cmd=Servo,1,<gpio>,".. valeur
  41.             domoticz.openURL(url)
  42.         end
  43.     end
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement