Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ à faire :
- - creer un interrupteur virtuel (interrupteur on / off)
- - modifier les noms de devices (servo_on, servo_pourcent)
- - modifier l'url (<ip esp>, <gpio>)
- - vérifier le calcul (les coeff : 30 + device.percentage * 1.50 )
- ]]--
- -- http://www.domoticz.com/wiki/%27dzVents%27:_next_generation_LUA_scripting
- return {
- -- 'active' controls if this entire script is considered or not
- active = true, -- set to false to disable this script
- -- trigger
- -- can be a combination:
- on = {
- devices = {
- -- scripts is executed if the device that was updated matches with one of these triggers
- 'servo_on', -- interr ON SERVO
- 'servo_pourcent'
- },
- },
- -- actual event code
- -- in case of a timer event or security event, device == nil
- execute = function(domoticz, device)
- if (device.name == 'servo_on') then
- if (device.state == 'On') then
- domoticz.devices("servo_pourcent").updatePercentage(60) -- met à 60% instantanement
- domoticz.devices("servo_pourcent").updatePercentage(0).afterSec(2) -- puis à 0% 2s plus tard
- else
- -- commande off ?
- domoticz.devices("servo_pourcent").updatePercentage(0)
- end
- elseif (device.namme == 'servo_pourcent') then
- valeur = math.floor(30 + device.percentage * 1.50);
- url = "http://<i esp>/control?cmd=Servo,1,<gpio>,".. valeur
- domoticz.openURL(url)
- end
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement