Tesla Powerwall use cases and automation sharing

i tried and failed. will try create utility rate plan from scrath to see.

currently I can see Amber SmartShift works pretty well. and The most gain for the battery system with Amber is price spike period. Other tuning makes only very small difference that may not worth the effect if you are at home with a/c on.

Hi, I didn’t see this mentioned in the thread yet so thought I’d point out: The Telsa Fleet integration works great as another alternative to accessing powerwall (and vehicle) sensors and controls without need for separate token apps or paid fleet subscription etc. It is limited to the 200 API calls / day though.

I’m using Telsa Fleet + Telsa Powerwall integrations for the use cases in this thread.

2 Likes

FYI: From Tesla Support
About your issues with the API : that might be related to the Gateway firmware that was updated in July.

After version 24.4.0 it was no longer possible to have local access via the IP address.

This option has been discontinued as there is now an app for installers to commission the Powerwall. The access was not actually intended for customers, but primarily for installers.

Unfortunately we currently don“t support API inquiries, but what I can share with you is this link which might help:

https://developer.tesla.com/docs/fleet-api/getting-started/what-is-fleet-api

Hi, I have recently had a PW3 with GW2 installed.

Do any fo know which of the above HA integrations will work with that? I am looking to control the PW (not just monitor it). For example an integration that switches the export eveything Vs export solar only option in response to a SoC < x, or perhaps on a timed schedule? Does the feet API allow for that?

Any screnn shots of that please?

Any halp much appreciated.

(I should perhaps say that as yet I have not got HA - I am considering going down that route, but it all hinges on a useable PW3 integrtation. The overall goal is integrate my powerwall, heatpump, myenergi car charger & water heater and my energy suppliers smart tarrifs (Octopus UK).

I just got my powerwall and amber. I would love to know what you have done since this post. I have added the amber addon in

I’ve since scaled my automations back quite a bit: I wasn’t saving all that much and was finding some particularly sensitive electronics on one circuit were effected negatively when I took the house off grid (including taking the computer running HA offline :unamused:)

I’ve still got all the sensors hooked up, but automations are all off except one that (attempts to) take the house off grid once the solar export price is well below -10 cents. I figure price protection should cover me for anything down that low, and I’m just covering any possible losses.

Note: for now, the ability to take the house off grid hinges on the HACS-based Tesla cloud integration. The native Powerwall integration used to perform off-grid islanding mode (disclaimer: I helped write that bit), but has since broken because of Tesla pushing a firmware update that removes local control over your own battery :angry:

  binary_sensor:
    - name: Amber Energy Negative Feed In
      platform: threshold
      entity_id: sensor.amber_energy_feed_in_price
      lower: -0.10

    - name: Powerwall Almost Full
      platform: threshold
      entity_id: sensor.powerwall_charge
      upper: 95
    
  automation:
    - id: power_automatically_go_off_grid
      alias: "Power: Go off-grid"
      description: "Takes the house off-grid if the battery is almost full, and feed in is suitably negative.  Comes back online when this is no longer the case"
      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 && powerwall 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:
                - action: input_boolean.turn_on
                  target:
                    entity_id: input_boolean.automatically_off_grid
                - if:
                    - condition: state
                      entity_id: switch.home_energy_gateway_off_grid_operation
                      state: "off"
                  then:
                    - service: switch.turn_on
                      target:
                        entity_id: switch.home_energy_gateway_off_grid_operation
                      alias: Go off-grid
                  alias: Go off grid if we aren't already
            - conditions:
                - alias: "otherwise, on grid"
                  or:
                    - condition: state
                      entity_id: binary_sensor.amber_energy_negative_feed_in
                      state: "off"
                    - condition: state
                      entity_id: binary_sensor.powerwall_almost_full
                      state: "off"
              sequence:
                - action: input_boolean.turn_off
                  target:
                    entity_id: input_boolean.automatically_off_grid
                - if:
                    - and:
                        - condition: state
                          entity_id: switch.home_energy_gateway_off_grid_operation
                          state: "on"
                  then:
                    - service: switch.turn_off
                      target:
                        entity_id: switch.home_energy_gateway_off_grid_operation

Apologies all for my absence - I’m glad to see this matter is still in people’s minds and further work is happening to allow us to better use our powerwalls.

I’m not using tesla fleet integration. As far as I know the powerwall is upgrading automatically but I am still able to reach its api locally using pypowerwall as a proxy. I need to check more closely.

I’m a bit worried as I feel I’m a bit in too deep with the local/custom integrations to swap again now, but as well if that will become a requirement, it will have to happen anyway.

My system has been working well as I want and need it and I’ve reached a point where it requires virtually no maintenance.

I notice no one replied to the question as to whether the Powerwall 3 is supported. For the PW 3 is it possible to:

  • Turn on and off discharging to the house
  • Turn on and off recharging from the grid

I wouldn’t see why not, Tesla are fairly consistent with their use of a single API to manage all devices.

However only someone with a PW3 will be able to confirm.

I’ve created three scripts to attempt to control the PW2. They aren’t effective. Has anybody got something similar working?

sequence:
  - action: number.set_value
    metadata: {}
    data:
      value: "20"
    target:
      entity_id: number.powerwall_2_tesla_backup_gateway_2_backup_reserve
  - action: select.select_option
    metadata: {}
    data:
      option: self_consumption
    target:
      entity_id: select.powerwall_2_tesla_backup_gateway_2_operation_mode
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.powerwall_2_tesla_backup_gateway_2_allow_charging_from_grid
  - action: select.select_option
    metadata: {}
    data:
      option: battery_ok
    target:
      entity_id: select.powerwall_2_tesla_backup_gateway_2_allow_export
alias: Powerwall → Self-Consumption Mode
description: ""
sequence:
  - action: number.set_value
    metadata: {}
    data:
      value: "95"
    target:
      entity_id: number.powerwall_2_tesla_backup_gateway_2_backup_reserve
  - action: select.select_option
    metadata: {}
    data:
      option: autonomous
    target:
      entity_id: select.powerwall_2_tesla_backup_gateway_2_operation_mode
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.powerwall_2_tesla_backup_gateway_2_allow_charging_from_grid
  - action: select.select_option
    metadata: {}
    data:
      option: never
    target:
      entity_id: select.powerwall_2_tesla_backup_gateway_2_allow_export
alias: Powerwall → Force Charge
description: ""
sequence:
  - action: number.set_value
    metadata: {}
    data:
      value: "5"
    target:
      entity_id: number.powerwall_2_tesla_backup_gateway_2_backup_reserve
  - action: select.select_option
    metadata: {}
    data:
      option: autonomous
    target:
      entity_id: select.powerwall_2_tesla_backup_gateway_2_operation_mode
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.powerwall_2_tesla_backup_gateway_2_allow_charging_from_grid
  - action: select.select_option
    metadata: {}
    data:
      option: battery_ok
    target:
      entity_id: select.powerwall_2_tesla_backup_gateway_2_allow_export
alias: Powerwall → Force Export
description: ""

Looks like not many people are using a PW3 as I can’t get a definitive answer…

Not sure I understand what you are trying to do that you can’t.

Have you tried the scripts that I published?

It’s possibly a small intersection - people with PW3, people who use homeassistant, people who want to control their pw3 with homeassistant and people who lurk in the homeassistant forums…

As of this morning my Tesla sends Code:Error when attempting to alter the backup reserve value. I can still change modes, but setting backup reserve fails

I’m using the custom Tesla integration (alandtse/tesla: Tesla custom integration for Home Assistant. This requires a refresh token be generated by third-party apps to login.) and it seems like the maximum the Backup Reserve value I can set right now is 80% for my Tesla Powerwall 2.

So, currently this action results in an error message, but still ups the number from the normal 20% to 80%:

data:
  value: "95"
target:
  entity_id: number.pw2_battery_both_custom_backup_reserve
action: number.set_value

image

But that’s not really what I’m looking for when I want to make sure that my battery is charged as much as possible before the peak tariff sets in :frowning:

P.S.:
Doesn’t look like I can set it any higher in the Tesla App either.
I can initially set it to a higher value there, but I can see within 30 seconds in the app and my HA Dashboard that the value is taken down to 80% as well.

behaviour I’m seeing is same ā€œfailed to perform actionā€ messages as you, and not able to push any change to reserve value successfully to the powerwall itself.
the other attributes seem to still be working (such as export energy solar/everything/none)

discussion here: All calls to set backup reserve level fail; errors in HA log - possible Tesla API change? Ā· Issue #1125 Ā· alandtse/tesla Ā· GitHub

so it seems possibly more than one issue

  • can’t push change to reserve value from HA, some broken-ness between HA and tesla
  • can’t set a reserve value greater than 100 - nothing to do with HA, just an arbitrary decision by tesla, which isn’t on, we own the boxes, let us decide how much charge we want at any one time

and in my case, confusion because I started to do a long overdue upgrade at about the same time as Tesla started tweaking stuff :frowning:

I don’t need a value greater than 100 :face_with_open_eyes_and_hand_over_mouth:
But it seems like I can only set values of 80 or less or exactly 100.

Typo :slight_smile:
Using workaround from the github discussion, my automation to set to 100% when car charging on intelligent octopus has just run and worked.

Has anyone written a template sensor that will estimate the time to charge a Powerwall to 100% based on current charge rate?