Go Off Grid option for Tesla Powerwall integration

The Tesla app and the local web interface has an option to go off grid.
There are times that I would like to go off grid and being able to schedule/automate it would be much better.

Is it possible to add this option to the HA integration? (Probably as a switch)

Thanks!

Would be great to have this option i would go off grid after the sunset before sunrise :slight_smile:

1 Like

In my case I actually want to go off grid during the day, while I’m generating solar.

Reason being, while solar is generated it needs to sync phases with the grid, and to do this the grid is constantly supplying about 100W. This usage adds up during the day and could be as much as 5% of my total usage on a day.

So going off grid during the day helps me decrease my dependency on the grid even more.

Looks like this is upcoming for 2023.2, in the beta release today.

Yes indeed it was added!

This is amazing :raised_hands:t2:

Thank you to the devs!

1 Like

You’re super welcome @justanothernaude! I was in the same boat as you, and desperately wanted to be able to automate taking my home off grid (negative feed in tariffs from my provider :roll_eyes:).

I’ve had some feedback that it curtails solar generation correctly for single phase systems (should work for most installations) but won’t if you have a three phase setup. Not much I can do here, I’ve just plumbed in the off grid switch from the Web UI.

Happy automating!

2 Likes

Awesome @daniel-simpson !

Would you mind sharing your automations? What are your use cases?

So far I’m taking myself off grid when my Powerwall is charged above the reserve and I’m sure I’m still generating enough solar:


alias: Go Off Grid
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.powerwall_solar_now
    above: sensor.powerwall_load_now
    for:
      hours: 0
      minutes: 30
      seconds: 0
  - platform: sun
    event: sunrise
    offset: 0
condition:
  - condition: numeric_state
    entity_id: sensor.powerwall_charge
    above: sensor.powerwall_backup_reserve
action:
  - type: turn_on
    entity_id: switch.powerwall_off_grid_operation
    domain: switch
mode: single

Sure, finally got around to sorting those out today and happy to share (though I wouldn’t be surprised if I have bugs, it’s my first draft).

My main use case is to take my home off-grid if the solar feed in price goes negative (which unfortunately my provider seems to do whenever the sun is out :sweat_smile: :grimacing:) and my battery is almost full. For a single-phase powerwall setup (the standard setup, as far as I’m aware), switching on “Go Off-Grid” curtails your solar and avoid exporting solar to the grid, which is what I’m taking advantage of here.

binary_sensor:
  # Note: this is coming from the Amber Energy integration, you may need to get the feed in price from another integration depending on where you live!
  - name: Amber Energy Negative Feed In
    platform: threshold
    entity_id: sensor.<YOUR SITE NAME>_feed_in_price
    lower: 0

  - name: Powerwall Almost Full
    platform: threshold
    entity_id: sensor.powerwall_charge
    upper: 95

automation power:
  - id: power_automatically_go_off_grid
    alias: "Power: Automatically go off-grid"
    description: ""
    mode: single
    trigger:
      - platform: homeassistant
        event: start
      - platform: state
        entity_id:
          - binary_sensor.amber_energy_negative_feed_in
          - binary_sensor.powerwall_almost_full
    action:
      - choose:
          - conditions:
              - alias: "Negative Feed In && Battery almost full"
                and:
                  - condition: state
                    entity_id: binary_sensor.amber_energy_negative_feed_in
                    state: "on"
                  - condition: state
                    entity_id: binary_sensor.powerwall_almost_full
                    state: "on"
            sequence:
              - if:
                  - condition: state
                    entity_id: switch.home_energy_gateway_off_grid_operation
                    state: "off"
                then:
                  - service: switch.turn_on
                    data: {}
                    target:
                      entity_id: switch.home_energy_gateway_off_grid_operation
                    alias: Go off-grid
                alias: Go off grid, if we aren't already off-grid
        default:
          - if:
              - and:
                  - condition: state
                    entity_id: switch.home_energy_gateway_off_grid_operation
                    state: "on"
                  # Note: adding this second condition in case you have a grid outage while you're off-grid... Not sure it's necessary
                  - condition: state
                    entity_id: binary_sensor.grid_status
                    state: "on"
            then:
              - service: switch.turn_off
                data: {}
                target:
                  entity_id: switch.home_energy_gateway_off_grid_operation

TL;DR:

if battery_charge > 95% && feed_in_price < $0.00
    Turn on "Off-grid operation"
else
    Turn off "Off-grid operation"

Hopefully that gives you an idea of what I was hoping to achieve anyway! Let me know if you want any clarification

2 Likes

Thanks for sharing! That’s very cool!

Just a comment about this note you left:

# Note: adding this second condition in case you have a grid outage while you're off-grid... Not sure it's necessary
- condition: state
  entity_id: binary_sensor.grid_status
  state: "on"

When switch.powerwall_off_grid_operation is on, then binary_sensor.grid_status is off, so it is indeed not necessary :slight_smile:

1 Like

Ahh, that’ll be why I was having so much trouble getting my powerwall back on grid (and a separate power outage automation kept triggering). Thanks for the clarification!

Once I iron out the kinks I’ll post a final version too

3 Likes

How did you go with this mate? managed to get it all working as you need?

I did, but I’ve actually had the automation disabled for a while: it’s winter here so I’m not getting much sun, and so the monetary aspect is very, very small. Plus, as a household we’ve gotten a lot better at using as much energy as possible while generating solar/cheap (dehumidifiers and heaters at the moment).

I’ll almost certainly have another crack at getting it set up in summer though!

Was there something in particular you were trying to get working @s3lkies? Happy to help out