Forums

Smart home interfacing?

Smart home interfacing?

Hi - does anyone know how to use data from the Powerwall 2 to regulate smart sockets (or similar)?

Since installing our solar panels, we suddenly have plenty of electricity. We decided to install a couple of electric storage heaters to make better use of the power we're generating. For the moment, we regulate them manually, but it would be nice to have them on networked sockets, controlled according to the charge status of the Powerwall. For example, if the Powerwall is at >90% charge and rising, switch on one or both of the storage heaters.

It's probably possible to DIY this with Raspberry Pi, but I wonder if there's already something off the shelf that would do the job. Could Amazon Alexa or Google Home handle something like this?

- Jim

cwied | March 29, 2018

As far as I know, Tesla has not published an official API for third-parties to use, so this remains a DIY project.

sashton | March 29, 2018

This subject is certainly a moving target.
There is certainly a RESTful interface on your Tesla Gateway. This is primarily read only but can give you running totals and battery status. It is also possible to start/stop and reconfigure through a web client.
Starting and suspending the battery on a timer is now a feature of the system, introduced by a recent firmware update.
There are systems available out there which claim to be able to read and control your Powerwall. I'm sure most are genuine but personally I am loath to pass my Tesla credentials to a third party, especially when there are car deposits associated with them.

My suggestion would be to look up the Gateway RESTful API. It is incredibly simple and it is very unlikely that you will damage your system by playing with it in this manner. The other advantages of using the method are 1) that it's entirely local to you so it will function even if your internet connection goes down and 2) you can apply your own security layers yourself (VLAN/segmented LANs etc.)

I am absolutely sure that there will be more and more groups adapting their products to work "with" the PW system so even if there isn't a PW glue module, it it's extensible there probably will be one along soon.

It would bore a lot of regulars here for me to repeat how I hook my appliances, car charging, load shedding and export limitation into the PW system again but it is all possible. Personally I avoid Google; Amazon and Facebook as I feel they play fast and loose with your data.

cwied | March 29, 2018

My hope is that eventually Tesla will add OAuth authentication and a third-party API. That would take care of the security concerns (presuming they implement their permissions correctly).

In the meantime, If I were you, I would look into IFTTT. You could write a simple script that leverages the Webhook trigger to trigger your heaters based on requests for the state of charge from the powerwall, provided they have some automation capability.

jcbrodie | March 30, 2018

Thanks folks. Just to be clear @sashton, I'm not looking to control the PW, but rather to use information about the PW state to control other things. The read only RESTful interface sounds like it could be just the job. I'll look into that, thank you.

@cwied: Definitely having a closer look at IFTTT, thanks. I've done a little bit with Python, seems like this works along the same lines.

gary.ferris1337 | March 30, 2018

This is something I'm interested in doing too, honestly. I haven't had a lot of time to look into the logistics, but if Tesla were to release an API for this, I would be ecstatic!

As sashton my concern for my data's security has definitely increased as of late, so I would lean towards the DIY methods.

sashton | March 30, 2018

@jcb easy to find elsewhere but here are the two most useful URI
State of Charge:
/api/system_status/soe
Metrics:
/api/meters/aggregates
JSON response is self explanatory

jcbrodie | March 30, 2018

@sashton Thanks again! Have house guests at the moment, but once they're away I'll tackle this properly.

@gary.f @sashton I quite agree about the data insecurity of having an Echo or any of these spy gadgets in the house.

vloschiavo | April 4, 2018

@jcbrodie:

I'vee started documenting the Powerwall 2 gateway api. You can find the current version here:
https://github.com/vloschiavo/powerwall2

I'm also interested in doing similar things as you with the excess power, hence the documentation.

I use OpenHab (running on a raspberry pi) for my internal home automation.
In general, here are the things I use Openhab for.
0) Controlling outlets - this is a hack on my side, but I use those remote control outlets that come with a radio frequency transmitter. They are usually on sale at home depot during Christmas.
-Here's the indoor version: https://smile.amazon.com/Woods-13569-Indoor-Wireless-Control/dp/B003ZTWY...
-Here's an outdoor version: https://smile.amazon.com/Woods-32555WD-Outdoor-Wireless-Weatherproof/dp/...

I then use openhab (or cron during christmas) to trigger an Arduino with an RF 315MHz transmitter to turn on/off the outlets. They are individually controlled and you specify if you want it on or off.

1) Monitoring Powerwall stats (Solar, Grid, Home, Batt usage/production/freq/etc/etc).

2) Monitoring (battery voltage) and controlling (open & close) a battery powered gate

3) Temp/Humid sensors in various locations:
-Attic (I'm planning on redoing the insulation so I want pre and post data
-Woodworking workshop (temp & humidity are very important there
-Exterior - current weather

4) Future: use excess solar (power being dumped to the grid) to charge my Model 3. - Requires Remote control of charge rate.
-Not working yet. Need one of these two things to work first:
--Tesla Wall Connector has a RS-485 interface - the new protocol it uses is currently being reverse engineered by Chris Dragon - old protocol version here: https://github.com/cdragon/TWCManager - with this I can dial down charge amps of the wall connector to match the solar excess.
--other option is wait for the Tesla owner API to be updated by Tesla to include controlling charge rate via the phone app. - https://twitter.com/elonmusk/status/932649922666438656

5) ....

This is a system I've been slowly hacking together for a couple of years in my spare time.

PM me if you'd like to discuss more.

sashton | April 4, 2018

@vloschiavo I agree hacking home automation devices is so much fun! I use a RFXtrx433E which appears to cover most commonly used frequencies. The biggest advantage is that I don't have to be stuck with ZigBee or Zwave devices which all seem to cost at least twice as much as any similar device without a Z in the protocol.
The problem with (4) appears to be that the EVSEs only appear to be able to dial down the charge rate to 1.4kW so I address that here by kicking the charger into life earlier in the day so the PW can mop up the excess when it's fallen to less than 1.4kW rather than waiting for the PW to fill up and then charging the car.
NB some of the chargers rely on a contactor in the device with quite a low duty cycle. I sent back quite a few (under warranty ..Ahem) when the contactors had failed after clicking on and off with every passing cloud :)

jcbrodie | April 6, 2018

@vloschiavo Thanks for that! I'll head over to github and take a look.

I now have a couple of 'smart plugs', so the heaters are networked, and I've got myself a Raspberry Pi, which I'm planning to set up with Home Assistant (https://www.home-assistant.io/). Once that's all set up, I can think about adding a networked switch for the water heater as well.

I think Tesla are missing a trick here. Since they've got the battery to run all this stuff, they should really do a killer app to coordinate it all as well. Much better than launching cars into space.