Code : Tout sélectionner
local delai = 15 -- pour initialiser le timer, changer la valeur si trop rapide ou lent
return {
on = {
timer = {
'every ' .. delai .. ' minutes' -- pour programmer la récurrence de la requête dans le temps
},
httpResponses = {
'trigger' -- doit correspondre au callback donné dans openURL command
}
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'http://192.168.1.xx:3002', -- appel de myDomoAtHome
method = 'GET',
callback = 'trigger', -- regarder httpResponses plus loin.
})
end
if (item.isHTTPResponse) then
if (item.statusCode == 200) then -- le service est opérationnel
local someValue = "MyDomoAtHome fonctionne correctement " -- prépare le texte
domoticz.log(someValue, domoticz.LOG_INFO) -- log l'info
domoticz.devices('myDomoAtHome').updateText(someValue) -- écrire le text dans le dispositif Domoticz, le nom doit correspondre au dispositif virtuel
else
local someValue = "MyDomoAtHome ne fonctionne pas, retour du status:" ..item.statusCode .. ", redémarrage lancé" -- prépare le texte
os.execute("echo MyPassword | sudo -S synoservice --start pkgctl-MyDomoAtHome") -- execute la relance du service dans SYNOLOGY
-- changer le pswd par le votre, malheureusement en clair
domoticz.log(someValue, domoticz.LOG_INFO) -- log l'info
-- update some device in Domoticz
domoticz.devices('myDomoAtHome').updateText(someValue) -- écrire le text dans le dispositif Domoticz, le nom doit correspondre au dispositif virtue
domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR) -- log erreur
domoticz.log(item, domoticz.LOG_ERROR) -- uncomment seulement si nécessaire
-- on va laisser un délai pour permettre au service de redémarrer et immédiatement on va contrôler que ça fonctionne
domoticz.openURL({
url = 'http://192.168.1.xx:3002', -- appel myDomoAtHome
method = 'GET',
callback = 'trigger', -- see httpResponses above.
}).afterSec(60) -- appel de la requête après 60 secondes
end
end
end
}
me suis-je trompé ?
2019-07-20 07:27:12.580 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:12.617 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:12.735 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:12.742 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:12.779 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:12.897 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:17.563 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:17.600 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:17.718 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:18.925 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:18.961 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:19.084 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:23.415 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:23.451 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:23.568 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:23.576 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:23.614 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:23.732 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:23.739 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:23.825 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:23.935 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:24.290 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:24.328 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:24.446 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:25.940 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:25.977 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:26.061 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:26.095 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:26.133 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:26.252 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:28.852 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:28.888 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:29.008 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:30.416 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:30.452 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:30.571 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:32.056 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:32.093 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:32.177 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:32.211 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:32.249 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:32.369 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:38.494 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:38.549 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:38.721 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:41.133 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:41.169 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:41.287 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:43.489 Error: Error opening url: http://192.168.1.xx:3002
2019-07-20 07:27:43.542 Error: dzVents: Error: (2.4.24) HTTP/1.1 response: 7 ==>> Couldn't connect to server
2019-07-20 07:27:43.661 Error: dzVents: Error: (2.4.24) There was a problem handling the request
2019-07-20 07:27:46.927 Error: Error opening url: http://192.168.1.xx:3002