[LUA] Rafraîchissement nocturne
Re: LUA : Rafraîchissement nocturne
ok pour tester ce nouveau scritp:
je l'ai modifier en mettant le nom de mes capteurs et j'ai placé le fichier dans le dossier des scripts :
j'ai encore des erreurs au lancement:
2020-01-04 08:22:00.322 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:00.322 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:00.923 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:00.923 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:03.032 (GATEWAY rfxcom) Temp + Humidity (TempExterieur)
2020-01-04 08:22:03.150 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:03.150 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:04.125 Notification sent (browser) => Success
2020-01-04 08:22:04.132 (Lampe Bureau) Light/Switch (Lampe Bureau)
2020-01-04 08:22:04.125 Status: Notification: Lampe Bureau Eteinds
2020-01-04 08:22:04.253 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:04.253 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:07.730 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:07.730 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:22.064 (GATEWAY rfxcom) Temp + Humidity (temptony)
2020-01-04 08:22:22.168 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:22.168 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:25.723 MQTT: Topic: domoticz/in, Message: {"idx":57,"nvalue":0,"svalue":"1;2802.4","Battery":100,"RSSI":9}
2020-01-04 08:22:25.832 MQTT: Topic: domoticz/in, Message: {"idx":60,"nvalue":0,"svalue":"241","Battery":100,"RSSI":9}
2020-01-04 08:22:25.946 MQTT: Topic: domoticz/in, Message: {"idx":61,"nvalue":0,"svalue":"0.036","Battery":100,"RSSI":9}
2020-01-04 08:22:25.849 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:25.849 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:25.970 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:25.970 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:26.046 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:26.046 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:37.732 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:37.732 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:57.766 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:57.766 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:23:00.065 (GATEWAY rfxcom) Temp + Humidity (TempExterieur)
????
Merci de ton aide
je l'ai modifier en mettant le nom de mes capteurs et j'ai placé le fichier dans le dossier des scripts :
j'ai encore des erreurs au lancement:
2020-01-04 08:22:00.322 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:00.322 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:00.923 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:00.923 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:03.032 (GATEWAY rfxcom) Temp + Humidity (TempExterieur)
2020-01-04 08:22:03.150 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:03.150 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:04.125 Notification sent (browser) => Success
2020-01-04 08:22:04.132 (Lampe Bureau) Light/Switch (Lampe Bureau)
2020-01-04 08:22:04.125 Status: Notification: Lampe Bureau Eteinds
2020-01-04 08:22:04.253 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:04.253 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:07.730 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:07.730 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:22.064 (GATEWAY rfxcom) Temp + Humidity (temptony)
2020-01-04 08:22:22.168 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:22.168 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:25.723 MQTT: Topic: domoticz/in, Message: {"idx":57,"nvalue":0,"svalue":"1;2802.4","Battery":100,"RSSI":9}
2020-01-04 08:22:25.832 MQTT: Topic: domoticz/in, Message: {"idx":60,"nvalue":0,"svalue":"241","Battery":100,"RSSI":9}
2020-01-04 08:22:25.946 MQTT: Topic: domoticz/in, Message: {"idx":61,"nvalue":0,"svalue":"0.036","Battery":100,"RSSI":9}
2020-01-04 08:22:25.849 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:25.849 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:25.970 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:25.970 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:26.046 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:26.046 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:37.732 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:37.732 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:22:57.766 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:57.766 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
2020-01-04 08:23:00.065 (GATEWAY rfxcom) Temp + Humidity (TempExterieur)
????
Merci de ton aide
Mon system domoticz en béta - RFXCOM XL 433- PHILIPS HUE- 
-
denis_brasseur
- Messages : 898
- Inscription : 24 déc. 2018, 17:05
- Localisation : (26)
Re: LUA : Rafraîchissement nocturne
Tu peux poster ton script tel que modifié ?Stf4 a écrit : 04 janv. 2020, 08:26 ok pour tester ce nouveau scritp:
je l'ai modifier en mettant le nom de mes capteurs et j'ai placé le fichier dans le dossier des scripts :
j'ai encore des erreurs au lancement:
2020-01-04 08:22:00.322 Error: dzVents: Error: (2.5.3) error loading module 'rafraichissementNocturne' from file '/home/pi/domoticz/scripts/dzVents/scripts/rafraichissementNocturne.lua':
2020-01-04 08:22:00.322 ...icz/scripts/dzVents/scripts/rafraichissementNocturne.lua:110: <eof> expected near 'domoticz'
Pi3 + DD PiDrive - RFXtrx433 - AEON Labs ZW090
Re: LUA : Rafraîchissement nocturne
voila mon script:
--[[
rafraichissementNocturne.lua
author/auteur = papoo
update/mise à jour = 02/01/2020
creation = 24/06/2017
github https://github.com/domoticz_scripts/dzV ... cturne.lua
blog https://pon.fr/
forum http://easydomoticz.com/forum/viewtopic ... 343#p38107
ce script utilise la fonction de notification universelle https://pon.fr/dzvents-fonction-de-noti ... iverselle/
--]]
local scriptName = 'Rafraichissement nocturne'
local scriptVersion = '2.0'
local seuil_notification = 25 -- seuil température intérieure au delà duquel les notifications seront envoyées
local deltaT = 2 -- Delta T entre T° interieure et T° extérieure avant notification
local frequency_notifications = 3600
local quiet_hours = "23:00-07:15"
local subSystems = "TELEGRAM" --NSS_GOOGLE_CLOUD_MESSAGING, NSS_HTTP, NSS_KODI, NSS_LOGITECH_MEDIASERVER, NSS_NMA,NSS_PROWL, NSS_PUSHALOT, NSS_PUSHBULLET, NSS_PUSHOVER, NSS_PUSHSAFER, NSS_TELEGRAM
local temp_ext = 'TempExterieur' -- nom de la sonde extérieure
local les_temperatures = {
'tempsdb',
'tempmaison',
'temptony',
} -- Liste de vos sondes intérieures séparées par une virgule
local subject = "\xE2\x9A\xA0 /!\\ Ouverture des fenetres recommandee /!\\ \xE2\x9A\xA0"
return {
active = true,
on = { timer = {'every 1 minutes'}},
--on = { timer = {'every minute'}},
logging = { level = domoticz.LOG_DEBUG,
-- level = domoticz.LOG_INFO, -- Seulement un niveau peut être actif; commenter les autres
-- level = domoticz.LOG_ERROR, -- Only one level can be active; comment others
-- level = domoticz.LOG_MODULE_EXEC_INFO,
marker = scriptName..' v'..scriptVersion },
execute = function(dz)
local round = dz.utils.round
--local _ = require('lodash')
local function logWrite(str,level) -- Support function for shorthand debug log statements
dz.log(tostring(str),level or dz.LOG_DEBUG)
end
local function split(s, delimiter)
if s ~= nil then
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
else
result = {""};
end
return result;
end
local function notificationTable(str)
--NSS_GOOGLE_CLOUD_MESSAGING, NSS_HTTP, NSS_KODI, NSS_LOGITECH_MEDIASERVER, NSS_NMA,NSS_PROWL, NSS_PUSHALOT, NSS_PUSHBULLET, NSS_PUSHOVER, NSS_PUSHSAFER, NSS_TELEGRAM
if (str) then
str = string.gsub (str,"GCM", dz.NSS_GOOGLE_CLOUD_MESSAGING)
str = string.gsub (str,"GOOGLE_CLOUD_MESSAGING", dz.NSS_GOOGLE_CLOUD_MESSAGING)
str = string.gsub (str,"HTTP", dz.NSS_HTTP)
str = string.gsub (str,"LMS", dz.NSS_LOGITECH_MEDIASERVER)
str = string.gsub (str,"LOGITECH_MEDIASERVER", dz.NSS_LOGITECH_MEDIASERVER)
str = string.gsub (str,"NMA", dz.NSS_NMA)
str = string.gsub (str,"PROWL", dz.NSS_PROWL)
str = string.gsub (str,"PUSHALOT", dz.NSS_PUSHALOT)
str = string.gsub (str,"PUSHOVER", dz.NSS_PUSHOVER)
str = string.gsub (str,"PUSHSAFER", dz.NSS_PUSHSAFER)
str = string.gsub (str,"PUSHBULLET", dz.NSS_PUSHBULLET)
str = string.gsub (str,"TELEGRAM", dz.NSS_TELEGRAM)
end
return (split(str,','))
end
local tempExt = round(dz.devices(temp_ext).temperature,2)
logWrite("le device : "..tostring(dz.devices(temp_ext).name).." indique une température de "..tostring(tempExt).."°C")
local i = 0
local tempsInt = 0
for _, name in ipairs(les_temperatures) do
i = i + 1
local dev = dz.devices(name)
if dev.temperature then
logWrite("le device : "..tostring(dev.name).." indique une température de "..tostring(round(dev.temperature,2)).."°C")
tempsInt = tempsInt + dev.temperature
end
end
logWrite("nombre de sondes intérieures parcourues est de "..tostring(i))
tempsInt = round(tempsInt/i)
logWrite("la moyenne ambiante intérieure est de "..tostring(tempsInt).."°C")
if (tempsInt + deltaT) > tempExt and seuil_notification < tempExt then
logWrite("la moyenne ambiante intérieure moins le deltat T est de "..tostring(tempsInt - deltaT).."°C")
dz.helpers.managedNotify(dz, subject, "Ouverture des fenêtres recommandée, la température moyenne ambiante intérieure est supérieure de "..deltaT.."°C à la temperature extérieure" , notificationTable(subSystems), frequency_notifications , quiet_hours)
end
-- dz.devices(les_temperatures).forEach(
-- function(device)
-- logWrite("le device : "..tostring(device.name).." a une température de "..tostring(device.temperature))
-- end
-- )
-- local temp = dz.devices().filter(function(device)
-- return _.includes(les_temperatures, device.name)
-- end)
-- print_table(temp)
end -- execute function
}
domoticz beta/Ra
--[[
rafraichissementNocturne.lua
author/auteur = papoo
update/mise à jour = 02/01/2020
creation = 24/06/2017
github https://github.com/domoticz_scripts/dzV ... cturne.lua
blog https://pon.fr/
forum http://easydomoticz.com/forum/viewtopic ... 343#p38107
ce script utilise la fonction de notification universelle https://pon.fr/dzvents-fonction-de-noti ... iverselle/
--]]
local scriptName = 'Rafraichissement nocturne'
local scriptVersion = '2.0'
local seuil_notification = 25 -- seuil température intérieure au delà duquel les notifications seront envoyées
local deltaT = 2 -- Delta T entre T° interieure et T° extérieure avant notification
local frequency_notifications = 3600
local quiet_hours = "23:00-07:15"
local subSystems = "TELEGRAM" --NSS_GOOGLE_CLOUD_MESSAGING, NSS_HTTP, NSS_KODI, NSS_LOGITECH_MEDIASERVER, NSS_NMA,NSS_PROWL, NSS_PUSHALOT, NSS_PUSHBULLET, NSS_PUSHOVER, NSS_PUSHSAFER, NSS_TELEGRAM
local temp_ext = 'TempExterieur' -- nom de la sonde extérieure
local les_temperatures = {
'tempsdb',
'tempmaison',
'temptony',
} -- Liste de vos sondes intérieures séparées par une virgule
local subject = "\xE2\x9A\xA0 /!\\ Ouverture des fenetres recommandee /!\\ \xE2\x9A\xA0"
return {
active = true,
on = { timer = {'every 1 minutes'}},
--on = { timer = {'every minute'}},
logging = { level = domoticz.LOG_DEBUG,
-- level = domoticz.LOG_INFO, -- Seulement un niveau peut être actif; commenter les autres
-- level = domoticz.LOG_ERROR, -- Only one level can be active; comment others
-- level = domoticz.LOG_MODULE_EXEC_INFO,
marker = scriptName..' v'..scriptVersion },
execute = function(dz)
local round = dz.utils.round
--local _ = require('lodash')
local function logWrite(str,level) -- Support function for shorthand debug log statements
dz.log(tostring(str),level or dz.LOG_DEBUG)
end
local function split(s, delimiter)
if s ~= nil then
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
else
result = {""};
end
return result;
end
local function notificationTable(str)
--NSS_GOOGLE_CLOUD_MESSAGING, NSS_HTTP, NSS_KODI, NSS_LOGITECH_MEDIASERVER, NSS_NMA,NSS_PROWL, NSS_PUSHALOT, NSS_PUSHBULLET, NSS_PUSHOVER, NSS_PUSHSAFER, NSS_TELEGRAM
if (str) then
str = string.gsub (str,"GCM", dz.NSS_GOOGLE_CLOUD_MESSAGING)
str = string.gsub (str,"GOOGLE_CLOUD_MESSAGING", dz.NSS_GOOGLE_CLOUD_MESSAGING)
str = string.gsub (str,"HTTP", dz.NSS_HTTP)
str = string.gsub (str,"LMS", dz.NSS_LOGITECH_MEDIASERVER)
str = string.gsub (str,"LOGITECH_MEDIASERVER", dz.NSS_LOGITECH_MEDIASERVER)
str = string.gsub (str,"NMA", dz.NSS_NMA)
str = string.gsub (str,"PROWL", dz.NSS_PROWL)
str = string.gsub (str,"PUSHALOT", dz.NSS_PUSHALOT)
str = string.gsub (str,"PUSHOVER", dz.NSS_PUSHOVER)
str = string.gsub (str,"PUSHSAFER", dz.NSS_PUSHSAFER)
str = string.gsub (str,"PUSHBULLET", dz.NSS_PUSHBULLET)
str = string.gsub (str,"TELEGRAM", dz.NSS_TELEGRAM)
end
return (split(str,','))
end
local tempExt = round(dz.devices(temp_ext).temperature,2)
logWrite("le device : "..tostring(dz.devices(temp_ext).name).." indique une température de "..tostring(tempExt).."°C")
local i = 0
local tempsInt = 0
for _, name in ipairs(les_temperatures) do
i = i + 1
local dev = dz.devices(name)
if dev.temperature then
logWrite("le device : "..tostring(dev.name).." indique une température de "..tostring(round(dev.temperature,2)).."°C")
tempsInt = tempsInt + dev.temperature
end
end
logWrite("nombre de sondes intérieures parcourues est de "..tostring(i))
tempsInt = round(tempsInt/i)
logWrite("la moyenne ambiante intérieure est de "..tostring(tempsInt).."°C")
if (tempsInt + deltaT) > tempExt and seuil_notification < tempExt then
logWrite("la moyenne ambiante intérieure moins le deltat T est de "..tostring(tempsInt - deltaT).."°C")
dz.helpers.managedNotify(dz, subject, "Ouverture des fenêtres recommandée, la température moyenne ambiante intérieure est supérieure de "..deltaT.."°C à la temperature extérieure" , notificationTable(subSystems), frequency_notifications , quiet_hours)
end
-- dz.devices(les_temperatures).forEach(
-- function(device)
-- logWrite("le device : "..tostring(device.name).." a une température de "..tostring(device.temperature))
-- end
-- )
-- local temp = dz.devices().filter(function(device)
-- return _.includes(les_temperatures, device.name)
-- end)
-- print_table(temp)
end -- execute function
}
domoticz beta/Ra
Mon system domoticz en béta - RFXCOM XL 433- PHILIPS HUE- 
-
denis_brasseur
- Messages : 898
- Inscription : 24 déc. 2018, 17:05
- Localisation : (26)
Re: LUA : Rafraîchissement nocturne
Pour poster ton code, utilise la balise code, il s'agit du bouton </>
La virgule après 'temptony' est inutile, et même génante.
Et je retrouve ceci en fin du code (d'ou l'utilité de la balise code) :
Code : Tout sélectionner
local les_temperatures = {
'tempsdb',
'tempmaison',
'temptony',
} -- Liste de vos sondes intérieures séparées par une virguleEt je retrouve ceci en fin du code (d'ou l'utilité de la balise code) :
Sinon, pas d'erreur de syntaxe par rapport au code d'originedomoticz beta/Ra
Pi3 + DD PiDrive - RFXtrx433 - AEON Labs ZW090
Re: LUA : Rafraîchissement nocturne
Merci d'avoir pris le temps d'analyse le code, étant débutant en programmation j'aurai besoin que
vous m'éclairez sur vos propos :
Pour installer j'ai simplement copier la totalité du code puis je l'ai sauvegarder avec l'extension lua dans le dossier script de domoticz du raspberry.
Que dois je faire avec la balise code, il s'agit du bouton </> ???
vous m'éclairez sur vos propos :
Pour installer j'ai simplement copier la totalité du code puis je l'ai sauvegarder avec l'extension lua dans le dossier script de domoticz du raspberry.
Que dois je faire avec la balise code, il s'agit du bouton </> ???
Mon system domoticz en béta - RFXCOM XL 433- PHILIPS HUE- 
Re: LUA : Rafraîchissement nocturne
Oui pour le bouton
On reprend par le commencement
Tu utilises quel logiciel pour ton code?
Il faut que l’encodage du code soit en UTF8 sans bom
J’utilise pour ma part notepad++
On reprend par le commencement
Tu utilises quel logiciel pour ton code?
Il faut que l’encodage du code soit en UTF8 sans bom
J’utilise pour ma part notepad++
Re: LUA : Rafraîchissement nocturne
J'utilise comme logiciel :Visual Studio code
J'ai fait le teste en passant par notepad++ en UTF8 sans bom comme le suggère @papoo Puis je l'envoie vers mon raspberry avec winSCP voila l'erreur dans domoticz apres avoir uploadé le fichier et redémarrer domoticz
Je comprends pas pourquoi certain script fonctionne et pas celui la mystère...
J'ai fait le teste en passant par notepad++ en UTF8 sans bom comme le suggère @papoo Puis je l'envoie vers mon raspberry avec winSCP voila l'erreur dans domoticz apres avoir uploadé le fichier et redémarrer domoticz
Je comprends pas pourquoi certain script fonctionne et pas celui la mystère...
Mon system domoticz en béta - RFXCOM XL 433- PHILIPS HUE- 
-
denis_brasseur
- Messages : 898
- Inscription : 24 déc. 2018, 17:05
- Localisation : (26)
Re: LUA : Rafraîchissement nocturne
Supprime cette virgule, teste, et republie ton code entre les balises codedenis_brasseur a écrit : 04 janv. 2020, 13:41 Pour poster ton code, utilise la balise code, il s'agit du bouton </>
La virgule après 'temptony' est inutile, et même génante.Code : Tout sélectionner
local les_temperatures = { 'tempsdb', 'tempmaison', 'temptony', } -- Liste de vos sondes intérieures séparées par une virgule
Et je retrouve ceci en fin du code (d'ou l'utilité de la balise code) :Sinon, pas d'erreur de syntaxe par rapport au code d'originedomoticz beta/Ra
Pi3 + DD PiDrive - RFXtrx433 - AEON Labs ZW090
Re: LUA : Rafraîchissement nocturne
les scripts commençant par script_time ou script_device ne sont pas des scripts dzvents, ils ne doivent pas être placer dans
mais dans
Code : Tout sélectionner
/home/pi/domoticz/scripts/dzVents/scripts/Code : Tout sélectionner
/home/pi/domoticz/scripts/lua/Re: LUA : Rafraîchissement nocturne
le code du script avec tes sondes ci dessous
pas besoin de redemarrer domoticz lors des changement dans le code, c'est immediat
tu as bien placé le code de la fonction de notification universelle dans global_data.lua encodé en utf8 sans bom?
pas besoin de redemarrer domoticz lors des changement dans le code, c'est immediat
tu as bien placé le code de la fonction de notification universelle dans global_data.lua encodé en utf8 sans bom?
Code : Tout sélectionner
--[[
rafraichissementNocturne.lua
author/auteur = papoo
update/mise à jour = 02/01/2020
creation = 24/06/2017
github https://github.com/papo-o/domoticz_scripts/blob/master/dzVents/scripts/rafraichissementNocturne.lua
blog https://pon.fr/
forum https://easydomoticz.com/forum/viewtopic.php?f=17&t=4343&p=76999#p76999
ce script utilise la fonction de notification universelle https://pon.fr/dzvents-fonction-de-notification-universelle/
--]]
local scriptName = 'Rafraichissement nocturne'
local scriptVersion = '2.0'
local seuil_notification = 25 -- seuil température intérieure au delà duquel les notifications seront envoyées
local deltaT = 2 -- Delta T entre T° interieure et T° extérieure avant notification
local frequency_notifications = 3600
local quiet_hours = "23:00-07:15"
local subSystems = "TELEGRAM" --NSS_GOOGLE_CLOUD_MESSAGING, NSS_HTTP, NSS_KODI, NSS_LOGITECH_MEDIASERVER, NSS_NMA,NSS_PROWL, NSS_PUSHALOT, NSS_PUSHBULLET, NSS_PUSHOVER, NSS_PUSHSAFER, NSS_TELEGRAM
local temp_ext = 'TempExterieur' -- nom de la sonde extérieure
local les_temperatures = {
'tempsdb',
'tempmaison',
'temptony'
} -- Liste de vos sondes intérieures séparées par une virgule, la derniere ligne ne doit pas comporter de virgule
local subject = "\xE2\x9A\xA0 /!\\ Ouverture des fenetres recommandee /!\\ \xE2\x9A\xA0"
return {
active = true,
on = { timer = {'every 10 minutes'}},
--on = { timer = {'every minute'}},
logging = { level = domoticz.LOG_DEBUG,
-- level = domoticz.LOG_INFO, -- Seulement un niveau peut être actif; commenter les autres
-- level = domoticz.LOG_ERROR, -- Only one level can be active; comment others
-- level = domoticz.LOG_MODULE_EXEC_INFO,
marker = scriptName..' v'..scriptVersion },
execute = function(dz)
local round = dz.utils.round
--local _ = require('lodash')
local function logWrite(str,level) -- Support function for shorthand debug log statements
dz.log(tostring(str),level or dz.LOG_DEBUG)
end
local function split(s, delimiter)
if s ~= nil then
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
else
result = {""};
end
return result;
end
local function notificationTable(str)
--NSS_GOOGLE_CLOUD_MESSAGING, NSS_HTTP, NSS_KODI, NSS_LOGITECH_MEDIASERVER, NSS_NMA,NSS_PROWL, NSS_PUSHALOT, NSS_PUSHBULLET, NSS_PUSHOVER, NSS_PUSHSAFER, NSS_TELEGRAM
if (str) then
str = string.gsub (str,"GCM", dz.NSS_GOOGLE_CLOUD_MESSAGING)
str = string.gsub (str,"GOOGLE_CLOUD_MESSAGING", dz.NSS_GOOGLE_CLOUD_MESSAGING)
str = string.gsub (str,"HTTP", dz.NSS_HTTP)
str = string.gsub (str,"LMS", dz.NSS_LOGITECH_MEDIASERVER)
str = string.gsub (str,"LOGITECH_MEDIASERVER", dz.NSS_LOGITECH_MEDIASERVER)
str = string.gsub (str,"NMA", dz.NSS_NMA)
str = string.gsub (str,"PROWL", dz.NSS_PROWL)
str = string.gsub (str,"PUSHALOT", dz.NSS_PUSHALOT)
str = string.gsub (str,"PUSHOVER", dz.NSS_PUSHOVER)
str = string.gsub (str,"PUSHSAFER", dz.NSS_PUSHSAFER)
str = string.gsub (str,"PUSHBULLET", dz.NSS_PUSHBULLET)
str = string.gsub (str,"TELEGRAM", dz.NSS_TELEGRAM)
end
return (split(str,','))
end
local tempExt = round(dz.devices(temp_ext).temperature,2)
logWrite("le device : "..tostring(dz.devices(temp_ext).name).." indique une température de "..tostring(tempExt).."°C")
local i = 0
local tempsInt = 0
for _, name in ipairs(les_temperatures) do
i = i + 1
local dev = dz.devices(name)
if dev.temperature then
logWrite("le device : "..tostring(dev.name).." indique une température de "..tostring(round(dev.temperature,2)).."°C")
tempsInt = tempsInt + dev.temperature
end
end
logWrite("nombre de sondes intérieures parcourues est de "..tostring(i))
tempsInt = round(tempsInt/i)
logWrite("la moyenne ambiante intérieure est de "..tostring(tempsInt).."°C")
if (tempsInt + deltaT) > tempExt and seuil_notification < tempExt then
logWrite("la moyenne ambiante intérieure moins le deltat T est de "..tostring(tempsInt - deltaT).."°C")
dz.helpers.managedNotify(dz, subject, "Ouverture des fenêtres recommandée, la température moyenne ambiante intérieure est supérieure de "..deltaT.."°C à la temperature extérieure" , notificationTable(subSystems), frequency_notifications , quiet_hours)
end
-- dz.devices(les_temperatures).forEach(
-- function(device)
-- logWrite("le device : "..tostring(device.name).." a une température de "..tostring(device.temperature))
-- end
-- )
-- local temp = dz.devices().filter(function(device)
-- return _.includes(les_temperatures, device.name)
-- end)
-- print_table(temp)
end -- execute function
}