http/https poller

Moderator: leecollings

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

http/https poller

Post by Machielw »

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: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

http/https poller

Post by mvzut »

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 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
pj-r
Posts: 140
Joined: Wednesday 17 December 2014 17:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: http/https poller

Post by pj-r »

LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

http/https poller

Post by mvzut »

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 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
pj-r
Posts: 140
Joined: Wednesday 17 December 2014 17:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: http/https poller

Post by pj-r »

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: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

http/https poller

Post by mvzut »

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 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
pj-r
Posts: 140
Joined: Wednesday 17 December 2014 17:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: http/https poller

Post by pj-r »

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 11:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: http/https poller

Post by Machielw »

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: 34
Joined: Friday 19 August 2016 5:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: http/https poller

Post by farhanito »

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: 140
Joined: Wednesday 17 December 2014 17:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: http/https poller

Post by pj-r »

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: 34
Joined: Friday 19 August 2016 5:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: http/https poller

Post by farhanito »

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

Re: http/https poller

Post by Zinken »

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 11:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: http/https poller

Post by Machielw »

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: 4
Joined: Tuesday 20 December 2016 3:00
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.5877
Contact:

Re: http/https poller

Post by Veikko »

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: 35
Joined: Saturday 18 November 2017 12:09
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Contact:

Re: http/https poller

Post by teo1966 »

i have this output


"wattHoursToday": 3,
"wattHoursSevenDays": 21,
"wattHoursLifetime": 80940,
"wattsNow": 0
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
teo1966
Posts: 35
Joined: Saturday 18 November 2017 12:09
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Contact:

Re: http/https poller

Post by teo1966 »

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:
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
User avatar
groetg
Posts: 39
Joined: Tuesday 06 January 2015 20:41
Target OS: Raspberry Pi / ODroid
Domoticz version: V2.4025
Location: Heerhugowaard, Holland
Contact:

Re: http/https poller

Post by groetg »

There is a possibillity to add a Enphase hardware item in Dotmoticz, but with wich portnumber do I have to add this device? Already tried 80 and 8080, won't work. Making a script is to difficult for me.
enphase.PNG
enphase.PNG (16.09 KiB) Viewed 11865 times
Master: RPI Model 2B
Sub 1: RPI Model 2B
RFX transmitter/receiver 433 Mhz
13 KAKU units (3 window sensors, 1 door sensor, 7 light switches, 1 dusk sensor, 1 motion sensor)
4 IP cam
Meteostick
OTGW
P1 cable
Davis Vantage Pro weatherstation (incl. solar/UV)
peerke72
Posts: 13
Joined: Sunday 17 June 2018 17:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: http/https poller

Post by peerke72 »

I get 2 extra devices (apparaten) when I add the Envoy in the Hardware' section with port 80.

These devices show thetotal kWh production and the current W's for all solarpanels together.

I'm not sure if these are the only devices I should get or if there should also be devices for individual panels. There is a JSON call that shows the current W's for individual panels. It would be great when more detailed information becomes available in domoticz also.
Is there information/documentation about this domoticz hardware?

Btw, maybe you have to enable 'accept new hardware' in the settings temporary. Otherwise the device aren't added automatically.
Jumper3126
Posts: 105
Joined: Thursday 31 December 2015 15:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: http/https poller

Post by Jumper3126 »

I also have enphase converters underneath my solar panels. After installation I was disappointed of the lack of information that the app and website give, as there is no info on the production per individual panel. I think this info is only supplied to the installer account. I was able to get the password for it, but i dont think that the domoticz enphase hardware device is able to get the info per pannel.

I should however be possible to get it through via an events script, or HTTP/HTTPS poller. Perhaps someone already has got this up and running, otherwise I'll see if I can figure something out.
Jumper3126
Posts: 105
Joined: Thursday 31 December 2015 15:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: http/https poller

Post by Jumper3126 »

I'm able to update a virtual sensor with the http/https poller instructions of Machielw. But this is only the total production of all pannels.

The data per pannel is reachable through http://192.168.1.76/api/v1/production/inverters
However, you need to password of the installer account. Only if I login to http://192.168.1.76/installer/setup/home#overview, I can use http://192.168.1.76/api/v1/production/inverters, which than gives me:

Code: Select all

[
  {
    "serialNumber": "12180201xxxy",
    "lastReportDate": 1536516524,
    "devType": 1,
    "lastReportWatts": 0,
    "maxReportWatts": 257
  },
  {
    "serialNumber": "12180201xxxx",
    "lastReportDate": 1536516485,
    "devType": 1,
    "lastReportWatts": 0,
    "maxReportWatts": 264
  }
]
(deleted all but 2 pannels)

If I use http://192.168.1.76/api/v1/production for the URL in HTTP/HTTPS poller and the installer login and password, I keep on getting

Code: Select all

 Error: Http: Error getting data from url "http://192.168.1.76/api/v1/production/inverters"
I think this has to do with the accesibility and the login/password
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest