Script Dzvents to read values from webpage [Solved]

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

Moderator: leecollings

Post Reply
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Script Dzvents to read values from webpage [Solved]

Post 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.
Last edited by javalin on Friday 04 February 2022 14:58, edited 1 time in total.
User avatar
waltervl
Posts: 5843
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Script Dzvents to read values from webpage

Post by waltervl »

I think the following topic should give you some hints. But I personally lack the knowledge. viewtopic.php?t=25321
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Script Dzvents to read values from webpage

Post 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.
User avatar
waltervl
Posts: 5843
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Script Dzvents to read values from webpage

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Script Dzvents to read values from webpage

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest