http/https poller

Must be cleaned all topics go to the right subforum
Post Reply
Machielw
Posts: 15
Joined: Saturday 23 January 2016 12:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

http/https poller

Post by Machielw » Sunday 18 September 2016 14:18

Somebody knows how the http/https poller works? I cannot find a Wiki of anything.

I Would like to read my Enphase Solar with it, But I have not enought information on how the poller works

this Url:
http://IP/api/v1/production
gives this output:

{
"wattHoursToday": 8872,
"wattHoursSevenDays": 100888,
"wattHoursLifetime": 954584,
"wattsNow": 2199
}

mvzut
Posts: 296
Joined: Thursday 12 November 2015 11:55
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Marum, The Netherlands
Contact:

http/https poller

Post by mvzut » Sunday 18 September 2016 15:24

Machielw wrote:Somebody knows how the http/https poller works? I cannot find a Wiki of anything.

I Would like to read my Enphase Solar with it, But I have not enought information on how the poller works

this Url:
http://IP/api/v1/production
gives this output:

{
"wattHoursToday": 8872,
"wattHoursSevenDays": 100888,
"wattHoursLifetime": 954584,
"wattsNow": 2199
}
I also don't know exactly how the poller works, but I doubt if it will automatically do what you want.

If you want to process json data (which your device seems to produce) on a periodical basis, you'll probably have to write your own code for it. It's fairly easy to do with a time-based (lua) script containing a curl command followed by a json:decode and subsequent updating of some dummy devices. There are quite a few examples in this forum and on the wiki to help you get started. But it's not plug and play, if that's what you were hoping...
Raspberry Pi 2B - RFXtrx433 - Aeon Z-Stick gen5 - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - Sonos Connect & PLAY:1 - Kodi - Wall mounted tablet + Imperihome - MANY switches/sensors

pj-r
Posts: 245
Joined: Wednesday 17 December 2014 18:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: http/https poller

Post by pj-r » Monday 19 September 2016 11:59

LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors

mvzut
Posts: 296
Joined: Thursday 12 November 2015 11:55
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Marum, The Netherlands
Contact:

http/https poller

Post by mvzut » Monday 19 September 2016 23:16

Ah, nice to see an example of how the poller works. Even (slightly) simpler than writing a full script including the curl and json:decode parts.

Maybe a bit off-topic, but what I wonder is: what if you would have more of these pollers running? Which data will s = request['content'] then contain?
Raspberry Pi 2B - RFXtrx433 - Aeon Z-Stick gen5 - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - Sonos Connect & PLAY:1 - Kodi - Wall mounted tablet + Imperihome - MANY switches/sensors

pj-r
Posts: 245
Joined: Wednesday 17 December 2014 18:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: http/https poller

Post by pj-r » Thursday 22 September 2016 8:11

mvzut wrote:Maybe a bit off-topic, but what I wonder is: what if you would have more of these pollers running? Which data will s = request['content'] then contain?
Take a look at this: https://github.com/domoticz/domoticz/pull/626
HTTP/HTTPS client with several parameters: url, login, password, refresh rate and script name (command).
So it looks like you can define what script you want to use for parsing the data.

And for reference of rest of reading this thread:
  • - scripts folder for parsers is: scripts/lua_parsers/
    - in command parameter it looks like you have provide full name of the script. for example: example_xml.lua
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors

mvzut
Posts: 296
Joined: Thursday 12 November 2015 11:55
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Marum, The Netherlands
Contact:

http/https poller

Post by mvzut » Thursday 22 September 2016 8:57

pj-r wrote:
mvzut wrote:Maybe a bit off-topic, but what I wonder is: what if you would have more of these pollers running? Which data will s = request['content'] then contain?
Take a look at this: https://github.com/domoticz/domoticz/pull/626
HTTP/HTTPS client with several parameters: url, login, password, refresh rate and script name (command).
So it looks like you can define what script you want to use for parsing the data.

