Re: 1er Script avec weewx
Publié : 10 févr. 2024, 15:13
je suis en train de verifier et de supprimer des choses dans le fichier dont je n'ai pas besoin.
je te redis des que j'ai fini
je te redis des que j'ai fini
Reprenez le contrôle de votre domotique
https://easydomoticz.com/forum/
C'est normal, les scripts LUA gérés via le WebUI sont enregistrés seulement dans la base de données. Il n'y a pas fichier généré dans les dossiers.salinois a écrit : 10 févr. 2024, 14:41 Ok, donc j'ai effacé le script , il disparait bien du repertoire /home/jeeper/domoticz/scripts/dzVents/generated_scripts/
je refais la meme operation comme le dit Kheros, je sauvegarde mais il n'apparait pas dans le repertoire /home/jeeper/domoticz/scripts/lua/
il n'y a que ceux qui viennent avec l'installation !!!!! par contre dans le Webui, il y est !!!
si je refais la meme chose en choisissant /dzVents/generated_scripts/ "pour tester", il apparait bien dans ce repertoire.
Est-ce un bug ?
Code : Tout sélectionner
-- Title: script_device_weewx.lua
-- Date: 10-01-2016
-- this script reads the weewxpws xml file and uploads current data to virtual device
-- format of the xml file =
-- <weewx>
-- <data realtime="temp">8.5<!--outsideTemp--></data>
-- <data realtime="hum">73.2<!--outsideHumidity--></data>
-- <data realtime="inTemp">19.5<!--outsideTemp--></data>
-- <data realtime="inHum">53.2<!--outsideHumidity--></data>
-- <data realtime="barometer">1025.5<!--Pressure--></data>
-- </weewx>
--
--
-- Config
-- local wind_device_idx = 13
-- local rain_device_idx = 11
-- local garden_device_idx = 8
local room_device_idx = 2
-- local aux_device_idx = 14
-- Attention au nom du "Dispositif" ,
-- c'est celui que l'on a mis dans la Config (on en choisi un au hasard parmis l'un des dispositifs de notre weewx)
s = otherdevices_lastupdate['Temperature Bureau']
-- returns a date time like 2013-07-11 17:23:12
-- Remplacer 'Vent Jardin' par le nom de votre dispositif anémomètre
-- prev_wind = otherdevices_svalues['Vent Jardin']
-- End Config
commandArray = {}
t1 = os.time()
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)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
-- ON ne mets à jour que tous les 5 mns
if ( difference < 300 ) then
return commandArray
end
-- ca fonctionne mais c'est parfois un peu long et on dépasse les 10 secondes... on fait donc cela par crontab
-- os.execute('wget http://my-weewx.site.fr/domoticz.xml -O /tmp/domoticz.xml')
-- os.execute('sed s#,#.# /tmp/domoticz.xml > /tmp/domoticz.xml-pre')
local filename = "/var/www/html/weewx/domoticz.xml"
local line , tempdevice = ''
local temperature,humidity,pressure,inhumidity,intemperature,auxhumidity,auxtemperature,rain,rainrate,wind,winddir,windgust,windchill = 0
local windcomp = 'N'
for line in io.lines(filename) do
if string.find(line,"\"temp\"") then
temperature=tonumber(string.match(line, "%-?%d+.?%d*"))
elseif string.find(line,"\"hum\"") then
humidity=tonumber(string.match(line, "%d+"))
-- elseif string.find(line,"\"inTemp\"") then
-- intemperature=tonumber(string.match(line, "%-?%d+.?%d*"))
-- elseif string.find(line,"\"inHum\"") then
-- inhumidity=tonumber(string.match(line, "%d+"))
-- elseif string.find(line,"\"auxTemp\"") then
-- auxtemperature=tonumber(string.match(line, "%-?%d+.?%d*"))
-- elseif string.find(line,"\"auxHum\"") then
-- auxhumidity=tonumber(string.match(line, "%d+"))
elseif string.find(line,"\"barometer\"") then
pressure=tonumber(string.match(line, "%d+"))
-- elseif string.find(line,"\"rainrate\"") then
-- rainrate=100 * tonumber(string.match(line, "%d+.?%d*"))
-- elseif string.find(line,"\"Rain\"") then
-- rain=tonumber(string.match(line, "%d+.?%d*"))
-- elseif string.find(line,"\"wind\"") then
-- wind=tonumber(string.match(line, "%d+"))
-- elseif string.find(line,"\"Winddir\"") then
-- winddir=tonumber(string.match(line, "%d+"))
-- elseif string.find(line,"\"Windgust\"") then
-- windgust=tonumber(string.match(line, "%d+"))
-- elseif string.find(line,"\"Windcomp\"") then
-- windcomp=string.match(line, "Windcomp\">([NESO/A]+)<!--")
-- elseif string.find(line,"\"WindChill\"") then
-- windchill=tonumber(string.match(line, "%-?%d+.?%d*"))
end
end
-- Si la vitesse du vent est nulle winddir et windcomp garde la valeur précédente
-- if ( wind == 0 or wind == nil ) then
-- winddir,windcomp = prev_wind:match("([^;]+);([^;]+)")
-- wind = 0
-- end
-- A l'initialisation du device domoticz on peut avoir des valeurs farfelues
-- if winddir == nil then
-- winddir = 0
-- end
-- if windcomp =='N/A' then
-- windcomp = 'N'
-- end
-- if windchill == nil then
-- windchill = 0
-- end
-- if windgust== nil then
-- windgust= 0
-- end
-- Conversion de win et wingust (domoticz attend 10 * Winspeed [m/s] -- weewx nous donne Winspeed [km/h]
-- wind = math.ceil(wind / 0.36)
-- windgust = math.ceil(windgust / 0.36)
-- Conditions Salon
if not ( inhumidity == nil or intemperature == nil ) then
tempdevice = room_device_idx..'|0|'..intemperature..';'..inhumidity..';0'
commandArray [1] = {['UpdateDevice'] = tempdevice }
end
-- Meteo Locale idx = 8
if not ( humidity == nil or temperature == nil or pressure == nil ) then
tempdevice = garden_device_idx..'|0|'..temperature..';'..humidity..';0;'..pressure..';0'
commandArray [2] = {['UpdateDevice'] = tempdevice }
end
-- Pluie Locale idx = 11
-- if not ( rainrate == nil or rain == nil ) then
-- tempdevice = rain_device_idx..'|0|'..rainrate..';'..rain
-- commandArray [3] = {['UpdateDevice'] = tempdevice }
-- end
-- Vent Locale idx=13 dir;comp;speed;gust;temp;windchill
-- if not ( temperature == nil ) then
-- (( tempdevice = wind_device_idx..'|0|'..winddir..';'..windcomp..';'..wind..';'..windgust..';'..temperature..';'..windchill
-- commandArray [4] = {['UpdateDevice'] = tempdevice }
-- end
-- Conditions Aux idx=14 (WC ou Cave)
-- if not ( auxhumidity == nil or auxtemperature == nil ) then
-- tempdevice = aux_device_idx..'|0|'..auxtemperature..';'..auxhumidity..';0'
-- commandArray [5] = {['UpdateDevice'] = tempdevice }
-- end
return commandArrayCode : Tout sélectionner
local room_device_idx = 1Code : Tout sélectionner
-- ON ne mets à jour que tous les 5 mns
if ( difference < 300 ) then
-- return commandArray
endCode : Tout sélectionner
-- End Config
commandArray = {}
print ("coucou")
t1 = os.time()
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)je le déplace progressivement vers le bas2024-02-10 21:08:00.305 Status: LUA: coucou
2024-02-10 21:09:00.317 Status: LUA: coucou
2024-02-10 21:10:00.328 Status: LUA: coucou
Code : Tout sélectionner
-- end
print ("bonjour")
return commandArray