GivEnergy API Call into Home Assistant - Fully working

26 comments started 2022-02-08 last 2022-02-14
APIsHome AutomationHome AssistantNodeRed
S
#1 Simon

Hi all,

There has been a few asks on this forum about home displays and integration of the API's into Home Assistant (Hassio) or other automation tools.

Initially I worked with with @simon_swinburne and I have been improving his read only flows for Node-RED to accurately pull back the required information. The link below is to the flow that can be imported into Node-RED and this will automatically create new entities within Hassio with the required properties to use in the included Energy Card.

I have this fully working and with the exception of your Daily Standard charge, will give an accurate reading of all your daily consumption and and generation data.

Link is here: https://github.com/bankmil/GivEnergy_API_Node-RED

Help yourself and enjoy!

R
#2 rwbarrett

Simon Hi Ive just installed node red and the integration and after a few "bang head against desk" moments am nearly there but am getting the following error messages -
"8/02/2022, 20:04:37node: Make the Call
msg : error
"RequestError: getaddrinfo EAI_AGAIN undefinedbatterydata"
08/02/2022, 20:04:37node: GivEnergy_Battery_Voltage
msg : string[22]
"State must be defined."
08/02/2022, 20:04:37node: GivEnergy_Battery_Status
msg : string[22]
"State must be defined.""

Any idea what I've done wrong?

S
#3 Simon

rwbarrett

You need to click the little square to the left of step 1 and 2 to set the global properties.

R
#4 rwbarrett

have done that - have copied in my api key (does it matter if its from the original website or from the beta - have tried both) . Is teher anything to set in the step 2 other than click on the box?

S
#5 steve

@Simon Thanks for doing this work. I'm having a few issues too.

I got some errors initially which I resolved by adding: https://github.com/zachowj/hass-node-red

I've added my API key and clicked the boxes to inject them into the "change nodes"

The last errors from the debug are below:

08/02/2022, 22:35:29node: GivEnergy_Export_Energy_Total
msg : string[22]
"State must be defined."

08/02/2022, 22:50:10node: 2cab4860f31f6ba5
msg.payload : Object
{ timestamp: "2022-02-08T22:50:10.215+00:00", status: 500, error: "Internal Server Error", message: "API Key not found", path: "/plant/summary" }

Any suggestions please? Thanks

#6 hoggy

Not my flow/Github nor do I use NodeRed but does this use the "new" battery API by any chance?
If so (and given it seems to be throwing a wobbly about API keys) does this flow assume you've already done the api signup/key exchange already to generate a "new style" key or does it do this itself?

Edit - replicated the error in Postman by feeding the battery API the wrong key:
{
"timestamp": "2022-02-09T08:51:53.675+00:00",
"status": 500,
"error": "Internal Server Error",
"message": "API Key not found",
"path": "/plant/summary"
}

So guessing you need to link your OLD portal key to the new Battery API by following the steps under: " Binding API Key" here and then use the new key it returns.
You can do this in postman, cURL, whatever OR (not trying to hijack) I made some scripts & explanation on the custom dashboard thing or the custom app if your on Andoroid can do it

R
#7 rwbarrett

Thanks - will try this tonight - I knew I'd seen something about this on the Teams site or on this one but couldnt find it - will let you know if this resolves the error

Y
#8 yandards

Just spend the afternoon trying to get nodeRed installed on my NAS, seems that as I've installed it via Docker it won't run in supervisor mode and therefore won't let me into the add-on store to get any further.

Whilst I can manage a bit of code tweaking to suit local installs it seems like I need a new NAS so I can run HA in a VM instead so the add on store will work.

Can't even get the Duck DNS integration in this config...

A
#9 anglefire

yandards unless you need a new NAS I would go for another solution. The cost of a nas verses say a raspberry pi are quite a bit I would say. An rpi 4 and a ssd to boot from (sd cards are ok but have been known to fail due to the amount of data rewriting that is done) would be about £150 I guess.
Pulls a fair bit less power too.
Simple enough to install ha core in a docker and then everything else in dockers to go with it to make management easier (especially with portainer)

#10 hoggy

I bought a few of these when they were going for £9 a pop a few months back.
Not so cheap now but if you keep an eye out they pop up every now and then.
Run full windows and only 12cm square. Just need cheapo laptop ram, an old HDD, 12 volts and your away.

Y
#11 yandards

anglefire I've got spare SSDs kicking around, and I've looked at the Pi side of life, just trying to keep everything on one box really.

It's not a new NAS by any means (DS412+) and a decade old this year so it wouldn't hurt having a new one as it struggles a bit with the image processing side as the mobile phone photo backup etc.

A
#12 anglefire

Fair enough. I’ve got 3 nas drives at home. All qnap - a single drive, a double drive and a quad drive - though only 3 drives in that one - two In raid and the last one for the security camera.
But I have a lot of photographs in the main stored on there and don’t really want to run anything else.
Rpi’s are fairly cheap - I have 4 though only one has an ssd. The other 3 are just doing networking tasks so don’t have the data writing tasks that home assistant does with the logging it performs.

R
#13 rwbarrett

Thanks everyone - I had bound the api key using the PowerShell script and forgotten - as soon as I used the scripts to find the bound key and used this it all sprang to life - finally have my battery in my energy dashboard - thanks for the coding and all the help !

S
#14 steve

hoggy Thanks, that worked a charm. Flow now showing all green and pulling the data 😄

#15 hoggy

Yay I did a thing!

S
#16 steve

Looking to add these to my HA energy dashboard. Currently the flow queries are every 5 mins. Is there an "allowed" minimum time between api queries? Say 15 secs, would that flag any issues with Givenergy?

A
#17 anglefire

steve the upload from the inverter to the servers is 5minutes so any more often to pull it is not going to benefit you.
There will be official local communication fairly soon I would think - some of us have beta access to it and it’s still being worked on but is pretty reliable and pulls data roughly every 10seconds.

S
#18 steve

anglefire Thanks. Local poll at that frequency will be very welcome for the HA energy dashboard

A
#19 anglefire

steve actually the energy dashboard doesn’t update that quickly. I’ve not checked accurately but I get the impression it’s every 1/2 hour. Might be more often, but unless I look at my live data and the dashboard after the half hour break they are never the same.

C
#20 chris_p

This looks exciting, will have to have a crack at this when I've got a chunk of time spare - Thanks for the effort here!

G
#21 godfreym

The HA energy only updates once an hour on the hour.
The beauty of HA is of course that you can configure and display whatever data you want so long as you have a device for collecting the data.
So you can have your own custom dashboards updating graphs & gauges at 10 second interval for instance, mind you you database will increase in size rapidly.

A
#22 andrew_bond

godfreym Just to comment that I am using InfluxDB and have been logging every 10 seconds since last May - my database is only 92MB. (I believe Influx does space management to control this)

A
#23 anglefire

andrew_bond the other metric to know is how many “devices “ you are logging.
I’ve not looked at my db size yet. Hopefully will get chance to see over the weekend. Also how many sensors etc I'm logging.

A
#24 andrew_bond

anglefire Yup, fair point. I have one inverter, and I should also mention that I'm not using the Influx output distributed with GivTCP. I log 6 readings into the database: Inverter status, Battery power, Grid power, PV power, Load Power, SOC.

A
#25 anglefire

andrew_bond ah a fair bit less than me then! I log all the voltages and a fair bit of other stuff via node-red into home assistant.
I’ll look later to see how bit the db is.

Y
#26 yandards

Got myself a Pi and after a lot of mucking around with Postman to get the correct API code it's with no errors on the node red side of life.

Energy dashboard on HA hasn't updated the info as yet and I have 0kwh in the little flow diagram for the battery and PV. Using the myenegi side for the grid input and output totals as the poling rate is much faster.

I've noticed that the PV forecast function seems to be a lot closer than Solcast as you can add a seasonal damping factor to the PV.