And for reference of rest of reading this thread:
  • - scripts folder for parsers is: scripts/lua_parsers/
    - in command parameter it looks like you have provide full name of the script. for example: example_xml.lua
Ah, I read that but couldn't find the field for script name. Now I see this is apparently what the "Command" field is intended for. Initially I assumed that the url field should only contain the address, and the command field should contain the /json?... etc. part. of the url. Assumptions... (are...)

Still don't completely see the advantage over creating a normal time script and adding a few curl and json:decode lines in the top. But maybe that's just me.
Raspberry Pi 2B - RFXtrx433 - Aeon Z-Stick gen5 - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - Sonos Connect & PLAY:1 - Kodi - Wall mounted tablet + Imperihome - MANY switches/sensors

pj-r
Posts: 245
Joined: Wednesday 17 December 2014 18:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: http/https poller

Post by pj-r » Thursday 22 September 2016 15:37

As I know normal time script runs on main thread and domoticz wont do anything else while the script is running. Poller runs on separate thread so the http call wont block whole domoticz.
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors

Machielw
Posts: 15
Joined: Saturday 23 January 2016 12:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: http/https poller

Post by Machielw » Friday 23 September 2016 18:01

who can help me then? What is wrong?

And thanks for help above!

link in poller:
Output link:
{
"wattHoursToday": 14566,
"wattHoursSevenDays": 84452,
"wattHoursLifetime": 1022584,
"wattsNow": 2277
}
Lua: test_json.lua in scripts/lua_parsers

script:
-- Retrieve the request content
s = request['content'];

-- Update some devices (index are here for this example)
local id = 113
local s = domoticz_applyJsonPath(s,'.wattHoursToday')
domoticz_updateDevice(id,'',s)

Output in log:
2016-09-23 17:58:26.069 CLuaHandler (updateDevice from LUA) : idx=113 nvalue= svalue=16661 invalue=0 signallevel=12 batterylevel=255
Virtual device idx=113 is not updated. (http poller = hardware id =7)

any help would be appreciated!

farhanito
Posts: 32
Joined: Friday 19 August 2016 5:39
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: http/https poller

Post by farhanito » Thursday 29 September 2016 18:33

Machielw wrote:who can help me then? What is wrong?

Output in log:
2016-09-23 17:58:26.069 CLuaHandler (updateDevice from LUA) : idx=113 nvalue= svalue=16661 invalue=0 signallevel=12 batterylevel=255
Virtual device idx=113 is not updated. (http poller = hardware id =7)

any help would be appreciated!
any update on this?
i have the same issue... the device isn't updating.

pj-r
Posts: 245
Joined: Wednesday 17 December 2014 18:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: http/https poller

Post by pj-r » Friday 30 September 2016 13:13

Does it work if instead of

Code: Select all

domoticz_updateDevice(id,'',s)
you try json api?

Code: Select all

