Get weather data from LAN based ObserverIP PWS  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

eddieb
Posts: 279
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by eddieb »

Hi,
originally it is a renkforce wh2600 (https://www.conrad.nl/p/renkforce-wh260 ... ur-1267654)
I updated the software with the latest observerip software from https://ambientweather.net/help/observe ... re-update/
I don't know if it is possible to update the wh2600 to that latest version in 1 step, I did several in-between updates over time.

At least ambient-weather is doing strange things. It tries to block NON ambient-weather bought PWS ... So it detects that this is an updated WH2600 and doesn't want to sent updates to ambient-weather, that is blocked somewhere in verstion 4.3 or so.

Uploading to WU works fine however. If you need intermediate firmware's sent me a pm ;-)

for now I just want to access the data of all sensors to show in domoticz. I don't want to sent data to wu thru domoticz.

Eddie
Last edited by eddieb on Wednesday 28 August 2019 12:31, edited 2 times in total.
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get weather data from LAN based ambient weather stations webpage

Post by waaren »

eddieb wrote: Wednesday 28 August 2019 8:23 Looks like it is working, now I should probably define some devices under dummy hardware ...
What do I need to do to get this working ?
1st. create a dummy hardware (if you have not one already)
2nd When you decided which values you want to have in the domoticz devices and created these devices as virtual device with unique names in the dummy hardware (use type wind, rain, temperature, text, alert, switch, etc) Send these types/names ([EDIT] and which value it should show) to me and I will do the next step in the dzVents. Could take some time tough as I am still traveling.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
eddieb
Posts: 279
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by eddieb »

Hi,
I am not 100% sure about what devices to create, for now I did this :
Screen Shot 2019-08-28 at 10.33.57.png
Screen Shot 2019-08-28 at 10.33.57.png (169.12 KiB) Viewed 8023 times
I want to use the following fields (out of the script)

name: "inTemp" value: "23.0"
name: "inHumi" value: "65"
name: "RelPress" value: "1010.10"
name: "outTemp" value: "20.0"
name: "outHumi" value: "80"
name: "windir" value: "151"
name: "avgwind" value: "0.0"
name: "gustspeed" value: "0.0"
name: "dailygust" value: "4.0"
name: "solarrad" value: "55.35"
name: "uvi" value: "1"
name: "rainofhourly" value: "0.00"

I really appreciate the work you are doing ;-)

Eddie
Last edited by eddieb on Wednesday 28 August 2019 12:26, edited 2 times in total.
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
eddieb
Posts: 279
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by eddieb »

I Just changed the initial topic ;-)
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by waaren »

eddieb wrote: Wednesday 28 August 2019 10:42 I am not 100% sure about what devices to create, for now I did this :
Just sent a PM. Will publish final script when ready and tested here.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get weather data from LAN based ObserverIP PWS  [Solved]

Post by waaren »

Still in test but ready enough to play with. Have fun !

Code: Select all

local scriptVersion = '0.201911091100'
local scriptVar  =  'ObserverIP_' .. scriptVersion

--[[ 

this dzVents script is used to collect data from ObserverIP weatherstation with software version 4.5.7. (weatherlogger 2.2.2.)
Because there is no known API / JSON interface at the time this script was created, it uses a call to the Web Gui and interprets the returned HTML code. 
This code is likely to change when a new version is released. If you encounter an incompatibility between this version of the script and a new version of the ObserverIP  software then please report this on the domoticz forum.

Also post there if you have a requirement to expose more of the available information to domoticz (either in a device or a uservariable) 

Before activating the script:
    please read the GETTING STARTED section of the dzVents wiki. 
    change xxx.xxx.xxx.xxx in this script to the IP of your weatherStation 
    define a dummy hardware in domoticz if not already done 
    define virtual sensors in domoticz for this dummy hardware

        type           Will show 
        wind           windspeed, windgust, winddirection (numeric and string), temperature, windchill temperature
        temperature    indoor temperature
        temp/humidity  indoor temperature, indoor humidity, indoor humidity status
        temperature    outdoor temperature
        temp/humidity  outdoor temperature, outdoor humidity, outdoor humidity status
        solarRadiation solar Radiation
        UV index       UV index
        rain           Rainrate in mm/h and amount of rain.
        barometer      air pressure in HPA
        dailyRain      Daily amount of rain in mm ( define as general Custom sensor with x-as mm )
        weeklyRain     Weekly amount of rain in mm ( define as general Custom sensor with x-as mm )  
        monthlyRain    Monthly amount of rain in mm ( define as general Custom sensor with x-as mm )
        yearlyRain     Yearly amount of rain in mm ( define as general Custom sensor with x-as mm )  
        gustSpeed      Gust speed ( define as general Custom sensor with x-as m/sec )
        avgWind        Wind speed ( define as general Custom sensor with x-as m/sec )

and change the names in the device declarations between the marked lines below.
these devices will overtime keep an history of the collected data that can be viewed by pressing the log button on the device.

History
========
20190828 Start coding
20180829 Start testing (thanks @eddieb !) based on prototype
20190901 Added comments and history 
20190904 Added option to get a notification when time since last device update is too long
20191016 Fixed wrong link between names and values
20191017 Added updates of custom sensors for daily-, weekly-, monthly- and yearly rain
20191017 Fixed typos (wrong case in table) 
20191018 Added option to add separate custom sensors for gustSpeed and average Wind 
20191030 Added option for script to be started by a device.
20191109 Replaced math.pow(x,y) with x^y (Lua 5.3 deprecated math.pow) 
 
]]--

return
{
    on = 
    { 
        devices = {'your trigger device name here' }, -- Script can be triggered by a device  
        timer = { 'every 5 minutes' }, -- or by a timer-rule
        -- timer = { 'every 1 minutes' }, -- 
        httpResponses = { scriptVar },  -- do not change this
    },

    logging =   
    {
        level = domoticz.LOG_DEBUG, -- change to LOG_ERROR when everything works as expected
        marker = scriptVar,
    },

    data = 
    { 
        rainTotal = { initial = 0 },
        previousRainSample = { initial = 0 },
    },

    execute = function(dz, item)
        -- ********** local settings below this line *************
        -- change to IP of your weatherstation
        local weatherStationIP = 'xxx.xxx.xxx.xxx' 
        
        -- change to number of seconds after you want to receive a notification that the response of the website is unexpected long
        -- set to -1 if you never want to be notified
        local maxResponseSeconds = 720 

        -- Change devicenames below to reflect your names and uncomment the lines with the devices you defined.
        -- You can also use idx but if you do, then don't use the surrounding quotes.
        
        -- local wind = dz.devices('AWindDir')
        -- local insideTemperature = dz.devices('AinTemp')
        -- local insideTemperatureHumidity = dz.devices('AinTempHum')
        -- local outsideTemperature = dz.devices('AoutTemp')
        -- local outsideTemperatureHumidity = dz.devices('AoutTempHum')
        -- local solarRadiation = dz.devices('ASolarRad')
        -- local uvIndex = dz.devices('AUvi')
        -- local rain = dz.devices('ARain')
        -- local barometer = dz.devices('ARelPress')
        -- local dailyRain = dz.devices('aDailyRain')       
        -- local weeklyRain = dz.devices('aWeeklyRain')     
        -- local monthlyRain = dz.devices('aMonthlyRain')   
        -- local yearlyRain = dz.devices('aYearlyRain')   
        -- local gustSpeed = dz.devices('AGustSpeed')
        -- local avgWind = dz.devices('AvgWind')
        
        -- ********** No changes necessary below this line *************

        -- this function will calculate  the last time the script updated devices
        -- to check if the webpage response was within limits
        local function checkWebpageResponse()
            local deltaSeconds = dz.time.dDate - dz.data.previousRainSample
            if ( maxResponseSeconds > 0 )  and ( deltaSeconds > maxResponseSeconds ) then
                dz.notify(scriptVar, 'weatherStation did not respond within ' .. tostring(maxResponseSeconds) .. ' seconds.')
            end
        end
        
        -- this function will call the webpage
        local function getWeatherStationData()
           local url = 'http://' .. weatherStationIP .. '/livedata.htm'
           dz.openURL  ({ url = url, callback = scriptVar })
        end

        -- this function will process the HTML and from the relevant data it will create a table to hold the values to update the devices
        local function processHTM()
            local fieldNames = {    -- the commented fields are available in the html but not used in this script.
                                        -- CurrTime='Current time',
                                        -- inBattSta='internalBatteryStatus',
                                        -- outBattSta1='outdoorBatteryStatus1',
                                        -- outBattSta2='outdoorBatteryStatus2',
                                        inTemp='indoorTemperature',
                                        inHumi='indoorHumidity',
                                        AbsPress='absolutePressure',
                                        RelPress='relativePressure',
                                        outTemp='outdoorTemperature',
                                        outHumi='outdoorHumidity',
                                        windir='windDirection',
                                        avgwind='windSpeed',
                                        gustspeed='windGust',
                                        dailygust='maxDailyGust',
                                        solarrad='solarRadiation',
                                        uv='UV',
                                        uvi='UVI', 
                                        pm25='PM2.5', 
                                        rainofhourly='hourlyRainRate',
                                        eventrain='eventRain',
                                        rainofdaily='dailyRain', 
                                        rainofweekly='weeklyRain',
                                        rainofmonthly='monthlyRain', 
                                        rainofyearly='yearlyRain',
                                    }

            
            -- Prepare WSData (remove quotes, nullify option value, and make fieldName )
            WSData = (item.data):gsub('"',''):gsub("'",""):gsub("option value"," xx"):gsub("input name"," fieldName") 
            
            -- fill table with keys
            local lines = {}
            local linesIndex = 1
            for keyField in string.gmatch( WSData,"[^%s, ]+" ) do -- loop over all 'words' in thedata
                if string.find(keyField,'fieldName=') then -- if 'word' is like fieldName=text
                    lines[linesIndex] = {}
                    lines[linesIndex].name =  keyField:gsub('fieldName=','') -- put text into name field 
                    linesIndex = linesIndex + 1
                end
            end

            -- fill table with values
            linesIndex = 1
            for keyField in string.gmatch( WSData,"[^%s, ]+" ) do 
                if string.find(keyField,'value=') then -- if 'word' is like value=text / number
                    if lines[linesIndex] == nil then lines[linesIndex] = {} end
                    lines[linesIndex].value =  keyField:gsub('value=','') -- put text / number into corresponding value field 
                    linesIndex = linesIndex + 1
                end
            end
            
            -- fill table usedFields only with names and values we are going to use to fill devices
            local usedFields = {}            
            for linesIndex = 1, #lines do 
                if fieldNames[lines[linesIndex].name] ~= nil then
                    usedFields[fieldNames[lines[linesIndex].name]] = lines[linesIndex].value  
                end
            end
			return usedFields
        end

        local function updateDevices(fields) -- update all ( declared ) devices. Specialized function to create required fields are local to this function
          
            local function windDirectionName(degrees) -- do not translate as domoticz web GUI depends on strings like E or S 
                degrees = tonumber(degrees) % 360 -- Ensure between 0 and 360
                local windDirections =
                    {
                            N={0,22.5}, -- 337,5- 360 will be catched later 
                            NE={22.5,67.5},
                            E={67.5,112.5},
                            SE={112.5,157.5},
                            S={157.5,202.5},
                            SW={202.5,247.5},
                            W={247.5,292.5},
                            NW={292.5,337.5},
                    }
                local minDegrees = 1
                local maxDegrees = 2
                for key, value in pairs(windDirections) do
                    if degrees >= value[minDegrees] and degrees < value[maxDegrees] then return key end
                end
                return 'N'
            end

            local function windChill(windSpeed, temperature) -- official KNMI function to compute windchill
                windSpeed = tonumber(windSpeed)
                temperature = tonumber(temperature)
                if windSpeed < 1.3 or windSpeed > 49 or temperature < -46 or temperature > 17 then return temperature end
                return dz.utils.round(13.12 + (0.6215 * temperature) - (13.96 * windSpeed^0.16) + (0.4867 * temperature * windSpeed^0.16), 1)
            end

            local function humidityStatus(temperature, humidity) -- as used in domoticz source
                humidity = tonumber(humidity)
                temperature = tonumber(temperature)
                if humidity <= 30 then return dz.HUM_DRY
                elseif humidity >= 70 then return dz.HUM_WET
                elseif  humidity >= 35 and humidity <= 65 and temperature >= 22 and temperature <= 26 then return dz.HUM_COMFORTABLE end
                return dz.HUM_NORMAL
            end

            local function BarometerForecast(pressure) -- simplified forecast model
                if pressure == nil then return nil end -- Should not happen
                pressure = tonumber(pressure)
                if pressure < 966   then return dz.BARO_THUNDERSTORM
                elseif pressure < 993   then return dz.BARO_CLOUDY
                elseif pressure < 1007  then return dz.BARO_PARTLYCLOUDY
                elseif pressure < 1013  then return dz.BARO_UNSTABLE
                elseif pressure < 1033  then return dz.BARO_STABLE
                end
                return dz.BARO_SUNNY
            end    

            local function updateRain(rainRate) -- use time since last sample to calculate new total. Daily total is derived from total by domoticz 
                rainRate = tonumber(rainRate)
                if dz.data.previousRainSample == 0 then 
                    dz.log('Initial setting of the raindata. No update of the device yet',dz.LOG_FORCE)
                    dz.data.previousRainSample = dz.time.dDate
                    return
                end
                if rainRate > 1000 then 
                    dz.log('Obvious wrong value. This would be more then 1 meter of rain per hour',dz.LOG_ERROR)
                    return 
                end 
                local deltaSeconds = dz.time.dDate - dz.data.previousRainSample
                local rainIncrease = rainRate * ( deltaSeconds / 3600 )
                local previousRainTotal = math.max(dz.data.rainTotal,  rain.rain or 0) -- protect against reset or new device 
                dz.data.rainTotal = previousRainTotal + rainIncrease 
                rain.updateRain(rainRate * 100 , dz.utils.round(dz.data.rainTotal,1)) -- one decimal should be accurate enough
                dz.data.previousRainSample = dz.time.dDate
            end   

            -- update weatherDevices/ See dzVents wiki (https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting) for required parms of the update functions 
            if wind ~= nil then wind.updateWind
            (
                fields.windDirection, 
                windDirectionName(fields.windDirection), 
                fields.windSpeed, 
                fields.windGust, 
                fields.outdoorTemperature, 
                windChill(fields.windSpeed, fields.outdoorTemperature)
            ) end

            if insideTemperature ~= nil then insideTemperature.updateTemperature(fields.indoorTemperature) end

            if insideTemperatureHumidity then insideTemperatureHumidity.updateTempHum
            (
                fields.indoorTemperature, 
                fields.indoorHumidity, 
                humidityStatus(fields.indoorTemperature,fields.indoorHumidity)
            ) end

            if outsideTemperature ~= nil then outsideTemperature.updateTemperature(fields.outdoorTemperature) end

            if outsideTemperatureHumidity ~= nil then outsideTemperatureHumidity.updateTempHum
            (
                fields.outdoorTemperature, 
                fields.outdoorHumidity, 
                humidityStatus(fields.outdoorTemperature,fields.outdoorHumidity)
            ) end

            if solarRadiation ~= nil then solarRadiation.updateRadiation(fields.solarRadiation) end

            if uvIndex ~= nil then uvIndex.updateUV(fields.UVI) end

            if rain ~= nil then updateRain(fields.hourlyRainRate) end

            if barometer ~= nil then barometer.updateBarometer
            (
                fields.relativePressure,
                BarometerForecast(fields.relativePressure)
            ) end
            
            if _G.logLevel == dz.LOG_DEBUG then dz.utils.dumpTable(fields) end
            
            if dailyRain ~= nil then dailyRain.updateCustomSensor(fields.dailyRain) end
            if weeklyRain ~= nil then weeklyRain.updateCustomSensor(fields.weeklyRain) end
            if monthlyRain ~= nil then monthlyRain.updateCustomSensor(fields.monthlyRain) end
            if yearlyRain ~= nil then yearlyRain.updateCustomSensor(fields.yearlyRain) end
            
            if gustSpeed ~= nil then gustSpeed.updateCustomSensor(fields.windGust) end
            if avgWind ~= nil then avgWind.updateCustomSensor(fields.windSpeed) end
            
        end

       -- main 
        if item.isTimer or item.isDevice then
            checkWebpageResponse()
            getWeatherStationData()
        elseif item.ok then -- statusCode == 2xx
            updateDevices(processHTM(item.data))
        else
            dz.log('Could not get (good) data from ' .. weatherStationIP,dz.LOG_ERROR)
            dz.log(item.data,dz.LOG_DEBUG)
        end

    end
}

Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
eddieb
Posts: 279
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by eddieb »

