Powerwall API help

I have built a collection of Open Energy Monitor products - emonpi, 2 x emontx v3, CTs, sensors, Openevse etc! And think it is all great!
I have followed the guides and Forum to set it all up for PV, EV, and all sorts of energy and temperature monitoring, including using Schedules (for Economy 7) and Post Processing. It all works very well - and all without delving into coding, scripts or github etc!!
I also have a Powerwall (on my same internal household network as the Emponpi) and I have discovered that I can access its State Of Charge by typing a line in my browser of - https://ipaddress of my powerwall/api/system_status/soe
This comes up with two tabs -
one labelled JSON and shows - percentage: 63.33 -
and one labelled Raw Data shows - {“percentage”:63.33} -
(The Powerwall’s current state of charge is 63%)
So my question is - can I relatively simply get the Emonpi to poll my network and provide an Emoncms Input of the Powerall state of charge - say every 10 seconds, such that I can use that Input in the normal way to make Feeds etc
Is there a line I can add to the EmonHub config file? Or do I need to place something on the EmonPi itself?
If it’s the latter I have worked out how to get on the Pi via SSH from my PC - but would need guidance on what file to alter or where to place a file etc, please (as well as exactly what that file contain!)?
Many thanks

1 Like

Hello @cbn1 great to hear about your setup!

There isnt currently a feature on the emonpi to do this out of the box. I would usually write a little script to pull in the value from one API and forward on to the local emoncms in this case. But perhaps using NodeRed might be easier if you would prefer to not delve into coding… If you have a recent emonSD image running on the emonPi you will likely need to install NodeRed to do this.

Alternatively here’s a really basic python example that pulls data from one emoncms installation and forwards it to another:

import urllib2, json

# 1. Fetch data from API 1
response = urllib2.urlopen('https://emoncms.org/input/get/ovms/metric_v_b_soc?apikey=APIKEY1')
jsonstr = response.read()
data = json.loads(jsonstr)
soc = data['value']

# 2. Post data onwards to API 2
response = urllib2.urlopen(''+str(soc)+'&apikey=APIKEY2')
print response.read()

Did you search the community? Several folk have done just this.

Thank you Trystan and Brian for your responses.
I had read other posts on the subject, but I couldn’t find a solution other than suggestions to use Node Red or Emoncms HTTP API or MQTT - which at the moment are beyond me!
However, given the current enforced time at home, and the very helpful guidance in your replies, I am going to teach myself how to do it !
Thanks Again


@haffle, did you get a Node-Red flow for pulling the data off your Powerwall?

@cbn1, if you have a spare Pi, then that is best for Node-Red. I’m not keen on mixing things on the emonPi; it can have unexpected consequences. (I changed the thread title).

@miker, did you get it to work, I presume so. - How to add a CA cert to access a powerwall? - #4 by miker

Hi @borpin - yes I did, and it works well.

The code I used, having been helped by @miker on this forum, is

