Page 1 of 1

Poller to ID

Posted: Sunday 26 November 2023 21:24
by vespino
I never noticed the “http poller” before and I was wondering if it might be a good idea to directly set a value of a device with the value found in the url instead of using a LUA script. Just a thought.

Re: Poller to ID

Posted: Monday 27 November 2023 8:53
by waltervl
Yes that is very well possible altough if your current lua scripts runs why change?
Only if the http call is slow it will not stall the event system-when using HTTP Poller as it is in a separate system.
But you could also use the async openURL function in DzVents for this.

Re: Poller to ID

Posted: Monday 27 November 2023 10:42
by vespino
I’m not using LUA at the moment, I’m updating using the API which works, but if I can use what’s built in…

Re: Poller to ID

Posted: Monday 27 November 2023 10:47
by waltervl
Yes, then start with the http poller.
But only if your device website is showing CSV, JSON or XML data. Else you will have to do some extra scraping.

https://www.domoticz.com/wiki/HTTP/HTTPS_poller

Re: Poller to ID

Posted: Monday 27 November 2023 16:02
by vespino
But my point is: I would like to NOT use LUA and simply import the URL output in a device specified with an ID. This is currently not possible if I read the documentation correctly.

Re: Poller to ID

Posted: Monday 27 November 2023 16:31
by waltervl
That is not how it works, see the Wiki.

It is a plugin or an integration that already connects to the website.
Or the HTTP Poller (with a small Lua script), a separate eventscript (Lua, dzvents, python) or some script outside Domoticz that updates a Dummy device with API calls.

Re: Poller to ID

Posted: Monday 27 November 2023 17:30
by willemd
vespino wrote: Monday 27 November 2023 16:02 But my point is: I would like to NOT use LUA and simply import the URL output in a device specified with an ID. This is currently not possible if I read the documentation correctly.
The lua script needed for the http poller is required but very simple.
It only does the mapping from a field in the API output to a device. Example for a kWh meter below receiving two values below.

Code: Select all

-- Read API output
s = request['content'];

-- Extract the values
local a = domoticz_applyJsonPath(s,'.total_power_export_t1_kwh')
local b = domoticz_applyJsonPath(s,'.active_power_w')

-- Post values onto the device
local idxkWh = 3
domoticz_updateDevice(idxkWh,'',-1*b ..";".. a*1000 )


Re: Poller to ID

Posted: Monday 27 November 2023 18:11
by vespino
I know it’s very simple, but my thought was it could be even easier and was meant as feature request. I posted on GitHub, but they told me to post it here.

Re: Poller to ID

Posted: Monday 27 November 2023 18:46
by waltervl
If it was meant as a enhancement request I would have no idea how somebody could implement this without a serious complex configuration interface.

Every website is different, so a lot of settings to think of to support all possible possibilities.

The current implementation with a small script seems to be the best possible way.

Re: Poller to ID

Posted: Monday 27 November 2023 20:18
by vespino
The output value gotten from the URL could only be txt I guess. But I understand this could give difficulties with elaborate devices. I will look into LUA then to keep things centralized and less depended on the API… or maybe not change a thing.