Big tnx for @waaren for helping out on this script.
It runs for about a week now and it looks great !
Eddie
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by Doudy »

;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by Doudy »

IHello,
I have following error :

Code: Select all

 
2019-10-14 15:42:01.428 Status: dzVents: Error (2.4.19): ObserverIP_0.201909061500: An error occured when calling event handler ObserverIP
2019-10-14 15:42:01.428 Status: dzVents: Error (2.4.19): ObserverIP_0.201909061500: /home/pi/domoticz/scripts/dzVents/scripts/ObserverIP.lua:190: attempt to compare nil with number 
I have modified line 190 - 191 - 192:

Code: Select all

        local function humidityStatus(temperature, humidity) -- as used in domoticz source
                humidity = tonumber(humidity)
                temperature = tonumber(temperature)
                if humidity and humidity <= 30 then return dz.HUM_DRY
                elseif humidity and humidity >= 70 then return dz.HUM_WET
                elseif  humidity and humidity >= 35 and humidity and humidity <= 65 and temperature >= 22 and temperature <= 26 then 
                return dz.HUM_COMFORTABLE end
                return dz.HUM_NORMAL
         end
Result:

Code: Select all

2019-10-14 15:48:01.365 Status: dzVents: Info: Handling httpResponse-events for: "ObserverIP_0.201909061500
2019-10-14 15:48:01.365 Status: dzVents: Info: ObserverIP_0.201909061500: ------ Start external script: ObserverIP.lua: HTTPResponse: "ObserverIP_0.201909061500"
2019-10-14 15:48:01.367 Status: dzVents: Debug: ObserverIP_0.201909061500: Processing device-adapter for AWindDir: Wind device adapter
2019-10-14 15:48:01.368 Status: dzVents: Debug: ObserverIP_0.201909061500: Processing device-adapter for AinTemp: Temperature device adapter
2019-10-14 15:48:01.369 Status: dzVents: Debug: ObserverIP_0.201909061500: Processing device-adapter for AinTempHum: Temperature+humidity device adapter
2019-10-14 15:48:01.369 Status: dzVents: Debug: ObserverIP_0.201909061500: Processing device-adapter for AoutTemp: Temperature device adapter
2019-10-14 15:48:01.371 Status: dzVents: Debug: ObserverIP_0.201909061500: Processing device-adapter for AoutTempHum: Temperature+humidity device adapter
2019-10-14 15:48:01.373 Status: dzVents: Debug: ObserverIP_0.201909061500: Processing device-adapter for ASolarRad: Solar radiation device adapter
2019-10-14 15:48:01.375 Status: dzVents: Debug: ObserverIP_0.201909061500: Processing device-adapter for AUvi: UV device adapter
2019-10-14 15:48:01.376 Status: dzVents: Debug: ObserverIP_0.201909061500: Processing device-adapter for ARain: Rain device
2019-10-14 15:48:01.377 Status: dzVents: Debug: ObserverIP_0.201909061500: Processing device-adapter for ARelPress: Barometer device adapter
2019-10-14 15:48:01.386 Status: dzVents: Info: ObserverIP_0.201909061500: ------ Finished ObserverIP.lua 
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by Doudy »

Hello,

ambiantweather.lua

In ambiantweather.lua, I have an offset of data
CurrTime = OK
InTemp = NOK this is the value that is in AbsPress
InHumi = NOK this is the value that is in RelPress
etc ...

Code: Select all