os.execute('curl http://localhost/json.htm?type=command&param=udevice&idx='..id..'&nvalue=0&svalue='..s')
https://www.domoticz.com/wiki/Domoticz_ ... counter.29

Its not the best way but might work :lol:
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors

farhanito
Posts: 32
Joined: Friday 19 August 2016 5:39
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: http/https poller

Post by farhanito » Saturday 01 October 2016 19:18

pj-r wrote: you try json api?

Code: Select all

os.execute('curl http://localhost/json.htm?type=command&param=udevice&idx='..id..'&nvalue=0&svalue='..s')
https://www.domoticz.com/wiki/Domoticz_ ... counter.29

Its not the best way but might work :lol:
took me a while to get this to work.
really confusing at first. the URL works with browser, but not with curl.
finally found out that i need to quote the URL to get curl to work..

so, my line is..

Code: Select all

os.execute('curl "http://localhost/json.htm?type=command&param=udevice&idx='..id..'&nvalue=0&svalue='..s..'"')
thanks for the pointer

Zinken
Posts: 9
Joined: Thursday 22 September 2016 8:00
Target OS: Raspberry Pi
Domoticz version: Stable
Contact:

Re: http/https poller

Post by Zinken » Thursday 13 October 2016 18:55

Maybe I'm not understanding but where is the http poller? Shouldn't I start with adding a hardware device?

Or is or only available in beta release?

Sent from my MI 5 using Tapatalk 2

Machielw
Posts: 15
Joined: Saturday 23 January 2016 12:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: http/https poller

Post by Machielw » Thursday 20 October 2016 21:44

It is working with Enphase Envoy this way: (I hope if production starts again tomorrow)

Code: Select all

-- Retrieve the request content
s = request['content'];
local id = 14
local wattHoursToday = domoticz_applyJsonPath(s,'.wattHoursToday')
local wattsNow = domoticz_applyJsonPath(s,'.wattsNow')
local wattHoursLifetime = domoticz_applyJsonPath(s,'.wattHoursLifetime')

domoticz_updateDevice(id,'',wattsNow .. ";" .. wattHoursLifetime)
I used the Virtual Teller / Counter device. Generation today I could not use from the enphase, since it is not in the virtual device.
I hope the wattsHourToday will be calculated by domoticz tomorrow (dark now, so no production),

@Zinken: you need the latest beta: (domoticz_updateDevice is fixed there, thanks to FrBoulli and gizmocuz )
https://github.com/domoticz/domoticz/issues/924

User avatar
Veikko
Posts: 5
Joined: Tuesday 20 December 2016 4:00
Target OS: Raspberry Pi
Domoticz version: V3.5877
Contact:

Re: http/https poller

Post by Veikko » Thursday 05 January 2017 22:00

Hi! I have a very easy solution going to url and will get one number.
I need to insert this value to domotics so I could see this under some device.
What I am talking about is energy price on the market.

Could somebody help me?
Dr. Lanning: "One day they'll have secrets, one day they'll have dreams..."

teo1966
Posts: 2
Joined: Saturday 18 November 2017 13:09
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: http/https poller

Post by teo1966 » Monday 04 December 2017 22:39

i have this output


"wattHoursToday": 3,
"wattHoursSevenDays": 21,
"wattHoursLifetime": 80940,
"wattsNow": 0

teo1966
Posts: 2
Joined: Saturday 18 November 2017 13:09
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: http/https poller

Post by teo1966 » Tuesday 05 December 2017 21:39

i have here info over enphase https://thecomputerperson.wordpress.com ... -scraping/

here from this site

I’ve recently had to interface with an EnPhase Envoy Solar PV system. The annoying thing is the lack of documentation.

The API for the “cloud service” exists and is well documented but the API for the local device itself doesn’t seem to exist.

There is one tiny one page document that seems to suggest you can get some data from the device. The information gleaned from their example API ” http://device.ip.address.here/api/v1/production ” is poor.

First.. it gives far LESS information than you can just retrieve from the main web page for the device on the LAN. Secondly the wattsNow field doesn’t seem to match the information displayed on the main page of the device. The wattsHoursSevenDays is also slightly off. Third.. it doesn’t even update regularly. You can’t have a system that detects dips in production due to cloud cover etc.

However. I did find some other sensible sources for information – and information that updates at an even more regular rate than the devices main website!

When you visit the site on the device running firmware D4.2.27 it makes the following requests:

http://10.0.0.177/backbone/application. ... n=04.02.43
This URL contains a lot of references to other json files that I need to research. See further down in this post for the other URLs exposed.

http://10.0.0.177/home.json
This json file contains the Database size / utilisation, date and time on the device, connection status and settings and update status.

http://10.0.0.177/production.json
Contains most useful information.. Production and (if fitted) consumption data!

http://10.0.0.177/inventory.json
Also contains some very useful information. Detailed status about the state of each micro-inverter. So far I’ve seen the following states:

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest