Fetch Tesla Power Wall State of charge using EmonHub

Thanks @borpin that looks really useful, would be great to be able to get the other parameters out of the powerwall as well

Note - Python3.

1 Like

You meant to add this to the Powerwall request, didn’t you?

OK both of those test worked :slight_smile:

For @borpin, I am now trying the script with Python3. First requirement was to add () in print statements :slight_smile:
Then urllib2 → urllib.
The saga will continue.

Great, can you also try in the 2nd example above:

ctx = ssl.SSLContext(ssl.PROTOCOL_TLS)

thanks for testing!!

I’ve updated the code on the EmonHub repository to use PROTOCOL_SSLv23 for the time being Update EmonHubTeslaPowerWallInterfacer.py · openenergymonitor/emonhub@d4633e3 · GitHub

That doesn’t work:

ctx = ssl.SSLContext(ssl.PROTOCOL_SSL)
AttributeError: ‘module’ object has no attribute ‘PROTOCOL_SSL’

I have the script working with Python3 now :slight_smile:

1 Like

Its PROTOCOL_TLS rather than SSL … hopefully that will work

Yes indeed it does.

OK showing my complete ignorance here, how do I update the Powerwall interfacer?!

Great that the TLS options works, sounds like that might mean we’ve made a secure connection!

cd /opt/openenergymonitor/emonhub
git pull origin powerwall
sudo service emonhub restart

Did you run the above without PYTHONHTTPSVERIFY=0?

Yes, but we’ll soon find out if it really works when I update :wink:

1 Like

Yay it works!
I even remebered to check I’d disabled my crontab :slight_smile:
Output from emonhub.log:

2020-05-11 14:55:46,230 DEBUG PowerWall Request response: {“percentage”:100}
2020-05-11 14:55:46,231 DEBUG PowerWall 7 NEW FRAME :
2020-05-11 14:55:46,232 DEBUG PowerWall 7 Timestamp : 1589205346.23
2020-05-11 14:55:46,233 DEBUG PowerWall 7 From Node : powerwall
2020-05-11 14:55:46,234 DEBUG PowerWall 7 Values : [100]
2020-05-11 14:55:46,234 DEBUG PowerWall 7 Sent to channel(start)’ : ToEmonCMS
2020-05-11 14:55:46,235 DEBUG PowerWall 7 Sent to channel(end)’ : ToEmonCMS
2020-05-11 14:55:46,416 DEBUG MQTT Publishing: emon/powerwall/soc 100
2020-05-11 14:55:46,418 INFO MQTT Publishing: emonhub/rx/powerwall/values 100

As you can see, it is sunny here today :sweat_smile:

1 Like

Great news, I’ve merged this in to the main emonhub branch now, would you mind switching back and testing one more time?

cd /opt/openenergymonitor/emonhub
git checkout emon-pi
git pull origin emon-pi
sudo service emonhub restart

Strictly

sudo systemctl restart emonhub.service
1 Like

Confirmed it works. Happy days.

1 Like

Great, thanks for all of your help @PeteF it will be great to look at expanding on this once we are on python3 with the tesla-powerwall specific library @borpin mentioned

Trystan, before you update the Tags etc, can the default emonhub.conf be tidied up especially for the Serial interfacer please. And the documentation for the new interfacer?

1 Like