datMaffin / homebridge-tesla-powerwall

Homebridge Plugin for the Tesla Powerwall
ISC License
21 stars 11 forks source link

Add a switch to detect grid failure #10

Closed StephenNorris closed 4 years ago

StephenNorris commented 5 years ago

I’d love to be able to automate some actions (turn things off mostly) when the grid is down and the battery is low. Is there any way to do this with the API you use?

datMaffin commented 5 years ago

This plugin basically just pulls the information from the Powerwall and inserts them into the specific services. There was a suggestion in issue #8 of a switch which changes it's state if the battery is low. This switch could possibly be used to automate things via the homekit app (I'm not 100% sure though).

kylerove commented 5 years ago

Looks like Home app does not have the ability to create actions based on the state of a dimmer switch percentage value beyond on/off (for powerwall battery charge state).

You could create an on/off switch for grid services using this api call to determine if the grid is up or down.

request: curl http://192.168.xxx.xxx/api/system_status/grid_status

response: {"grid_status":"SystemGridConnected"} = grid is up {"grid_status":"SystemIslandedActive"} = grid is down {"grid_status":"SystemTransitionToGrid"} = grid is restored but not yet in sync.

jongent commented 4 years ago

Just wanted to second this. It would be extremely helpful for load shedding in grid outage situations to have this. Any chance you're still going to have 1.0 at the end of the month here as it looks like you were originally planning?

Even if not what you had fully planned for 1.0, if you could even release an iterative update with just this additionally it would be awesome. More than happy to contribute to the coffee fund, especially with these odd COVID-19 times were living in, to help make it happen.

jongent commented 4 years ago

Just shot over a coffee donation--would love it if we could get something (either iterative with the grid failure switch or full 1.0 even better) in the next couple of weeks! Thanks @datMaffin!

datMaffin commented 4 years ago

Implemented in https://github.com/datMaffin/homebridge-tesla-powerwall/commit/8a7e2ca89cc92aed58674623c3cad6f95e9b9a44

Add the following to config.json in subsection of additionalServices:

"gridstatus": {
  "gridIsDownSwitch": true,
  "gridIsUpSwitch": true,
  "gridIsNotYetInSyncSwitch": true
}
datMaffin commented 4 years ago

Current version can now be installed with npm install -g homebridge-tesla-powerwall@1.0.0-Beta

Rollback to the last version is similar: npm install -g homebridge-tesla-powerwall.

Interested in feedback. (Are the introduced switches appropriate?).

All new switches are already included in the config.json documentation: https://github.com/datMaffin/homebridge-tesla-powerwall#configuration

jongent commented 4 years ago

Just implemented it into my configuration last night and it is working perfectly as planned. Actually setup power shedding automation based off of it in HomeKit last night and we had a grid outage of ~15 minutes this morning and the only reason I noticed was some of the items turning off that I had automated last night.