2019-10-16 14:12:01.289 Status: dzVents: > 1:
2019-10-16 14:12:01.289 Status: dzVents: > name: "CurrTime"
2019-10-16 14:12:01.289 Status: dzVents: > value: "14:12
2019-10-16 14:12:01.289 Status: dzVents: > 2:
2019-10-16 14:12:01.289 Status: dzVents: > name: "inBattSta"
2019-10-16 14:12:01.289 Status: dzVents: > value: "0"
2019-10-16 14:12:01.290 Status: dzVents: > 3:
2019-10-16 14:12:01.290 Status: dzVents: > name: "outBattSta"
2019-10-16 14:12:01.290 Status: dzVents: > value: "1"
2019-10-16 14:12:01.290 Status: dzVents: > 4:
2019-10-16 14:12:01.290 Status: dzVents: > name: "IndoorID"
2019-10-16 14:12:01.290 Status: dzVents: > value: "0"
2019-10-16 14:12:01.290 Status: dzVents: > 5:
2019-10-16 14:12:01.290 Status: dzVents: > name: "Outdoor1ID"
2019-10-16 14:12:01.290 Status: dzVents: > value: "1"
2019-10-16 14:12:01.290 Status: dzVents: > 6:
2019-10-16 14:12:01.290 Status: dzVents: > name: "Outdoor2ID"
2019-10-16 14:12:01.290 Status: dzVents: > value: "0x4c"
2019-10-16 14:12:01.290 Status: dzVents: > 7:
2019-10-16 14:12:01.290 Status: dzVents: > name: "inTemp"
2019-10-16 14:12:01.290 Status: dzVents: > value: "0x7e"
2019-10-16 14:12:01.290 Status: dzVents: > 8:
2019-10-16 14:12:01.291 Status: dzVents: > name: "inHumi"
2019-10-16 14:12:01.291 Status: dzVents: > value: "0x--"
2019-10-16 14:12:01.291 Status: dzVents: > 9:
2019-10-16 14:12:01.291 Status: dzVents: > name: "AbsPress"
2019-10-16 14:12:01.291 Status: dzVents: > value: "22.5"
2019-10-16 14:12:01.291 Status: dzVents: > 10:
2019-10-16 14:12:01.291 Status: dzVents: > name: "RelPress"
2019-10-16 14:12:01.291 Status: dzVents: > value: "65" 
An idea ?
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by waaren »

Doudy wrote: Wednesday 16 October 2019 14:17 In ambiantweather.lua, I have an offset of data
CurrTime = OK
InTemp = NOK this is the value that is in AbsPress
InHumi = NOK this is the value that is in RelPress
etc ...

An idea ?
Not immediate but if you can share a screen shot of your webpage and the raw result of curl http://lan-ip/livedata.htm executed at the same time like @eddieB provided in this topic in his post of Tuesday 27 August 2019 20:37,
I will have a look.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by Doudy »

Here are the infos requested :

Image

Code: Select all


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>LiveData</title>
        <link href="axcss0.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td colspan="2" align="right" bgcolor="#0088F7">&nbsp;</td>
            </tr>
            <tr>
                <td colspan="2" bgcolor="#FFFFFF"><table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="20" height = "80">&nbsp;</td>
                            <td >&nbsp;</td>
                                                        <td width="10">&nbsp;</td>
                                <td class="txtstyle_1" >Weather Logger  2.2</td>
                        </tr>
                </table></td>
            </tr>
            <tr>
                <td colspan="2" align="right" bgcolor="#60B7FF"><table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="120" align="center"><font color="#FFFFFF" face="Arial, Helvetica, sans-serif"><em>Version:2.2.2</em></font></td>
                        </tr>
                </table></td>
            </tr>
            <tr>
                <td colspan="2" align="left" bgcolor="#C0C0C0">
                    <table width="20" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td bgcolor="#C0C0C0"><div class="menuitem_1"><a href="bscsetting.htm">Local Network</a></div></td>
                            <td bgcolor="#C0C0C0"><div class="menuitem_1"><a href="weather.htm">Weather Network</a></div></td>
                            <td bgcolor="#C0C0C0"><div class="menuitem_1"><a href="station.htm">Station Settings</a></div></td>
                            <td bgcolor="#EDEFEF"><div class="menuitem_1"><a href="livedata.htm">Live Data</a></div></td>
                            <td bgcolor="#C0C0C0"><div class="menuitem_1"><a href="correction.htm">Calibration</a></div></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <form name="livedata" method="POST" onsubmit="return chkForm(0);">

                <tr>
                    <td colspan="2" bgcolor="#EDEFEF"><div class="subitem_1">Live Data</div></td>
                </tr>
                 <tr>
                    <td width="533" bgcolor="#EDEFEF"><div class="item_1">Receiver Time:</div></td>
                    <td width="307" bgcolor="#EDEFEF">
                    <input name="CurrTime" disabled="disabled" type="text" class="item_2" style="WIDTH: 120px" value="15:14 10/16/2019" maxlength ="20"></td>
                </tr>
                <tr>
                    <td width="533" bgcolor="#EDEFEF"><div class="item_1">Indoor Battery Status</div></td>
                    <td width="307" bgcolor="#EDEFEF">
                    <select name="inBattSta" class="item_2" disabled="disabled"  style="WIDTH: 120px">
                            <option value="0" selected >Normal</option>
                            <option value="1"          >Indoor Bat Low</option>
                    </select></td>
                </tr>
                <tr>
                    <td width="533" bgcolor="#EDEFEF"><div class="item_1">Outdoor Battery Status</div></td>
                    <td width="307" bgcolor="#EDEFEF">
                    <select name="outBattSta" class="item_2" disabled="disabled"  style="WIDTH: 120px">
                            <option value="0" selected >Normal</option>
                            <option value="1"          >Outdoor Bat Low</option>
                    </select></td>
                </tr>
                <tr>
                    <td width="533" bgcolor="#EDEFEF"><div class="item_1">Indoor Sensor ID</div></td>
                    <td width="307" bgcolor="#EDEFEF"><input name="IndoorID" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="0x4c" max                                     length="6"></td>
                </tr>
                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Outdoor Sensor1 ID</div></td>
                    <td bgcolor="#EDEFEF"><input name="Outdoor1ID" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="0x7e" maxlength="6"                                     ></td>
                </tr>

                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Outdoor Sensor2 ID</div></td>
                    <td bgcolor="#EDEFEF"><input name="Outdoor2ID" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="0x--" maxlength="6"                                     ></td>
                </tr>

                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Indoor Temperature</div></td>
                    <td bgcolor="#EDEFEF"><input name="inTemp" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="22.6" maxlength="8"></t                                     d>
                </tr>

                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Indoor Humidity</div></td>
                    <td bgcolor="#EDEFEF"><input name="inHumi" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="64" maxlength="4"></td>
                </tr>
                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Absolute Pressure </div></td>
                    <td bgcolor="#EDEFEF"><input name="AbsPress" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="1001.70" maxlength="6                                     "></td>
                </tr>
                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Relative Pressure </div></td>
                    <td bgcolor="#EDEFEF"><input name="RelPress" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="1003.80" maxlength="6                                     "></td>
                </tr>
                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Outdoor Temperature</div></td>
                    <td bgcolor="#EDEFEF"><input name="outTemp" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="14.5" maxlength="8"></                                     td>
                </tr>

                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Outdoor Humidity </div></td>
                    <td bgcolor="#EDEFEF"><input name="outHumi" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="97" maxlength="4"></td                                     >
                </tr>

                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Wind Direction </div></td>
                    <td bgcolor="#EDEFEF"><input name="windir" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="171" maxlength="5"></td                                     >
                </tr>

                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Wind Speed </div></td>
                    <td bgcolor="#EDEFEF"><input name="avgwind" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="6.5" maxlength="6"></t                                     d>
                </tr>

                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Wind Gust </div></td>
                    <td bgcolor="#EDEFEF"><input name="gustspeed" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="12.2" maxlength="6">                                     </td>
                </tr>

                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Solar Radiation </div></td>
                    <td bgcolor="#EDEFEF"><input name="solarrad" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="39.48" maxlength="12"                                     ></td>
                </tr>

                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">UV </div></td>
                    <td bgcolor="#EDEFEF"><input name="uv" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="281" maxlength="12"></td>
                </tr>

                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">UVI </div></td>
                    <td bgcolor="#EDEFEF"><input name="uvi" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="1" maxlength="4"></td>
                </tr>

                <tr>
                    <td bgcolor="#EDEFEF"><div class="item_1">Hourly Rain Rate</div></td>
                    <td bgcolor="#EDEFEF"><input name="rainofhourly" disabled="disabled" type="text" class="item_2" style="WIDTH: 80px" value="0.00" maxlength="                                     8"></td>
                </tr>

                                <form name="Rain_1" method="POST" onsubmit="return chkForm(0);">
                        <tr>
                            <td bgcolor="#EDEFEF"><div class="item_1">Daily Rain</div></td>
                            <td bgcolor="#EDEFEF"><input name="rainofdaily"  type="text" class="item_2" style="WIDTH: 80px" value="2.40" maxlength="8">
                        <span id="rainofdaily_msg" class="errMsg0"></span></td>
                        </tr>

                        <tr>
                            <td bgcolor="#EDEFEF"><div class="item_1">Weekly Rain</div></td>
                            <td bgcolor="#EDEFEF"><input name="rainofweekly" type="text" class="item_2" style="WIDTH: 80px" value="2.40" maxlength="8">
                         <span id="rainofweekly_msg" class="errMsg0"></span></td>
                        </tr>

                        <tr>
                            <td bgcolor="#EDEFEF"><div class="item_1">Monthly Rain</div></td>
                            <td bgcolor="#EDEFEF"><input name="rainofmonthly" type="text" class="item_2" style="WIDTH: 80px" value="83.10" maxlength="8">
                         <span id="rainofmonthly_msg" class="errMsg0"></span></td>
                        </tr>

                        <tr>
                            <td bgcolor="#EDEFEF"><div class="item_1">Yearly Rain</div></td>
                            <td bgcolor="#EDEFEF"><input name="rainofyearly" type="text" class="item_2" style="WIDTH: 80px" value="589.20" maxlength="8">
                         <span id="rainofyearly_msg" class="errMsg0"></span></td>
                        </tr>

                        <tr>
                            <td colspan="2" bgcolor="#EDEFEF">&nbsp;</td>
                        </tr>
                        <tr align="center">
                            <td colspan="2" bgcolor="#EDEFEF"><input name="Apply" type="submit" class="item_2" style="WIDTH: 60px; HEIGHT: 24px;" onclick="setSu                                     bmitType(1)" value="Apply" />
                                <input name="Cancel" type="reset" class="item_2" style="WIDTH: 60px; HEIGHT: 24px;" value="Cancel" /></td>
                        </tr>
                </form>

                <tr>
                    <td colspan="2" bgcolor="#EDEFEF">&nbsp;</td>
                </tr>

                <tr>
                    <td colspan="2" align="center" bgcolor="#EDEFEF">
                        <input name="rain_Default" type="button" class="item_2" style="WIDTH: 110px; HEIGHT: 24px;" onclick="raindef()" value="Rain Reset">
                        <input id="refresh_st" type="button" class="item_4" style="WIDTH: 110px; HEIGHT: 24px;"  onclick="uiCtrl(this.value);" value="Refresh">
                        <input id="refresh_sp" type="button" class="item_2" style="WIDTH: 110px; HEIGHT: 24px;"  onclick="uiCtrl(this.value);" value="Stop Refre                                     sh">
                    </td>
                </tr>
            </form>
            <tr>
                <td colspan="2" bgcolor="#EDEFEF">&nbsp;</td>
            </tr>
            <tr>
                <td colspan="2" bgcolor="#C0C0C0">&nbsp;</td>
            </tr>
        </table>

                <script src="axjs0.js" type="text/javascript"></script>
        <script language="JavaScript" type="text/javascript">
            <!--
            var rfTaskRuningFlag = 0, rfTimeId;
            uiCtrl('Refresh');

                        function uiCtrl(uiCmd)
                        {
                            if (uiCmd=='Refresh'){
                                document.getElementById('refresh_st').disabled = true;
                                document.getElementById('refresh_sp').disabled = false;
                                rfTaskRuningFlag = 1;
                                rfTaskState = 0;
                                rfTimeId = setInterval("ss()",16000);
                            }else if (uiCmd=='Stop Refresh'){
                                document.getElementById('refresh_st').disabled = false;
                                document.getElementById('refresh_sp').disabled = true;
                                rfTaskRuningFlag = 0;
                                clearInterval(rfTimeId);
                            }
                        }

                        function ss()
                        {
                            if (rfTaskRuningFlag)
                            {
                                window.top.location.reload();
                            }
                        }
                        //-->
                </script>
    </body>
</html>

I adapted this :

Code: Select all

            local shortFieldNames = {    
                                        inTemp="Indoor Temperature",
                                        inHumi="Indoor Humidity",
                                        AbsPress="Absolute Pressure",
                                        RelPress="Relative Pressure",
                                        outTemp="Outdoor Temperature",
                                        outHumi="Outdoor Humidity",
                                        windir="Wind Direction",
                                        avgwind="Wind Speed",
                                        gustspeed="Wind Gust",
                                        --dailygust="Max Daily Gust",
                                        solarrad="Solar Radiation",
                                        uv="UV",
                                        uvi="UVI", 
                                        --pm25="PM2.5", 
                                        rainofhourly="Hourly Rain Rate",
                                        --eventrain="Event Rain",
                                        rainofdaily="Daily Rain", 
                                        rainofweekly="Weekly Rain",
                                        rainofmonthly="Monthly Rain", 
                                        rainofyearly="Yearly Rain",
                                    }

The log file :

Code: Select all

 2019-10-16 16:07:01.480 Status: dzVents: Debug: ambiantWeather: "4.20"
2019-10-16 16:07:01.481 Status: dzVents: Debug: ambiantWeather: "84.90"
2019-10-16 16:07:01.481 Status: dzVents: Debug: ambiantWeather: "591.00"
2019-10-16 16:07:01.481 Status: dzVents: Debug: ambiantWeather: "Apply"
2019-10-16 16:07:01.481 Status: dzVents: Debug: ambiantWeather: "Cancel"
2019-10-16 16:07:01.481 Status: dzVents: Debug: ambiantWeather: "Rain
2019-10-16 16:07:01.481 Status: dzVents: Debug: ambiantWeather: "Refresh">
2019-10-16 16:07:01.481 Status: dzVents: Debug: ambiantWeather: "Stop
2019-10-16 16:07:01.482 Status: dzVents: > 1:
2019-10-16 16:07:01.482 Status: dzVents: > value: "16:07
2019-10-16 16:07:01.482 Status: dzVents: > name: "CurrTime"
2019-10-16 16:07:01.482 Status: dzVents: > 2:
2019-10-16 16:07:01.482 Status: dzVents: > value: "0"
2019-10-16 16:07:01.482 Status: dzVents: > name: "inBattSta"
2019-10-16 16:07:01.482 Status: dzVents: > 3:
2019-10-16 16:07:01.482 Status: dzVents: > value: "1"
2019-10-16 16:07:01.482 Status: dzVents: > name: "outBattSta"
2019-10-16 16:07:01.482 Status: dzVents: > 4:
2019-10-16 16:07:01.482 Status: dzVents: > value: "0"
2019-10-16 16:07:01.482 Status: dzVents: > name: "IndoorID"
2019-10-16 16:07:01.482 Status: dzVents: > 5:
2019-10-16 16:07:01.482 Status: dzVents: > value: "1"
2019-10-16 16:07:01.482 Status: dzVents: > name: "Outdoor1ID"
2019-10-16 16:07:01.482 Status: dzVents: > 6:
2019-10-16 16:07:01.482 Status: dzVents: > value: "0x4c"
2019-10-16 16:07:01.482 Status: dzVents: > name: "Outdoor2ID"
2019-10-16 16:07:01.482 Status: dzVents: > 7:
2019-10-16 16:07:01.482 Status: dzVents: > value: "0x7e"
2019-10-16 16:07:01.482 Status: dzVents: > name: "inTemp"
2019-10-16 16:07:01.482 Status: dzVents: > 8:
2019-10-16 16:07:01.482 Status: dzVents: > value: "0x--"
2019-10-16 16:07:01.482 Status: dzVents: > name: "inHumi"
2019-10-16 16:07:01.482 Status: dzVents: > 9:
2019-10-16 16:07:01.482 Status: dzVents: > value: "22.6"
2019-10-16 16:07:01.482 Status: dzVents: > name: "AbsPress"
2019-10-16 16:07:01.483 Status: dzVents: > 10:
2019-10-16 16:07:01.483 Status: dzVents: > value: "64"
2019-10-16 16:07:01.483 Status: dzVents: > name: "RelPress"
2019-10-16 16:07:01.483 Status: dzVents: > 11:
2019-10-16 16:07:01.483 Status: dzVents: > value: "1001.80"
2019-10-16 16:07:01.483 Status: dzVents: > name: "outTemp"
2019-10-16 16:07:01.483 Status: dzVents: > 12:
2019-10-16 16:07:01.483 Status: dzVents: > value: "1003.90"
2019-10-16 16:07:01.483 Status: dzVents: > name: "outHumi"
2019-10-16 16:07:01.483 Status: dzVents: > 13:
2019-10-16 16:07:01.483 Status: dzVents: > value: "14.5"
2019-10-16 16:07:01.483 Status: dzVents: > name: "windir"
2019-10-16 16:07:01.483 Status: dzVents: > 14:
2019-10-16 16:07:01.483 Status: dzVents: > value: "97"
2019-10-16 16:07:01.483 Status: dzVents: > name: "avgwind"
2019-10-16 16:07:01.483 Status: dzVents: > 15:
2019-10-16 16:07:01.483 Status: dzVents: > value: "169"
2019-10-16 16:07:01.483 Status: dzVents: > name: "gustspeed"
2019-10-16 16:07:01.483 Status: dzVents: > 16:
2019-10-16 16:07:01.483 Status: dzVents: > value: "7.9"
2019-10-16 16:07:01.483 Status: dzVents: > name: "solarrad"
2019-10-16 16:07:01.483 Status: dzVents: > 17:
2019-10-16 16:07:01.483 Status: dzVents: > value: "12.2"
2019-10-16 16:07:01.483 Status: dzVents: > name: "uv"
2019-10-16 16:07:01.483 Status: dzVents: > 18:
2019-10-16 16:07:01.483 Status: dzVents: > value: "26.90"
2019-10-16 16:07:01.483 Status: dzVents: > name: "uvi"
2019-10-16 16:07:01.483 Status: dzVents: > 19:
2019-10-16 16:07:01.483 Status: dzVents: > value: "187"
2019-10-16 16:07:01.483 Status: dzVents: > name: "rainofhourly"
2019-10-16 16:07:01.483 Status: dzVents: > 20:
2019-10-16 16:07:01.483 Status: dzVents: > value: "1"
2019-10-16 16:07:01.483 Status: dzVents: > name: "Rain_1"
2019-10-16 16:07:01.483 Status: dzVents: > 21:
2019-10-16 16:07:01.483 Status: dzVents: > value: "0.00"
2019-10-16 16:07:01.484 Status: dzVents: > name: "rainofdaily"
2019-10-16 16:07:01.484 Status: dzVents: > 22:
2019-10-16 16:07:01.484 Status: dzVents: > value: "4.20"
2019-10-16 16:07:01.484 Status: dzVents: > name: "rainofweekly"
2019-10-16 16:07:01.484 Status: dzVents: > 23:
2019-10-16 16:07:01.484 Status: dzVents: > value: "4.20"
2019-10-16 16:07:01.484 Status: dzVents: > name: "rainofmonthly"
2019-10-16 16:07:01.484 Status: dzVents: > 24:
2019-10-16 16:07:01.484 Status: dzVents: > value: "84.90"
2019-10-16 16:07:01.484 Status: dzVents: > name: "rainofyearly"
2019-10-16 16:07:01.484 Status: dzVents: > 25:
2019-10-16 16:07:01.484 Status: dzVents: > value: "591.00"
2019-10-16 16:07:01.484 Status: dzVents: > name: "Apply"
2019-10-16 16:07:01.484 Status: dzVents: > 26:
2019-10-16 16:07:01.484 Status: dzVents: > value: "Apply"
2019-10-16 16:07:01.484 Status: dzVents: > name: "Cancel"
2019-10-16 16:07:01.484 Status: dzVents: > 27:
2019-10-16 16:07:01.484 Status: dzVents: > value: "Cancel"
2019-10-16 16:07:01.484 Status: dzVents: > name: "rain_Default"
2019-10-16 16:07:01.484 Status: dzVents: > 28:
2019-10-16 16:07:01.484 Status: dzVents: > value: "Rain
2019-10-16 16:07:01.484 Status: dzVents: > 29:
2019-10-16 16:07:01.484 Status: dzVents: > value: "Refresh">
2019-10-16 16:07:01.484 Status: dzVents: > 30:
2019-10-16 16:07:01.484 Status: dzVents: > value: "Stop
2019-10-16 16:07:01.484 Status: dzVents: > 0:
2019-10-16 16:07:01.484 Status: dzVents: > name: "livedata"
2019-10-16 16:07:01.484 Status: dzVents: Info: ambiantWeather: ------ Finished ambiantWeather.lua 
Thank you
;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by waaren »

Doudy wrote: Wednesday 16 October 2019 15:25 Here are the infos requested :
The strings 'option value' in your httpResponse was causing the wrong values. It should work again if you replace the procesHTM() function with this one.

I also updated the version I posted Friday 06 September 2019 15:40 in this topic

Code: Select all

-- this function will process the HTML. It will create a table from the relevant data with names and values to update the devices
        local function processHTM()
            local shortFieldNames = {    
                                        inTemp="IndoorTemperature",
                                        inHumi="IndoorHumidity",
                                        AbsPress="Absolute Pressure",
                                        RelPress="Relative Pressure",
                                        outTemp="Outdoor Temperature",
                                        outHumi="Outdoor Humidity",
                                        windir="Winddirection",
                                        avgwind="Wind Speed",
                                        gustspeed="Wind Gust",
                                        --dailygust="Maxdaily Gust",
                                        solarrad="Solar Radiation",
                                        uv="UV",
                                        uvi="UVI", 
                                        --pm25="PM2.5", 
                                        rainofhourly="Hourly Rain Rate",
                                        --eventrain="Event Rain",
                                        rainofdaily="Daily Rain", 
                                        rainofweekly="Weekly Rain",
                                        rainofmonthly="Monthly Rain", 
                                        rainofyearly="Yearly Rain",
                                    }
            
            -- Prepare WSData (remove quotes, nullify option value, and make fieldName )
            WSData = (item.data):gsub('"',''):gsub("'",""):gsub("option value"," xx"):gsub("input name"," fieldName") 
            
            -- fill table with keys
            local lines = {}
            local linesIndex = 1
            for keyField in string.gmatch( WSData,"[^%s, ]+" ) do -- loop over all 'words' in thedata
                if string.find(keyField,'fieldName=') then -- if 'word' is like fieldName=text
                    lines[linesIndex] = {}
                    lines[linesIndex].name =  keyField:gsub('fieldName=','') -- put text into name field 
                    linesIndex = linesIndex + 1
                end
            end

            -- fill table with values
            linesIndex = 1
            for keyField in string.gmatch( WSData,"[^%s, ]+" ) do 
                if string.find(keyField,'value=') then -- if 'word' is like value=text / number
                    if lines[linesIndex] == nil then lines[linesIndex] = {} end
                    lines[linesIndex].value =  keyField:gsub('value=','') -- put text / number into corresponding value field 
                    linesIndex = linesIndex + 1
                end
            end
            
            -- fill table usedFields only with names and values we are going to use to fill devices
            local usedFields = {}            
            for linesIndex = 1, #lines - 1 do 
                if shortFieldNames[lines[linesIndex].name] ~= nil then
                    usedFields[shortFieldNames[lines[linesIndex].name]] = lines[linesIndex].value  
                end
            end
			return usedFields
        end

        
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by Doudy »

Thanks for update
How can I add other values?
For example :
Image

;) ;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by waaren »

Doudy wrote: Thursday 17 October 2019 9:26 How can I add other values?
Added this functionality for daily, weekly, monthly and yearly rain amounts. Are there other devices that need to be added ?

Updated script in my post of Friday 06 September 2019 15:40 in this topic
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by Doudy »

Hello,

I would like to understand!
How to update the values ​​of different devices in domoticz

Image

The values ​​are all in remarks

Code: Select all

        --local wind = dz.devices('AWindDir')
        --local insideTemperature = dz.devices('AinTemp')
        --local insideTemperatureHumidity = dz.devices('AinTempHum')
        --local outsideTemperature = dz.devices('AoutTemp')
        --local outsideTemperatureHumidity = dz.devices('AoutTempHum')
        --local solarRadiation = dz.devices('ASolarRad')
        --local uvIndex = dz.devices('AUvi')
        --local rain = dz.devices('ARain')
        --local barometer = dz.devices('ARelPress')
        --local dailyRain = dz.devices('ARainDaily')       
        --local weeklyRain = dz.devices('ARainWeekly')     
        --local monthlyRain = dz.devices('ARainMonthly')   
        --local yearlyRain = dz.devices('ARainYearly')   
;) ;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by waaren »

Doudy wrote: Thursday 17 October 2019 11:56 How to update the values ​​of different devices in domoticz
The values ​​are all in remarks
From the comments in the script:
-- Change devicenames below to reflect your names and uncomment the lines with the devices you defined.
-- You can also use idx but if you do, then don't use the surrounding quotes.

You can uncomment a line by removing the --

Also: you defined Daily-, Weekly-, Monthly- and YearlyRain as type Rain. The data from your weatherstation is not suited for this type of device.
That's why I asked in the script to define them as type Custom sensor and use mm for the x-as.

dailyRain Daily amount of rain in mm ( define as general Custom sensor with x-as mm )
weeklyRain Weekly amount of rain in mm ( define as general Custom sensor with x-as mm )
monthlyRain Monthly amount of rain in mm ( define as general Custom sensor with x-as mm )
yearlyRain Yearly amount of rain in mm ( define as general Custom sensor with x-as mm )
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by Doudy »

But when i looking with

Code: Select all

curl http://192.168.1.99/livedata.htm

I find a value for al this data (rainofdaily - rainofweekly - rainofmonthly - rainofyearly)

Code: Select all

                        <tr>
                            <td bgcolor="#EDEFEF"><div class="item_1">Daily Rain</div></td>
                            <td bgcolor="#EDEFEF"><input name="rainofdaily"  type="text" class="item_2" style="WIDTH: 80px" value="0.30" maxlength="8">
                        <span id="rainofdaily_msg" class="errMsg0"></span></td>
                        </tr>

                        <tr>
                            <td bgcolor="#EDEFEF"><div class="item_1">Weekly Rain</div></td>
                            <td bgcolor="#EDEFEF"><input name="rainofweekly" type="text" class="item_2" style="WIDTH: 80px" value="15.90" maxlength="8">
                         <span id="rainofweekly_msg" class="errMsg0"></span></td>
                        </tr>

                        <tr>
                            <td bgcolor="#EDEFEF"><div class="item_1">Monthly Rain</div></td>
                            <td bgcolor="#EDEFEF"><input name="rainofmonthly" type="text" class="item_2" style="WIDTH: 80px" value="96.60" maxlength="8">
                         <span id="rainofmonthly_msg" class="errMsg0"></span></td>
                        </tr>

                        <tr>
                            <td bgcolor="#EDEFEF"><div class="item_1">Yearly Rain</div></td>
                            <td bgcolor="#EDEFEF"><input name="rainofyearly" type="text" class="item_2" style="WIDTH: 80px" value="602.70" maxlength="8">
                         <span id="rainofyearly_msg" class="errMsg0"></span></td>
                        </tr>

The log file :

Code: Select all

 2019-10-17 13:48:01.295 Status: dzVents: Info: Handling httpResponse-events for: "ObserverIP_0.201910171000
2019-10-17 13:48:01.295 Status: dzVents: Info: ObserverIP_0.201910171000: ------ Start external script: ObserverIP-3.lua: HTTPResponse: "ObserverIP_0.201910171000"
2019-10-17 13:48:01.297 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AWindDir: Wind device adapter
2019-10-17 13:48:01.298 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AinTemp: Temperature device adapter
2019-10-17 13:48:01.299 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AinTempHum: Temperature+humidity device adapter
2019-10-17 13:48:01.299 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AoutTemp: Temperature device adapter
2019-10-17 13:48:01.300 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AoutTempHum: Temperature+humidity device adapter
2019-10-17 13:48:01.301 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ASolarRad: Solar radiation device adapter
2019-10-17 13:48:01.303 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AUvi: UV device adapter
2019-10-17 13:48:01.304 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ARain: Rain device
2019-10-17 13:48:01.307 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ARelPress: Barometer device adapter
2019-10-17 13:48:01.308 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ARainDaily: Rain device
2019-10-17 13:48:01.309 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ARainWeekly: Rain device
2019-10-17 13:48:01.310 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ARainMonthly: Rain device
2019-10-17 13:48:01.311 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ARainYearly: Rain device
2019-10-17 13:48:01.322 Status: dzVents: Error (2.4.19): ObserverIP_0.201910171000: Method updateCustomSensor is not available for device "ARainDaily" (deviceType=Rain, deviceSubType=TFA). If you believe this is not correct, please report.
2019-10-17 13:48:01.322 Status: dzVents: Error (2.4.19): ObserverIP_0.201910171000: Method updateCustomSensor is not available for device "ARainWeekly" (deviceType=Rain, deviceSubType=TFA). If you believe this is not correct, please report.
2019-10-17 13:48:01.322 Status: dzVents: Error (2.4.19): ObserverIP_0.201910171000: Method updateCustomSensor is not available for device "ARainMonthly" (deviceType=Rain, deviceSubType=TFA). If you believe this is not correct, please report.
2019-10-17 13:48:01.322 Status: dzVents: Error (2.4.19): ObserverIP_0.201910171000: Method updateCustomSensor is not available for device "ARainYearly" (deviceType=Rain, deviceSubType=TFA). If you believe this is not correct, please report.
2019-10-17 13:48:01.324 Status: dzVents: Info: ObserverIP_0.201910171000: ------ Finished ObserverIP-3.lua 

Code: Select all

 2019-10-17 13:50:02.136 Status: dzVents: Error (2.4.19): ObserverIP_0.201910171000: Method updateCustomSensor is not available for device "ARainDaily" (deviceType=Rain, deviceSubType=TFA). If you believe this is not correct, please report.
2019-10-17 13:50:02.136 Status: dzVents: Error (2.4.19): ObserverIP_0.201910171000: Method updateCustomSensor is not available for device "ARainWeekly" (deviceType=Rain, deviceSubType=TFA). If you believe this is not correct, please report.
2019-10-17 13:50:02.136 Status: dzVents: Error (2.4.19): ObserverIP_0.201910171000: Method updateCustomSensor is not available for device "ARainMonthly" (deviceType=Rain, deviceSubType=TFA). If you believe this is not correct, please report.
2019-10-17 13:50:02.136 Status: dzVents: Error (2.4.19): ObserverIP_0.201910171000: Method updateCustomSensor is not available for device "ARainYearly" (deviceType=Rain, deviceSubType=TFA). If you believe this is not correct, please report. 
:?: :?: :idea: :?: :?:
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by waaren »

Doudy wrote: Thursday 17 October 2019 13:46 But when i looking with

Code: Select all

curl http://192.168.1.99/livedata.htm

I find a value for al this data (rainofdaily - rainofweekly - rainofmonthly - rainofyearly)
I understand. The values you see are the total amounts of rain in mm. That is why the daily - weekly - monthly and yearly rain devices should be defined as type custom sensor with mm as x-as. NOT as type rain devices
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Get weather data from LAN based ObserverIP PWS

Post by Doudy »

It's going slowly
I have modified the rain devices at custom sensors
Image

But the values = 0 mm

I have following :

Code: Select all

	...
        local rain = dz.devices('ARain')
        local dailyRain = dz.devices('ARainDaily')       
        local weeklyRain = dz.devices('ARainWeekly')     
        local monthlyRain = dz.devices('ARainMonthly')   
        local yearlyRain = dz.devices('ARainYearly')   
        ...
 
and

Code: Select all

       local fieldNames = {    -- the commented fields are available in the html but not used in this script.
                                      ...
                                       
                                       ... 
                                        rainofhourly='hourlyRainRate',
                                        rainofdaily='dailyRain', 
                                        rainofweekly='weeklyRain',
                                        rainofmonthly='monthlyRain', 
                                        rainofyearly='yearlyRain',
                                    }

Log file :

Code: Select all

 2019-10-17 16:46:01.264 Status: dzVents: Info: Handling httpResponse-events for: "ObserverIP_0.201910171000
2019-10-17 16:46:01.264 Status: dzVents: Info: ObserverIP_0.201910171000: ------ Start external script: ObserverIP-3.lua: HTTPResponse: "ObserverIP_0.201910171000"
2019-10-17 16:46:01.268 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AWindDir: Wind device adapter
2019-10-17 16:46:01.272 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AvgWind: Wind device adapter
2019-10-17 16:46:01.275 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AGustSpeed: Wind device adapter
2019-10-17 16:46:01.277 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AinTemp: Temperature device adapter
2019-10-17 16:46:01.279 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AinTempHum: Temperature+humidity device adapter
2019-10-17 16:46:01.281 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AoutTemp: Temperature device adapter
2019-10-17 16:46:01.282 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AoutTempHum: Temperature+humidity device adapter
2019-10-17 16:46:01.284 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ASolarRad: Solar radiation device adapter
2019-10-17 16:46:01.286 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for AUvi: UV device adapter
2019-10-17 16:46:01.287 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ARain: Rain device
2019-10-17 16:46:01.289 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ARelPress: Barometer device adapter
2019-10-17 16:46:01.291 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ARainDaily: Custom sensor device adapter
2019-10-17 16:46:01.293 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ARainWeekly: Custom sensor device adapter
2019-10-17 16:46:01.294 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ARainMonthly: Custom sensor device adapter
2019-10-17 16:46:01.296 Status: dzVents: Debug: ObserverIP_0.201910171000: Processing device-adapter for ARainYearly: Custom sensor device adapter
2019-10-17 16:46:01.320 Status: dzVents: Info: ObserverIP_0.201910171000: ------ Finished ObserverIP-3.lua 
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest