Page 1 of 1

Script Dzvents to read values from webpage [Solved]

Posted: Tuesday 01 February 2022 22:29
by javalin
Dear all,

I would like to get somes values from a weather station website and store these data into Domoticz.

The API request is :

Code: Select all

http://centronautico.cm-faro.pt/report.php
Lines 65 and 66 from html reponse are Wind Speed and Wind Gust:

Code: Select all

	
<td class="ws3">3</td>
<td class="ws3">5</td>	
Line 68 is Wind Direction:

Code: Select all

<img src="images/wd_SE.gif" alt="SE" /></td>
This is my code lines but, how I could read the html reponse to dump in dzvents?

Code: Select all

local scriptVar = 'getWidInfo'

return
{
    on =
    {

        timer =
        {
            'every minute',
        },

        httpResponses = 
        {
            scriptVar,
        },
    },

    logging = 
    {
        level = domoticz.LOG_DEBUG,
        marker = scriptVar,
    },

    execute = function(dz, item)
        if item.isTimer or item.isDevice then
            dz.openURL(
            {
                url = "http://centronautico.cm-faro.pt/report1.php",
                method = 'GET',
                callback = scriptVar,
            })
    elseif item.ok then -- statusCode == 2xx



    end
}
Thank you in advance.

Re: Script Dzvents to read values from webpage

Posted: Tuesday 01 February 2022 23:47
by waltervl
I think the following topic should give you some hints. But I personally lack the knowledge. viewtopic.php?t=25321

Re: Script Dzvents to read values from webpage

Posted: Wednesday 02 February 2022 22:18
by javalin
Thank you waltervl, I had tried to make the script with LUA following that post before create this one. I am not able to run socket.http after installed.

Re: Script Dzvents to read values from webpage

Posted: Wednesday 02 February 2022 23:43
by waltervl
Here is another scripts that goes through html data.
DzVents is build on Lua so native Lua functions will also work in DzVents..
https://domoticz.com/forum/viewtopic.ph ... 54#p223354

Re: Script Dzvents to read values from webpage

Posted: Friday 04 February 2022 14:57
by javalin
I have got to adapt the waaren script to extract the data from the weather station that I want. Thank you very much waltervl for your help and to waaren, wherever you are, a big hug.