Page 2 sur 3
Re: Web Relay Con V2.0 HW-584
Publié : 11 nov. 2022, 22:56
par Keros
Toutes les lignes de logs ne correspondent pas à ton script.
Une qui nous intéresse est :
billyken a écrit : 11 nov. 2022, 22:10
2022-11-11 21:48:00.525 Error: dzVents: Error: (3.1.8) WebRelay 1.0: ...ents\generated_scripts/Test Entree Carte RJ45 Garage.lua:34: attempt to concatenate a nil value (global 'ipWeb')
Elle indique que la variable
ipWeb est vide.
Elle est utilisée à la ligne local url = "http://"..ipWeb..":"..port.."/98"
Or la définition est local ipWebRelay = "192.168.1.4"
Neutrino a fait une petite erreur que tu peux corriger en faisant du débogage

Re: Web Relay Con V2.0 HW-584
Publié : 11 nov. 2022, 23:28
par Neutrino
J'avais dit que c'était pas testé
Tu n'es pas obligé de créer autant de matériels Dummy. Un seul suffit à créer l'ensemble des dispositifs.
Re: Web Relay Con V2.0 HW-584
Publié : 12 nov. 2022, 08:21
par billyken
j'ai modifier la ligne de code en mettant
ipWebRelay a la place de ipWeb
Code : Tout sélectionner
if item.isTimer then
local url = "http://"..ipWebRelay..":"..port.."/98"
domoticz.log('Requesting data from relay', domoticz.LOG_DEBUG)
domoticz.openURL({url = url, method = 'GET', callback = scriptName}).afterSec(7)
voici le nouveau log
j'ai modifier l'entrée 8 et il recupere bien la bonne info mais il reste un probleme on dirait
Code : Tout sélectionner
2022-11-12 08:14:00.363 Status: dzVents: Info: WebRelay 1.0: ------ Start internal script: Test Entree Carte RJ45 Garage:, trigger: "every 1 minutes"
2022-11-12 08:14:00.363 Status: dzVents: Debug: WebRelay 1.0: Requesting data from relay
2022-11-12 08:14:00.363 Status: dzVents: Debug: WebRelay 1.0: OpenURL: url = http://192.168.1.4:8080/98
2022-11-12 08:14:00.363 Status: dzVents: Debug: WebRelay 1.0: OpenURL: method = GET
2022-11-12 08:14:00.363 Status: dzVents: Debug: WebRelay 1.0: OpenURL: post data = nil
2022-11-12 08:14:00.363 Status: dzVents: Debug: WebRelay 1.0: OpenURL: headers = nil
2022-11-12 08:14:00.363 Status: dzVents: Debug: WebRelay 1.0: OpenURL: callback = WebRelay
2022-11-12 08:14:00.363 Status: dzVents: Info: WebRelay 1.0: ------ Finished Test Entree Carte RJ45 Garage
2022-11-12 08:16:07.607 Status: dzVents: Info: Handling httpResponse-events for: "WebRelay"
2022-11-12 08:16:07.607 Status: dzVents: Info: WebRelay 1.0: ------ Start internal script: Test Entree Carte RJ45 Garage: HTTPResponse: "WebRelay"
2022-11-12 08:16:07.607 Status: dzVents: Info: WebRelay 1.0: ------ Finished Test Entree Carte RJ45 Garage
2022-11-12 08:16:07.560 Error: Error opening url: http://192.168.1.4:8080/98
2022-11-12 08:16:07.607 Error: dzVents: Error: (3.1.8) WebRelay 1.0: HTTP/1.1 response: 18 ==>> Transferred a partial file
2022-11-12 08:16:07.607 Error: dzVents: Error: (3.1.8) WebRelay 1.0: Last http response was not what expected. Trigger: WebRelay
2022-11-12 08:16:07.607 Error: dzVents: Error: (3.1.8) WebRelay 1.0: 1000000011111110
Tu n'es pas obligé de créer autant de matériels Dummy. Un seul suffit à créer l'ensemble des dispositifs.
oui effectivement j'avais pas percuter comme ca je surcharge pour rien du coup je devrais crée un seul materiel et apres crée les 8 capteur virtuel en partant de celui ci
Re: Web Relay Con V2.0 HW-584
Publié : 12 nov. 2022, 10:41
par Neutrino
La carte doit renvoyer une réponse pas très standard.
Enlève la partie suivante pour voire si c'est mieux.
Code : Tout sélectionner
if (not response.ok) or (response.trigger ~= scriptName) then
domoticz.log('Last http response was not what expected. Trigger: '..response.trigger, domoticz.LOG_ERROR)
domoticz.log(response.data, domoticz.LOG_ERROR)
return
end
Re: Web Relay Con V2.0 HW-584
Publié : 12 nov. 2022, 11:08
par billyken
voila le retour que j'ai en suprimant
Code : Tout sélectionner
2022-11-12 11:02:00.524 Status: dzVents: Info: WebRelay 1.0: ------ Start internal script: Test Entree Carte RJ45 Garage:, trigger: "every 1 minutes"
2022-11-12 11:02:00.524 Status: dzVents: Debug: WebRelay 1.0: Requesting data from relay
2022-11-12 11:02:00.524 Status: dzVents: Debug: WebRelay 1.0: OpenURL: url = http://192.168.1.4:8080/98
2022-11-12 11:02:00.524 Status: dzVents: Debug: WebRelay 1.0: OpenURL: method = GET
2022-11-12 11:02:00.524 Status: dzVents: Debug: WebRelay 1.0: OpenURL: post data = nil
2022-11-12 11:02:00.524 Status: dzVents: Debug: WebRelay 1.0: OpenURL: headers = nil
2022-11-12 11:02:00.524 Status: dzVents: Debug: WebRelay 1.0: OpenURL: callback = WebRelay
2022-11-12 11:02:00.524 Status: dzVents: Info: WebRelay 1.0: ------ Finished Test Entree Carte RJ45 Garage
2022-11-12 11:02:07.740 Status: dzVents: Info: Handling httpResponse-events for: "WebRelay"
2022-11-12 11:02:07.740 Status: dzVents: Info: WebRelay 1.0: ------ Start internal script: Test Entree Carte RJ45 Garage: HTTPResponse: "WebRelay"
2022-11-12 11:02:07.741 Status: dzVents: Info: WebRelay 1.0: ------ Finished Test Entree Carte RJ45 Garage
2022-11-12 11:02:07.688 Error: Error opening url: http://192.168.1.4:8080/98
2022-11-12 11:02:07.740 Error: dzVents: Error: (3.1.8) WebRelay 1.0: HTTP/1.1 response: 18 ==>> Transferred a partial file
2022-11-12 11:02:07.741 Error: dzVents: Error: (3.1.8) WebRelay 1.0: An error occurred when calling event handler Test Entree Carte RJ45 Garage
2022-11-12 11:02:07.741 Error: dzVents: Error: (3.1.8) WebRelay 1.0: ...ents\generated_scripts/Test Entree Carte RJ45 Garage.lua:51: attempt to concatenate a nil value (global 'In')
tout a l'heure il arrivait a lire la suite de 0 et 1 et lorsque que je changer l'état de lentrée 8 par exemple on passer le srcipt voyait bien 1000000011111110 ou 1000000011111111 mais plus en supprimant la partie que tu ma demander
Re: Web Relay Con V2.0 HW-584
Publié : 12 nov. 2022, 11:24
par Neutrino
ça devrait être mieux :
Code : Tout sélectionner
local scriptName = 'WebRelay'
local scriptVersion = '1.0'
local ipWebRelay = "192.168.1.4"
local port = "8080"
-- Dummy à créer :
local In = {"Entrée 1","Entrée 2","Entrée 3","Entrée 4","Entrée 5","Entrée 6","Entrée 7","Entrée 8"}
return {
active = true,
logging = {
level = domoticz.LOG_DEBUG, -- Uncomment to override the dzVents global logging setting
marker = scriptName..' '..scriptVersion
},
on = {
timer = {'every 1 minutes'},
httpResponses = {
scriptName,
},
},
execute = function(domoticz, item)
if item.isTimer then
local url = "http://"..ipWebRelay..":"..port.."/98"
domoticz.log('Requesting data from relay', domoticz.LOG_DEBUG)
domoticz.openURL({url = url, method = 'GET', callback = scriptName}).afterSec(7)
end
if not item.isHTTPResponse then return end
local response = item
if response.trigger == scriptName then
domoticz.log(response.data, domoticz.LOG_DEBUG)
for i = 1, 8 do
if string.sub(response.data,i+8,i+8)=="0" then
domoticz.devices(In[i]).switchOff()
else
domoticz.devices(In[i]).switchOn()
end
end
end
end
}
Re: Web Relay Con V2.0 HW-584
Publié : 12 nov. 2022, 11:42
par billyken
yes ca marche !!!!!!
voila le log il reste une erreur mais j'ai tester toutes les entrées et c'est OK
Code : Tout sélectionner
2022-11-12 11:37:07.246 Status: dzVents: Info: Handling httpResponse-events for: "WebRelay"
2022-11-12 11:37:07.246 Status: dzVents: Info: WebRelay 1.0: ------ Start internal script: Test Entree Carte RJ45 Garage: HTTPResponse: "WebRelay"
2022-11-12 11:37:07.246 Status: dzVents: Debug: WebRelay 1.0: 1000000011111110
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Processing device-adapter for Entrée 1: Switch device adapter
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Constructed timed-command: On
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Processing device-adapter for Entrée 2: Switch device adapter
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Constructed timed-command: On
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Processing device-adapter for Entrée 3: Switch device adapter
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Constructed timed-command: On
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Processing device-adapter for Entrée 4: Switch device adapter
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Constructed timed-command: On
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Processing device-adapter for Entrée 5: Switch device adapter
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Constructed timed-command: On
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Processing device-adapter for Entrée 6: Switch device adapter
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Constructed timed-command: On
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Processing device-adapter for Entrée 7: Switch device adapter
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Constructed timed-command: On
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Processing device-adapter for Entrée 8: Switch device adapter
2022-11-12 11:37:07.261 Status: dzVents: Debug: WebRelay 1.0: Constructed timed-command: Off
2022-11-12 11:37:07.261 Status: dzVents: Info: WebRelay 1.0: ------ Finished Test Entree Carte RJ45 Garage
2022-11-12 11:37:07.261 Status: EventSystem: Script event triggered: C:\Program Files (x86)\Domoticz\dzVents\runtime\dzVents.lua
2022-11-12 11:37:07.199 Error: Error opening url: http://192.168.1.4:8080/98
2022-11-12 11:37:07.246 Error: dzVents: Error: (3.1.8) WebRelay 1.0: HTTP/1.1 response: 18 ==>> Transferred a partial file
Re: Web Relay Con V2.0 HW-584
Publié : 12 nov. 2022, 12:38
par Neutrino
L'erreur vient des données envoyées par la carte qui sont interprétées comme incomplètes.
Le principale, c'est que ça marche

Re: Web Relay Con V2.0 HW-584
Publié : 12 nov. 2022, 12:49
par billyken
oui merci beaucoup
dernier question est ce l'on peut lancer le script tous les 30 secondes au lieu d'une minutes ?
Re: Web Relay Con V2.0 HW-584
Publié : 12 nov. 2022, 13:35
par Neutrino
Peut-être en ajoutant
domoticz.openURL({url = url, method = 'GET', callback = scriptName}).afterSec(
37)
après la ligne
domoticz.openURL({url = url, method = 'GET', callback = scriptName}).afterSec(7)
Je ne sais pas si c'est possible, à tester
