Pb certainement idiot voir c..
Publié : 01 juin 2021, 16:54
Bonjour,
Je ne comprends ce qui se passe: j'analyse la liste des Timers d'un device.
Tout est OK la boucle dans les timers et son résultat dz.log('Timer actif ? ' ..TimerActif)
Mais pas le test ! j'ai tout essayé (enfin il me semble) mais ça ne marche pas.
Une idée ?
et le résultat
Je ne comprends ce qui se passe: j'analyse la liste des Timers d'un device.
Tout est OK la boucle dans les timers et son résultat dz.log('Timer actif ? ' ..TimerActif)
Mais pas le test ! j'ai tout essayé (enfin il me semble) mais ça ne marche pas.
Une idée ?
Code : Tout sélectionner
local scriptName = "Test"
return {
on = { devices = { 'Test Uniquement' },
httpResponses = { 'trigger' }},
data = { lastLevel = { initial = 0 }},
logging = {
level = domoticz.LOG_DEBUG,
marker = scriptName.. ' ==>' },
execute = function(dz, item)
local devSel = dz.devices('Arrosage')
local varEtat = dz.variables('Etat Arrosage')
----Ajout du 1er juin 2021 --------------------------------------
-- Remonte la liste des Timers du Device considéré et Notifie si nécessaire
if (item.isDevice) then
-- necessite ajout IP dans Configuration/Parametres/Réseaux locaux (pas d'authentification)
dz.openURL({
url = 'http://192.168.0.40:8084/json.htm?idx=' .. devSel.idx ..'&type=timers',
callback = 'trigger'
})
end
if (item.isHTTPResponse and item.ok) then
dz.log(item.data)
-- conversion du retour JSON en tableau LUA
local json = dz.utils.fromJSON(item.data)
-- On vérifie l'état des Timers
local TimerActif = false
for key,value in pairs(json.result) do
dz.log('Ligne= ' .. key .. ' valeur ' .. json.result[key].Active)
TimerActif= TimerActif or (json.result[key].Active)
end
dz.log('Timer actif ? ' ..TimerActif)
if TimerActif then
dz.log('Au moins 1 timer est actif')
else
dz.log("Aucun timer n'est actif")
end
else
dz.log('ERREUR json')
end
----Fin ajout --------------------------------------
end
}
Code : Tout sélectionner
2021-06-01 16:36:07.477 Status: EventSystem: Script event triggered: /usr/local/domoticz/dzVents/runtime/dzVents.lua
2021-06-01 16:36:07.581 Status: dzVents: Info: Test ==>: ------ Start internal script: Script #3: HTTPResponse: "trigger"
2021-06-01 16:36:07.602 Status: dzVents: Debug: Test ==>: Processing device-adapter for Arrosage: Switch device adapter
2021-06-01 16:36:07.603 Status: dzVents: Info: Test ==>: {
2021-06-01 16:36:07.603 "result" :
2021-06-01 16:36:07.603 [
2021-06-01 16:36:07.603 {
2021-06-01 16:36:07.603 "Active" : "false",
2021-06-01 16:36:07.603 "Cmd" : 0,
2021-06-01 16:36:07.603 "Color" : "",
2021-06-01 16:36:07.603 "Date" : "",
2021-06-01 16:36:07.603 "Days" : 85,
2021-06-01 16:36:07.603 "Level" : 20,
2021-06-01 16:36:07.603 "MDay" : 0,
2021-06-01 16:36:07.603 "Month" : 0,
2021-06-01 16:36:07.603 "Occurence" : 0,
2021-06-01 16:36:07.603 "Randomness" : "false",
2021-06-01 16:36:07.603 "Time" : "20:15",
2021-06-01 16:36:07.603 "Type" : 2,
2021-06-01 16:36:07.603 "idx" : "37"
2021-06-01 16:36:07.603 },
2021-06-01 16:36:07.603 {
2021-06-01 16:36:07.603 "Active" : "false",
2021-06-01 16:36:07.603 "Cmd" : 0,
2021-06-01 16:36:07.603 "Color" : "",
2021-06-01 16:36:07.603 "Date" : "",
2021-06-01 16:36:07.603 "Days" : 512,
2021-06-01 16:36:07.603 "Level" : 60,
2021-06-01 16:36:07.603 "MDay" : 0,
2021-06-01 16:36:07.603 "Month" : 0,
2021-06-01 16:36:07.603 "Occurence" : 0,
2021-06-01 16:36:07.603 "Randomness" : "false",
2021-06-01 16:36:07.603 "Time" : "22:00",
2021-06-01 16:36:07.603 "Type" : 2,
2021-06-01 16:36:07.603 "idx" : "38"
2021-06-01 16:36:07.603 },
2021-06-01 16:36:07.603 {
2021-06-01 16:36:07.603 "Active" : "false",
2021-06-01 16:36:07.603 "Cmd" : 0,
2021-06-01 16:36:07.603 "Color" : "",
2021-06-01 16:36:07.603 "Date" : "",
2021-06-01 16:36:07.603 "Days" : 128,
2021-06-01 16:36:07.603 "Level" : 10,
2021-06-01 16:36:07.603 "MDay" : 0,
2021-06-01 16:36:07.603 "Month" : 0,
2021-06-01 16:36:07.603 "Occurence" : 0,
2021-06-01 16:36:07.603 "Randomness" : "false",
2021-06-01 16:36:07.603 "Time" : "00:00",
2021-06-01 16:36:07.603 "Type" : 0,
2021-06-01 16:36:07.603 "idx" : "39"
2021-06-01 16:36:07.603 }
2021-06-01 16:36:07.603 ],
2021-06-01 16:36:07.603 "status" : "OK",
2021-06-01 16:36:07.603 "title" : "Timers"
2021-06-01 16:36:07.603 }
2021-06-01 16:36:07.603
2021-06-01 16:36:07.604 Status: dzVents: Info: Test ==>: Ligne= 1 valeur false
2021-06-01 16:36:07.604 Status: dzVents: Info: Test ==>: Ligne= 2 valeur false
2021-06-01 16:36:07.604 Status: dzVents: Info: Test ==>: Ligne= 3 valeur false
2021-06-01 16:36:07.604 Status: dzVents: Info: Test ==>: Timer actif ? false
2021-06-01 16:36:07.604 Status: dzVents: Info: Test ==>: Au moins 1 timer est actif
2021-06-01 16:36:07.604 Status: dzVents: Info: Test ==>: ------ Finished Script #3