Page 5 of 5

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 October 2020 13:55
by Doudy
Hello,

I have the following error in my log.file

Code: Select all

2020-10-22 12:39:16.885 Error: dzVents: Error: (3.0.2) ObserverIP_0.201911091100: An error occurred when calling event handler ObserverIP-99
2020-10-22 12:39:16.885 Error: dzVents: Error: (3.0.2) ObserverIP_0.201911091100: /home/pi/domoticz/scripts/dzVents/scripts/ObserverIP-99.lua:229: attempt to compare nil with number
Can you help me ?
Thant is le line :

Code: Select all

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

Thanks
;)

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 October 2020 14:15
by waaren
Doudy wrote: Thursday 22 October 2020 13:55 I have the following error
Can you replace lines 226-233 with below function? It will not solve the issue but will probably show enough extra information to identify it.

Code: Select all

local function humidityStatus(temperature, humidity) -- as used in domoticz source
    dz.log('temperature: ' .. tostring(temperature),dz.LOG_FORCE)
    dz.log('humidity: ' .. tostring(humidity),dz.LOG_FORCE)
    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


Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 October 2020 14:17
by eddieb
Looks like humidity is not present
(perhaps other version of observerip ?)

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 October 2020 14:39
by Doudy

Code: Select all

local scriptVersion = '0.201911091100'

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 October 2020 14:40
by eddieb
What version are you running on the ObserverIP ?

I am at "AmbientWeather 4.5.7" and that works

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 October 2020 16:20
by Doudy
I find this

Code: Select all

this dzVents script is used to collect data from ObserverIP weatherstation with software version 4.5.7. (weatherlogger 2.2.2.)
;)

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 October 2020 16:28
by eddieb
I was not asking about the version of the script but the version that is running on you observerip hardware ...

mine is :
Screenshot 2020-10-22 at 16.26.29.png
Screenshot 2020-10-22 at 16.26.29.png (99.76 KiB) Viewed 1130 times
go with your browser to the IP of you observerip and look at the header presented.

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 October 2020 17:17
by Doudy
This is mine

Image

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 October 2020 17:23
by eddieb
Ah, that seems to be the original software.
It might be that the dzevents script is not 100% compatible with that.
You need to grep the /livedata.htm page from you device and send it tot @waaren in a pm or so.
He might be able to adjust the script so that it works with your version too.

On the onther hand, you might also want to flash your observerip with newer firmware like mine ...

on https://www.ambientweather.com/observerip.html you will find the tools
on https://help.ambientweather.net/help/ob ... re-update/ you will find the latest firmware.

if you need older versions, pm me ..

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 October 2020 17:29
by Doudy
;)
Thanks for the information

Re: Get weather data from LAN based ObserverIP PWS

Posted: Saturday 17 February 2024 17:30
by Doudy
Hello,

A little problem.
I created two virtual switches

Code: Select all

Name = inTempHum and outTempHum
Type : Temp + Humidity
SubType : "THGN122/123/132, THGR122/228/238/268"
But it shows me the following message:

Code: Select all

2024-02-17 17:14:01.288 Status: Warning: Expecting svalue with at least 2 elements separated by semicolon, 0 elements received (""), notification not sent (Hardware: 3 - Virtuel, ID: 82184, Unit: 1, Type: 52 - Temp + Humidity, SubType: 1 - THGN122/123/132, THGR122/228/238/268)
2024-02-17 17:14:01.312 Status: Warning: Expecting svalue with at least 2 elements separated by semicolon, 0 elements received (""), notification not sent (Hardware: 3 - Virtuel, ID: 82186, Unit: 1, Type: 52 - Temp + Humidity, SubType: 1 - THGN122/123/132, THGR122/228/238/268)
An idea ?
Script version = '0.201911091100'
;)

Re: Get weather data from LAN based ObserverIP PWS

Posted: Tuesday 20 February 2024 11:21
by Doudy
I have another problem
Every 10 minutes I receive the following message!
Why this message?
Why every 10'?

Code: Select all

2024-02-20 08:56:53.151 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 08:56:53.634 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 08:56:53.655 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 09:06:53.707 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 09:06:54.209 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 09:06:54.230 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 09:16:54.301 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 09:16:54.835 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 09:16:54.858 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 09:26:54.985 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 09:26:55.501 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 09:26:55.522 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 09:36:55.581 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 09:36:56.084 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 09:36:56.111 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 09:46:56.157 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 09:46:56.663 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 09:46:56.685 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 09:56:56.687 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 09:56:57.163 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 09:56:57.187 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 10:06:58.095 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 10:06:58.560 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 10:06:58.580 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 10:16:58.646 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 10:16:59.101 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 10:16:59.125 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 10:26:59.172 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 10:26:59.671 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 10:26:59.696 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 10:36:59.741 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 10:37:00.263 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 10:37:00.286 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 10:47:01.089 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 10:47:02.024 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 10:47:02.053 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 10:57:01.818 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 10:57:03.279 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 10:57:03.301 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 11:07:03.293 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 11:07:03.633 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 11:07:03.655 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
2024-02-20 11:17:03.967 Error: Error opening url: http://192.168.129.99/livedata.htm
2024-02-20 11:17:04.441 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: HTTP/1.1 response: 56 ==>> Failure when receiving data from the peer
2024-02-20 11:17:04.464 Error: dzVents: Error: (3.1.8) ObserverIP_0.20240214: Could not get (good) data from 192.168.129.99
An idea ?
;)

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 February 2024 8:23
by eddieb
I experienced that the internal webserver of the PWS is not that stable.
If you hit it to often it suffers some kind of memory leak and slows down until no reaction at all
To prevent that I reboot my ObserverIP every night by putting it behind a wifi switch ...

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 February 2024 8:47
by Doudy
eddieb wrote: Thursday 22 February 2024 8:23 To prevent that I reboot my ObserverIP every night by putting it behind a wifi switch ...
Thank you for the info.
And how do you do this?

;)

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 February 2024 9:41
by eddieb
I send an OFF-sleep5-ON sequence to the switch ...

Re: Get weather data from LAN based ObserverIP PWS

Posted: Thursday 22 February 2024 11:04
by Doudy
eddieb wrote: Thursday 22 February 2024 9:41 I send an OFF-sleep5-ON sequence to the switch ...
OK

Re: Get weather data from LAN based ObserverIP PWS

Posted: Saturday 24 February 2024 10:48
by Doudy
Hello,
I tested your suggestion, but I still get the same messages, every 10'
;)

Re: Get weather data from LAN based ObserverIP PWS

Posted: Sunday 25 February 2024 14:35
by Doudy
I continued searching and found this with the executeShellCommand command on the following site:

https://easydomoticz.com/forum/viewtopi ... ug#p116809

I adapted this:

Code: Select all

        local function getWeatherStationData()
			local url = 'http://' .. weatherStationIP .. '/livedata.htm'
			dz.executeShellCommand({command = 'url', callback = 'scriptVar',})
and

Code: Select all

			
			if item.isTimer or item.isDevice then
				checkWebpageResponse()
				getWeatherStationData()
			elseif item.isShellCommandResponse then				
				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

I no longer have an error message, but my data is no longer updating : updateDevices(processHTM(item.data))
I think it's processHTM(item.data) but I'm not sure

;)

Re: Get weather data from LAN based ObserverIP PWS

Posted: Monday 26 February 2024 9:36
by waltervl
Then yoo need to add some extra dz log to see what is called.
Could also be related to ShellCommandResponse. That needs to be unique and so not be 'scriptVar'

See also https://www.domoticz.com/wiki/DzVents:_ ... tion_3.1.0

Re: Get weather data from LAN based ObserverIP PWS

Posted: Monday 26 February 2024 14:58
by Doudy
Hello,
Thank you for the info.
I don't understand the meaning of the explanation.
Not being a computer scientist!
I integrated into the script
print('******************* > 0000000')
print('******************* > 1111111')
print('******************* > 2222222')
print('******************* > 3333333')
print('******************* > 4444444')
print('******************* > 5555555')
print('******************* > 6666666')

So that you can follow the progress of the script.
This seems to be going well but after 6666666 no Data !
The script below :

Code: Select all

local scriptVersion = '0.201911091100'
--local scriptVersion = '0.20240214'								  
local scriptVar  =  'ObserverIP_' .. scriptVersion
local dz = domoticz

--[[ 
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 )
        WindSpeed      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.
https://www.domoticz.com/forum/viewtopic.php?f=59&t=29187&sid=c20b8f82db6a08fe4e31041582b54ba5
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) 
20240214 Adaptation perso
]]--

return
{

	active = true,
	on = 
	--off=
    { 
        devices = {'WH2600-2-Wind', 'WH2600-2-Solar Radiation', 'WH2600-2-Outdoor', 'WH2600-2-UV', 'WH2600-2-Rain' }, -- Script can be triggered by a device  
        --timer = { 'every 5 minutes' }, -- or by a timer-rule
        timer = { 'every 1 minutes' }, -- 
        shellCommandResponses = {scriptVar},  -- do not change this
    },

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

    data = 
    { 
        rainTotal = { initial = 0 },
        previousRainSample = { initial = 0 },
    },
	
    execute = function(dz, item)
        print("======================================================================================== > OberveIP-99.lua")
		-- ********** local settings below this line *************
        -- change to IP of your weatherstation
        local weatherStationIP = '192.168.129.99' 

        -- 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 internalBatteryStatus = dz.devices('LD-Batterie-In')
		dz.devices('LD-Batterie-In').updateText(dz.devices('LD-Batterie-In'))
        local outdoorBatteryStatus1 = dz.devices('LD-Batterie-Out')
		dz.devices('LD-Batterie-Out').updateText(dz.devices('LD-Batterie-Out'))
        local windDirection = dz.devices('LD-WindDir')
        local insideTemperature = dz.devices('LD-inTemp')
        local insideTemperatureHumidity = dz.devices('LD-inTempHum')
        local outsideTemperature = dz.devices('LD-outTemp')
        local outsideTemperatureHumidity = dz.devices('LD-outTempHum')
        local solarRadiation = dz.devices('LD-SolarRad')
        local uv = dz.devices('LD-UV')
	local uvIndex = dz.devices('LD-Uvi')
        local rain = dz.devices('LD-Rain')
        local barometer = dz.devices('LD-RelPress')
	local barometerA = dz.devices('LD-AbsolutePress')
        local dailyRain = dz.devices('LD-RainDaily')       
        local weeklyRain = dz.devices('LD-RainWeekly')     
        local monthlyRain = dz.devices('LD-RainMonthly')   
        local yearlyRain = dz.devices('LD-RainYearly')   
        local gustSpeed = dz.devices('LD-GustSpeed')
        --local windir = dz.devices('LD-WindDir')
	local windSpeed = dz.devices('LD-WindSpeed')
        
        -- ********** 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.executeShellCommand({command = 'url', callback = scriptVar,})
			print("************************************************** > 5555555555555555555")
		   
	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',
                                        windspeed='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
			print("************************************************** > 666666666666666")
			dz.log ("!!: " .. item.statusCode, dz.LOG_INFO)
			dz.log ("Data: " .. item.data, dz.LOG_INFO)
			
            local function windDirectionName(degrees) -- do not translate as domoticz web GUI depends on strings like E or S 
				print("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD")
				print("degrees = "..degrees)
				print("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD")
                degrees = tonumber(degrees) % 360 -- Ensure between 0 and 360
				print("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD")
				print("degrees = "..degrees)
				print("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD")
                local windDirections =
                    {
						N={0,1},
						NNE={1,22.5}, -- 337,5- 360 will be catched later 
						NE={22.5,45},
						ENE={45,67.5},
						E={67.5,90},
						ESE={90,112.5},
						SE={112.5,135},
						SSE={135,157.5},
						S={157.5,180},
						SSO={180,202.5},
						SO={202.5,225},
						OSO={225,247,5},
						O={247.5,270},
						ONO={270,292.5},
						NO={292.5,315},
						NNO={315,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 == nil then return nil end -- Should not happen
				if temperature == nil then return nil end -- Should not happen                
                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 == nil then return nil end -- Should not happen
                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 
                if rainRate ~= nil then 
					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	
            end   

            -- update weatherDevices/ See dzVents wiki (https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting) for required parms of the update functions 
            wind = tonumber(wind)
			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

			--print("uv : " ..UV)
            if uv ~= nil then uv.updateUV(fields.UV) end

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

            if barometer ~= nil then barometer.updateBarometer
            (
                fields.relativePressure,
                BarometerForecast(fields.relativePressure)
            ) end

            if barometerA ~= nil then barometerA.updateBarometer
            (
                fields.absolutePressure,
                BarometerForecast(fields.absolutePressure)
            ) 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 windSpeed ~= nil then windSpeed.updateCustomSensor(fields.windSpeed) end
            
        end

       -- main 
	   
	    --if (item.isShellCommandResponse) then
			if item.isTimer or item.isDevice then
				print("************************************************** > 00000000000000")
				--if (item.ok) then
				checkWebpageResponse()
				print("************************************************** > 111111111111111")
				getWeatherStationData()
			elseif item.isShellCommandResponse then				
				dz.log ("!!: " .. item.statusCode, dz.LOG_INFO)		
				--dz.log ("Response object: " .. item.data, dz.LOG_INFO)				
				print("************************************************** > 333333333333333")
				updateDevices(processHTM(item.data))
				print("************************************************** > 444444444444444")
			else
				print("************************************************** > 777777777777777")
				dz.log('Could not get (good) data from ' .. weatherStationIP,dz.LOG_ERROR)
				dz.log(item.data,dz.LOG_DEBUG)			
			end

        print("======================================================================================== > OberveIP-99.lua")
    end
}
But local functions not printed !
See extract from my log below:

Code: Select all

2024-02-26 14:53:00.485 Status: dzVents: ======================================================================================== > OberveIP-99.lua
2024-02-26 14:53:00.486 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-Batterie-In: Text device
2024-02-26 14:53:00.488 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-Batterie-Out: Text device
2024-02-26 14:53:00.489 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-WindDir: Wind device adapter
2024-02-26 14:53:00.490 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-inTemp: Temperature device adapter
2024-02-26 14:53:00.491 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-inTempHum: Temperature+humidity device adapter
2024-02-26 14:53:00.492 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-outTemp: Temperature device adapter
2024-02-26 14:53:00.494 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-outTempHum: Temperature+humidity device adapter
2024-02-26 14:53:00.495 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-SolarRad: Solar radiation device adapter
2024-02-26 14:53:00.496 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-UV: UV device adapter
2024-02-26 14:53:00.497 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-Uvi: UV device adapter
2024-02-26 14:53:00.499 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-Rain: Rain device
2024-02-26 14:53:00.500 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-RelPress: Barometer device adapter
2024-02-26 14:53:00.501 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-AbsolutePress: Barometer device adapter
2024-02-26 14:53:00.502 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-RainDaily: Custom sensor device adapter
2024-02-26 14:53:00.503 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-RainWeekly: Custom sensor device adapter
2024-02-26 14:53:00.504 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-RainMonthly: Custom sensor device adapter
2024-02-26 14:53:00.505 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-RainYearly: Custom sensor device adapter
2024-02-26 14:53:00.506 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-GustSpeed: Custom sensor device adapter
2024-02-26 14:53:00.507 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-WindSpeed: Custom sensor device adapter
2024-02-26 14:53:00.508 Status: dzVents: ************************************************** > 00000000000000
2024-02-26 14:53:00.508 Status: dzVents: ************************************************** > 111111111111111
2024-02-26 14:53:00.508 Status: dzVents: Debug: ObserverIP_0.201911091100: ExecuteShellCommand: command = url
2024-02-26 14:53:00.508 Status: dzVents: Debug: ObserverIP_0.201911091100: ExecuteShellCommand: callback = ObserverIP_0.201911091100
2024-02-26 14:53:00.508 Status: dzVents: Debug: ObserverIP_0.201911091100: ExecuteShellCommand: timeout = nil
2024-02-26 14:53:00.508 Status: dzVents: Debug: ObserverIP_0.201911091100: ExecuteShellcommand: path = /home/pi/domoticz/scripts/dzVents/data/
2024-02-26 14:53:00.508 Status: dzVents: ************************************************** > 5555555555555555555
2024-02-26 14:53:00.508 Status: dzVents: ======================================================================================== > OberveIP-99.lua
2024-02-26 14:53:00.509 Status: dzVents: Info: ObserverIP_0.201911091100: ------ Finished observer-2.lua


2024-02-26 14:54:00.509 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2024-02-26 14:54:00.612 Status: LUA: Security based event fired
2024-02-26 14:54:00.713 Status: dzVents: Info: Handling shellcommandResponse-events for: "ObserverIP_0.201911091100"
2024-02-26 14:54:00.713 Status: dzVents: Info: ObserverIP_0.201911091100: ------ Start external script: observer-2.lua: ShellCommandResponse: "ObserverIP_0.201911091100"
2024-02-26 14:54:00.714 Status: dzVents: ======================================================================================== > OberveIP-99.lua
2024-02-26 14:53:00.722 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-WindDir: Wind device adapter
2024-02-26 14:53:00.723 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-inTemp: Temperature device adapter
2024-02-26 14:53:00.724 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-inTempHum: Temperature+humidity device adapter
2024-02-26 14:53:00.725 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-outTemp: Temperature device adapter
2024-02-26 14:53:00.726 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-outTempHum: Temperature+humidity device adapter
2024-02-26 14:53:00.727 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-SolarRad: Solar radiation device adapter
2024-02-26 14:53:00.728 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-UV: UV device adapter
2024-02-26 14:53:00.730 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-Uvi: UV device adapter
2024-02-26 14:53:00.731 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-Rain: Rain device
2024-02-26 14:53:00.732 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-RelPress: Barometer device adapter
2024-02-26 14:53:00.733 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-AbsolutePress: Barometer device adapter
2024-02-26 14:53:00.734 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-RainDaily: Custom sensor device adapter
2024-02-26 14:53:00.735 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-RainWeekly: Custom sensor device adapter
2024-02-26 14:53:00.736 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-RainMonthly: Custom sensor device adapter
2024-02-26 14:53:00.738 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-RainYearly: Custom sensor device adapter
2024-02-26 14:53:00.739 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-GustSpeed: Custom sensor device adapter
2024-02-26 14:53:00.741 Status: dzVents: Debug: ObserverIP_0.201911091100: Processing device-adapter for LD-WindSpeed: Custom sensor device adapter
2024-02-26 14:53:00.741 Status: dzVents: Info: ObserverIP_0.201911091100: !!: 127
2024-02-26 14:53:00.741 Status: dzVents: ************************************************** > 333333333333333
2024-02-26 14:53:00.741 Status: dzVents: ************************************************** > 666666666666666
2024-02-26 14:53:00.741 Status: dzVents: Info: ObserverIP_0.201911091100: !!: 127
2024-02-26 14:53:00.741 Status: dzVents: Info: ObserverIP_0.201911091100: Data:
2024-02-26 14:53:00.742 Status: dzVents: ************************************************** > 444444444444444
2024-02-26 14:53:00.742 Status: dzVents: ======================================================================================== > OberveIP-99.lua
2024-02-26 14:53:00.743 Status: dzVents: Info: ObserverIP_0.201911091100: ------ Finished observer-2.lua

:?