Re: Envoyer 2 fois les commandes On/Off (send twice)
Publié : 23 août 2018, 11:29
Bonjour
J'ai un problème avec le script de Vil1driver modifié par papoo pour les volets roulants
J'explique :
- pour tous les interrupteurs ça fonctionne parfaitement comme on peut le voir sur le log
- pour les volets roulants ( somfy avec RFXCom)
si je demande la fermeture du volet , le script envoie bien l'ordre de fermer mais la seconde commande ( qui logiquement devrait être la même) est stop
Une bonne âme pourrait il m'indiquer la voie à suivre pour résoudre ce problème
Le script utilisé
J'ai un problème avec le script de Vil1driver modifié par papoo pour les volets roulants
J'explique :
- pour tous les interrupteurs ça fonctionne parfaitement comme on peut le voir sur le log
- pour les volets roulants ( somfy avec RFXCom)
si je demande la fermeture du volet , le script envoie bien l'ordre de fermer mais la seconde commande ( qui logiquement devrait être la même) est stop
Une bonne âme pourrait il m'indiquer la voie à suivre pour résoudre ce problème
Code : Tout sélectionner
2018-08-23 10:48:30.032 (RFXCOM) Lighting 6 (Applique_Salon)
2018-08-23 10:48:30.018 Status: User: Admin initiated a switch command (1/Applique_Salon/On)
2018-08-23 10:48:30.086 Status: LUA: TWICE : Applique_Salon -> On
2018-08-23 10:48:30.088 Status: EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_twice.lua
2018-08-23 10:48:31.106 (RFXCOM) Lighting 6 (Applique_Salon)
2018-08-23 10:48:31.131 Status: LUA: TWICE : Applique_Salon -> On
2018-08-23 10:48:31.132 Status: EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_twice.lua
2018-08-23 10:48:32.160 (RFXCOM) Lighting 6 (Applique_Salon)
2018-08-23 10:48:42.884 (RFXCOM) Temp (Temp Chauffage)
2018-08-23 10:48:44.052 (RFXCOM) Temp (Temp Eau Chaude)
2018-08-23 10:48:47.841 (RFXCOM) Lighting 6 (Applique_Salon)
2018-08-23 10:48:47.822 Status: User: Admin initiated a switch command (1/Applique_Salon/Off)
2018-08-23 10:48:47.889 Status: LUA: TWICE : Applique_Salon -> Off
2018-08-23 10:48:47.890 Status: EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_twice.lua
2018-08-23 10:48:48.935 (RFXCOM) Lighting 6 (Applique_Salon)
2018-08-23 10:48:48.989 Status: LUA: TWICE : Applique_Salon -> Off
2018-08-23 10:48:48.990 Status: EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_twice.lua
2018-08-23 10:48:50.031 (RFXCOM) Lighting 6 (Applique_Salon)
2018-08-23 10:48:59.243 (RFXCOM) RFY (Volet_roulant_Chambre_1)
2018-08-23 10:48:59.232 Status: User: Admin initiated a switch command (6/Volet_roulant_Chambre_1/Off)
2018-08-23 10:48:59.297 Status: LUA: TWICE : Volet_roulant_Chambre_1 -> Open
2018-08-23 10:48:59.299 Status: EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_twice.lua
2018-08-23 10:49:00.345 (RFXCOM) RFY (Volet_roulant_Chambre_1)
2018-08-23 10:49:00.399 Status: LUA: TWICE : Volet_roulant_Chambre_1 -> Stopped
2018-08-23 10:49:00.400 Status: EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_device_twice.lua
2018-08-23 10:49:01.437 (RFXCOM) RFY (Volet_roulant_Chambre_1)
2018-08-23 10:49:14.201 (RFXCOM) Temp (Temp Exterieur Lampe)Le script utilisé
Code : Tout sélectionner
script_device_twice.lua
--
-- ce script permet de doubler les commandes envoyees aux switchs
-- de sorte a fiabiliser leur fonctionnement
-- domoticz agit alors comme un repeteur
--------------------------------
------ Tableau a editer ------
--------------------------------
local ip = '192.168.xxx.xxx:xxxx' -- user:pass@ip:port de domoticz
local switch={}
switch['0']='Cafetiere'
switch['1']='Entree'
switch['2']='Applique_Salon'
switch['3']='Bandeau_Cuisine'
switch['4']='Eclairage_Jardin'
switch['5']='Module_Kyala'
switch['6']='Globe'
switch['7']='Lampadaire_Boule'
switch['8']='PC_Ventilateur'
switch['9']='Prise_commandee'
switch['10']='Volet_roulant_Salon'
switch['11']='Volet_roulant_Cuisine'
switch['12']='Volet_roulant_Chambre_1'
switch['13']='Volet_roulant_Chambre_2'
-- etc..
--------------------------------
-- Fin du tableau a editer --
--------------------------------
time = os.date("*t")
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
function urlencode(str)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w ])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
return str
end
commandArray = {}
for key, valeur in pairs(switch) do
if(uservariables['TWICE_'.. valeur ..'_'.. otherdevices[valeur]] == nil) then
commandArray[tonumber(key)]={['OpenURL']=ip..'/json.htm?type=command¶m=saveuservariable&vname=TWICE_'..urlencode(valeur)..'_'.. otherdevices[valeur] ..'&vtype=2&vvalue='..urlencode(otherdevices_lastupdate[valeur])}
print('TWICE : creation variable manquante TWICE_'..valeur..'_'.. otherdevices[valeur])
elseif(uservariables['TWICE_'.. valeur..'_'.. otherdevices[valeur]] == nil) then
commandArray[tonumber(key)]={['OpenURL']=ip..'/json.htm?type=command¶m=saveuservariable&vname=TWICE_'..urlencode(valeur)..'_'..otherdevices[valeur]..'&vtype=2&vvalue='..urlencode(otherdevices_lastupdate[valeur])}
print('TWICE : creation variable manquante TWICE_'..valeur..'_'.. otherdevices[valeur])
elseif (devicechanged[valeur] and timedifference(uservariables['TWICE_'..valeur..'_'..otherdevices[valeur]]) > 5) then
commandArray[valeur] = otherdevices[valeur]..' AFTER 1'
commandArray['Variable:TWICE_'..valeur..'_'..otherdevices[valeur]]=otherdevices_lastupdate[valeur]
print('TWICE : '..valeur.. ' -> ' ..otherdevices[valeur])
end
end
return commandArray