[{"id":"3ceb5e73.2f9352","type":"http request","z":"30189346.6b7acc","name":"charge","method":"GET","ret":"obj","paytoqs":false,"url":"https://192.168.REDACTED.REDACTED/api/system_status/soe","tls":"e5ec1e65.f66b1","persist":false,"proxy":"","authType":"","x":410,"y":260,"wires":[["40a510f1.be352"]]},{"id":"40a510f1.be352","type":"json","z":"30189346.6b7acc","name":"","property":"payload","action":"str","pretty":false,"x":590,"y":260,"wires":[[]]},{"id":"e5ec1e65.f66b1","type":"tls-config","z":"","name":"TLS configuration","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false}]

… but I have typed REDACTED four times in that - the first two are the Powerwall local IP and the second two are the emonPi local IP. Hopefully there is no other personal info in the code!

It grabs data once every 10 seconds, and forwards it to my emonCMS dashboard.

FWIW, I have a dedicated Raspberry Pi Zero W for doing the Node-RED, and again it is working well.


1 Like

Thanks. Did you remove the API key from the emoncms node?

I reformatted above - you can use a single back tick inline but for bulk, 3 backticks on a line before and 3 on a line after will format it as above :grin:.

@borpin I didn’t, but 99% sure it isn’t in there. I did look, and whilst it is needed in one of the Nodes, for some reason it didn’t seem to get included in the code “Export”. (Thanks for the reformatting - I didn’t know how to do that).

@cbn1 - if you want to use the emonCMS battery icon for showing the Powerwall SoC, you might want to edit the code a bit so that it displays 10 “chunks” instead of just the 5. Trystan was very helpful and showed me how to do it in this thread. Dashboard battery graphic - granularity - #6 by haffle

1 Like

beer_cheer thumbsup


There’s no direct security issues with a 192.168.xxx.xxx IP address.
Your external IP address is the one you want to “protect.” i.e. the one you get from your ISP.


@cbn1 - with the risk of the blind leading the blind, if I can help please PM me; I am only just getting to grips with Node-RED, but others on here have been very helpful so it would be good if I could reciprocate a bit.

FWIW, I set Node-RED up on a Pi Zero W, but any Pi will work. In the first instance I followed the guide on Running on Raspberry Pi : Node-RED and then if you import the code I posted earlier it should get you going. It can be very frustrating until it works, but then it is very rewarding when it does! :grinning:

(Obviously the Node-RED Pi will need to be working 24/7 for the SoC to get transferred to emonCMS).

(I’m on a roll…)

On the other thread @miker posted this link to some other data available from the powerwall. If you want to import this date to emonCMS with Node-Red, you can use this flow


[{"id":"7f4081b4.f1515","type":"json","z":"88bc3298.02488","name":"","property":"payload","action":"","pretty":false,"x":330,"y":280,"wires":[["3aa9261a.7ecb9a"]]},{"id":"3aa9261a.7ecb9a","type":"split","z":"88bc3298.02488","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":490,"y":220,"wires":[["172e9f57.ec0c81"]]},{"id":"172e9f57.ec0c81","type":"change","z":"88bc3298.02488","name":"","rules":[{"t":"move","p":"payload.last_communication_time","pt":"msg","to":"time","tot":"msg"},{"t":"set","p":"nodegroup","pt":"msg","to":"\"Powerwall-\" & msg.parts.key","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":280,"wires":[[]]}]

You need to add the hhtp request and inject to the code posted above, plus add the emoncms node but it will inject data like this:


Thank you all!
I do have another Pi and was just dusting it off and updating it when I realised your messages were flooding in!
I will try Node Red on it and use the code examples above - sounds like the answer is there thanks to the efforts of others.
I will also try Trystan’s basic Python option - I assume that might be more suitable to run on the emonPi, as it seems a bit excessive to run another Pi 24/7 just to do this function.
Thanks @haffle for your offer of help - I may well take you up on it!

1 Like

You then find lots of other uses for Node-Red… :grinning:.

1 Like

@borpin I’ve tried your solution above, but am still getting “format error, json value is not numeric” when I set emoncms to “simple json”. When I set emoncms to “valid json object” I get “input in not a valid json object”. Any help greatly appreciated!

Strictly a WAG, but is jsonata misspelled? i.e. is it supposed to be jsondata?

Thanks Bill. I’ve made this change, but still get the error. Unless I get other advice I’m going to try and figure out how to retain only the bits I’m interested in. Hoping that I lose the broken bit.

Does your emonCMS config look like this (node group empty)?


Can you attach a debug node

  1. after the json node
  2. after the change node

and post the data output here please.

Is the data from the API exactly as you posed in that link above? Any variation and it will not work - I don’t have a Powerwall :sob:.

(sorry I missed your reply).

Thanks Brian, sorry I didn’t mean to sound so demanding.

The battery has been amazing, obviously a big spend and as a household we deliberated whether it was worth it. Here’s the summary of performance/use since install (basically the beginning of March):

The storage takes away most of the need to try and use solar when it’s sunny, so we’re very pleased.

Back to scraping data…

I did have a node set, but this is now removed. Error still there.

Here’s the debug message from the json node (annoyingly truncated, I don’t know how to solve that):

{"site":{"last_communication_time":"2020-03-31T19:39:08.090236114+01:00","instant_power":0,"instant_reactive_power":-682,"instant_apparent_power":682,"frequency":0,"energy_exported":14364,"energy_imported":71113,"instant_average_voltage":70.49158111670735,"instant_total_current":0,"i_a_current":0,"i_b_current":0,"i_c_current":0,"timeout":1500000000},"battery":{"last_communication_time":"2020-03-31T19:39:08.090389106+01:00","instant_power":270,"instant_reactive_power":-10,"instant_apparent_power":270.1851217221259,"frequency":49.928,"energy_exported":191160,"energy_imported":222770,"instant_average_voltage":244.70000000000002,"instant_total_current":-6.800000000000001,"i_a_current":0,"i_b_current":0,"i_c_current":0,"timeout":1500000000},"load":{"last_communication_time":"2020-03-31T19:39:08.090236114+01:00","instant_power":267.7692634613927,"instant_reactive_power":-609.903039936396,"instant_apparent_power":666.0946603736693,"frequency":0,"energy_exported":0,"energy_imported":253848,"in ....

Here’s the debug output from the change node (again truncated):

{"site":{"last_communication_time":"2020-03-31T19:45:06.490250637+01:00","instant_power":19,"instant_reactive_power":-700,"instant_apparent_power":700.2578096672681,"frequency":0,"energy_exported":14364,"energy_imported":71113,"instant_average_voltage":70.29816877652883,"instant_total_current":0,"i_a_current":0,"i_b_current":0,"i_c_current":0,"timeout":1500000000},"battery":{"last_communication_time":"2020-03-31T19:45:06.490578495+01:00","instant_power":960,"instant_reactive_power":10,"instant_apparent_power":960.0520819205591,"frequency":49.884,"energy_exported":191250,"energy_imported":222770,"instant_average_voltage":243.9,"instant_total_current":-24.1,"i_a_current":0,"i_b_current":0,"i_c_current":0,"timeout":1500000000},"load":{"last_communication_time":"2020-03-31T19:45:06.490250637+01:00","instant_power":964.1517270526933,"instant_reactive_power":-615.300164446345,"instant_apparent_power":1143.7582109634843,"frequency":0,"energy_exported":0,"energy_imported":253938,"instant_avera ....

Here’s the json from my powerwall, looks like I have an additional timeout in each section:


I think I’m only interested in the instant_power variable from each of the four sets (although the site data will hopefully match what my emonpi is capturing via its CT clip.

To copy the data out click here.


You also need to change the debug node to be the complete message object -


However, there must be something wrong with the change node as it should start not start


The debug output from the change node should look like


Note the last_communication_time has gone and been moved into the msg.time element.

It does look like this?