bon , j'ai mis de côté ce script, j'en ai trouvé un autre sur le forum (celui en anglais), et je l'ai adapté à ma config.
le voilà
Code : Tout sélectionner
-- Title: script_device_weewx.lua
-- Date: 09-01-2016
-- this script reads the weewxpws xml file and uploads current data to virtual device
commandArray = {}
os.execute('wget http://192.168.0.153/weewx/domoticz.xml -O /home/jeeper/domoticz/scripts/lua/domoticz.xml')
local filename = "/var/www/html/weewx/domoticz.xml"
local line = ''
local temperature = 0
local humidity = 0
local pressure = 0
local tempdevice = ''
for line in io.lines(filename) do
if string.find(line,"\"temp\"") then
temperature=line
end
if string.find(line,"\"hum\"") then
humidity=tonumber(string.match(line, "%d+"))
end
if string.find(line,"\"barometer\"") then
pressure=tonumber(string.match(line, "%d+"))
end
print(line)
end
-- Update device id 1, nval 0 sval temp;hum;hum-stat;baro;baro-stat
tempdevice='1|0|'..temperature..';'..humidity..';0;'..pressure..';0'
--force print as string
-- none of these work
--commandArray['UpdateDevice'] = "1|0|" .. temperature .. ";" .. humidity .. ";0;" .. pressure .. ";0"
--commandArray['UpdateDevice'] = '1|0|'..temperature..';'..humidity..';0;'..pressure..';0'
--commandArray['UpdateDevice'] = tempdevice
-- only this one updates the device
commandArray['UpdateDevice'] = tempdevice
print(tempdevice)
return commandArray
ci-joint copie écran de l'affichage et logs; après si celui-ci fonctionne bien , je me remettrai sur l'autre script.
salinois2024-02-11 15:07:00.057 Status: EventSystem: Script event triggered: script_weewx_2
2024-02-11 15:08:00.074 Status: LUA: <weewx>
2024-02-11 15:08:00.074 Status: LUA: <data realtime="temp">20,7<!--Temperature Bureau--></data>
2024-02-11 15:08:00.074 Status: LUA: <data realtime="hum">43<!--Humidite Bureau--></data>
2024-02-11 15:08:00.074 Status: LUA: <data realtime="barometer">997,9<!--Barometre--></data>
2024-02-11 15:08:00.074 Status: LUA: </weewx>
2024-02-11 15:08:00.074 Status: LUA: 1|0| <data realtime="temp">20,7<!--Temperature Bureau--></data>;43;0;997;0