Voici la version utilisée, sous docker :
Version: 2021.1
Build Hash: 8547c5b7e
Compile Date: 2021-04-17 17:29:11
dzVents Version: 3.1.7
Python Version: 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0]
Côté logs du device je vois bien l'activation de mon équipement (qui change bien d'état on/off), et je le vois également dans les logs domoticz de ce type :
2021-12-06 14:56:20.340 Shelly: Light/Switch (Shelly_1_88)
2021-12-06 14:56:20.336 Status: User: Skwimotic (IP: 192.168.x.x) initiated a switch command (368/Shelly_1_88/On)
Par quel mécanisme le shelly pourrait annuler la commande?
en activant le dummy domoticz envoie l'ordre en http et trigger en même temps le script (je pense).
le shelly lui renvoie un changement - pour le même état - sans trigger (pour pas que ça boucle)
et ce qui est étrange c'est qu'après un reboot ça fonctionne de nouveau
j'imagine qu'il y a une variable de domoticz que je ne connais pas qui me pose problème, et qui serait réinitialisée à son reboot
Sur un autre sujet : j'avais un peu galéré sur ma variable utilisateur car je me suis rendu compte que son état n'était pas mis à jour en temps réel
Si je fais ça alors que la variable était à Off, ça m'affiche Off, d'où ma variable locale. Je ne sais pas si ça peut avoir un lien avec mon soucis
domoticz.variables('bypass_lumi_garage').set('On')
domoticz.log('variable bypass_lumi_garage :'..domoticz.variables('bypass_lumi_garage').value)
Le code en question :
Code : Tout sélectionner
return
{
active = true,
on =
{
devices = {'Buanderie Xiaomi Motion 1','Garage Xiaomi Motion 2','Atelier Xiaomi Motion 3','Atelier Xiaomi Motion 5',
'Buanderie-Couloir Xiaomi Sensor 1','Buanderie-Atelier Xiaomi Sensor 2','Garage-Electrique Xiaomi Sensor 3',
'Shelly_1_88','Shelly_1_89','Shelly_1_88_switch','Shelly_1_89_switch'} --,'shelly_test'
},
logging =
{
level = domoticz.log_info,
marker = "buanderie_light"
},
execute = function(domoticz, device)
--declaration des lumières
local gateway_light = domoticz.devices('Xiaomi RGB Gateway')
local atelier_light = domoticz.devices('YeeLight atelier')
local buanderie_light = domoticz.devices('Shelly_1_89')
local garage_light = domoticz.devices('Shelly_1_88')
--timer
local duree = 2
--declaration des capteur lux
local gateway_lux = domoticz.devices('Xiaomi Gateway Lux').lux
local xia3_lux = domoticz.devices('Atelier Xiaomi Lux 3').lux
--recupération si une des lumières est déjà allumée ou non
local etat_global = 'Off'
if (buanderie_light.state == 'On' or atelier_light.state == 'On' or garage_light.state == 'On')then
etat_global = 'On'
end
domoticz.log('etat_global :'..etat_global)
domoticz.log('device.name :'..device.name)
--si allumage explicite via voix ou bouton, manuel à true
local bypass_lumi_garage = domoticz.variables('bypass_lumi_garage').value
if (device.active and (string.find(device.name,'Shelly_1_') ~= nil)) then
domoticz.log('Shelly active')
--domoticz.log('avant set '..domoticz.variables('bypass_lumi_garage').value)
--si switch 88/89 et shelly 88/89 "éteint" (=='on' car via inter ça turn on avant d'arriver à domoticz), alors on bypass
if ((device.name == 'Shelly_1_88_switch' and garage_light.state == 'On') or (device.name == 'Shelly_1_89_switch' and buanderie_light.state == 'On')) then --= vient d'être allumé via switch
domoticz.log('switch turned on')
domoticz.variables('bypass_lumi_garage').set('On')
bypass_lumi_garage = 'On'
gateway_light.setRGB(0,0,255)
--si switch 88/89 et shelly 88/89 "allumé", alors on désactive le bypass
elseif ((device.name == 'Shelly_1_88_switch' and garage_light.state == 'Off') or (device.name == 'Shelly_1_89_switch' and buanderie_light.state == 'Off')) then --= vient d'être éteint via switch
domoticz.log('switch turned off')
domoticz.variables('bypass_lumi_garage').set('Off')
bypass_lumi_garage = 'Off'
gateway_light.switchOff().checkFirst().silent()
etat_global = 'Off' --pour pas que ça rallume via inter
--si allumé via la voix, on active le bypass
elseif (device.name == 'Shelly_1_88' or device.name == 'Shelly_1_89') then
domoticz.log('light turned on')
domoticz.variables('bypass_lumi_garage').set('On')
bypass_lumi_garage = 'On'
gateway_light.setRGB(0,0,255)
end
--si éteint via la voix, on désactive le bypass
elseif (device.inActive and (device.name == 'Shelly_1_88' or device.name == 'Shelly_1_89')) then
domoticz.log('Shelly inActive')
domoticz.variables('bypass_lumi_garage').set('Off')
bypass_lumi_garage = 'Off'
gateway_light.switchOff().checkFirst().silent()
etat_global = 'Off' --pour pas que ça rallume via inter
end
domoticz.log('variable lumi garage :'..domoticz.variables('bypass_lumi_garage').value)
domoticz.log('local lumi garage :'..bypass_lumi_garage)
--Si ça a été déclenché manuellement, on ne fait rien
if (device.active and bypass_lumi_garage == 'On') then
--do nothing
domoticz.log('Bypass activé')
--si c'est le jour, on se base sur la luminosité de la pièce
elseif (device.active and domoticz.time.isDayTime) then
--buanderie
if (gateway_lux < 1000) then
domoticz.log('Buanderie sombre : '..gateway_lux)
buanderie_light.switchOff().checkFirst().afterMin(duree).silent()
buanderie_light.switchOn().checkFirst().forMin(duree).silent()
end
--atelier + garage
if ((xia3_lux < 10)) then
domoticz.log('Atelier sombre : '..xia3_lux)
atelier_light.switchOff().checkFirst().afterMin(duree).silent()
atelier_light.switchOn().checkFirst().forMin(duree).silent()
garage_light.switchOff().checkFirst().afterMin(duree).silent()
garage_light.switchOn().checkFirst().forMin(duree).silent()
end
--si c'est la nuit, ça dépend du type de capteur.
elseif (device.active and domoticz.time.isNightTime) then
--si c'est un capteur de porte ou si déjà allumé on rallume pour x minutes
if ((string.find(device.name,'Sensor') ~= nil) or (etat_global == 'On')) then
buanderie_light.switchOff().checkFirst().afterMin(duree).silent()
buanderie_light.switchOn().checkFirst().forMin(duree).silent()
atelier_light.switchOff().checkFirst().afterMin(duree).silent()
atelier_light.switchOn().checkFirst().forMin(duree).silent()
garage_light.switchOff().checkFirst().afterMin(duree).silent()
garage_light.switchOn().checkFirst().forMin(duree).silent()
end
end
-- if (device.active and domoticz.time.isNightTime) then
-- gateway_light.switchOff().checkFirst().afterMin(duree)
-- gateway_light.switchOn().checkFirst().forMin(duree)
-- --atelier_light.switchOff().checkFirst().afterMin(duree)
-- --atelier_light.switchOn().checkFirst().forMin(duree)
-- end
-- if (device.active and domoticz.time.hour <= 22 and domoticz.time.hour >= 6) then
-- end
end
}