Add support for Tesla Powerwall

If you want to try the more complicated way, here is my write up of the steps that I followed:

If you want to use the method you started then here: Add support for Tesla Powerwall - #309 by markpurcell

2 Likes

This integration and the automations people have shared above are awesome. Thank you all!

Iā€™ve created an automation to decide whether to charge from the grid, based on predicted solar generation for the next day. Iā€™m trying to figure out the best combination of actions when switching to grid charging, for example whether to leave in self-powered mode and alter the backup reserve percentage, or instead to switch to time-based mode, which will also make grid charging kick in during my off-peak time.

Iā€™ve read in a few places that the charging rate is limited in self-powered mode. If I switch to time-based control, I guess it has a target charge time to aim for (i.e. the end of the off-peak time) so it ramps up more to reach that target. The benefit to this would be a quicker charge time and therefore less overall time in grid-charging mode (with other appliances also drawing from the grid and therefore slightly higher cost).

Can anyone whoā€™s tested this spare me a very late night and confirm whether thatā€™s the case? I have a Powerwall 2 in case that matters.

This feature request is now well supported by the custom integration:

For me the different modes do charge at different rates, it also depends on the size of your solar as well as I think the powerwall uses that to calculate how much energy will be supplied during the day.

The rough rule of thumb I have seen is:

Setting the backup reserve higher will charge at about 33%, i.e. ~ 1.7kW.

Setting the powerwall into ā€˜backupā€™ mode (available in the home assistant integration will charge at about 66% ~ 3.4 kW

Setting the time based control during an off peak window will charge upto 100% ~ 5 kW.

2 Likes

Thanks, sadly I didnā€™t see your response last night, but at least I managed to confirm for myself the hard way :laughing:

Youā€™re exactly right, playing with the backup reserve % results in a charge rate of 1.7kW. The only way to get 5kW is to use time-based mode in the off-peak window.

However, Iā€™ve noticed that if you switch to time-based mode after the start of your configured off-peak time window has passed, (e.g. off-peak starts at 23:30 and you only switch to time-based at 23:45), it doesnā€™t seem to kick in at all and start charging. This is annoying as I was planning on delaying the start time depending on how much charging was needed.

Not the end of the world though, it will just start charging at a target time instead of finishing at a target time.

Hi there,

Does anyone know if you can control the switching of grid charging from HA using this integration or another method?

With Spring coming up I can see that there maybe nights when I want to turn off grid charging for that night preceding a high solar day, but others nights still want to switch back to grid charging. I would like to do this by automation based on my Solcast forecast.

The Tesla Custom Integration has the same controls as the Tesla App, so yes you can automate.

1 Like

Thanx Mark,

got it automated with this:

service: select.select_option
data:
  option: "No"
target:
  entity_id: select.home_energy_gateway_grid_charging

2 Likes

Apologies if this has been answered elsewhere, however I have got so far but have come up against a brick wall!!

Iā€™m trying to set both the operation mode and backup reserve through an automation.

The first action works as expected e.g.

service: select.select_option
data:
  option: Self-Powered
target:
  entity_id: select.home_energy_gateway_operation_mode

However the second action does not work, in this case trying to set the backup reserve to 5%.

service: select.select_option
data:
  option: "5"
target:
  entity_id: number.home_energy_gateway_backup_reserve

Any help would be appreciated.

try this in the Automation ACTION:

service: number.set_value
data:
  value: "5"
target:
  entity_id: number.home_energy_gateway_backup_reserve

as its a number then it is a ā€œVALUEā€ and not an ā€œOPTIONā€

1 Like

Chris, many thanks for the help, worked a treat, much appreciated, Andrew

Hi

I am trying to install manually. I have downloaded the latest from GitHub and copied to custom components.

I get the error ā€œ504 gateway time-outā€ when I click to add the integration.

Any idea what could be causing this?

Thanks

I just updated to the latest version of the Integrity but on a restart I get the below Error in my logs:

Logger: homeassistant.util.package
Source: util/package.py:98
First occurred: 12:17:21 (3 occurrences)
Last logged: 12:17:39

Unable to install package teslajsonpy==3.7.4: ERROR: Cannot install teslajsonpy==3.7.4 because these package versions have conflicting dependencies. ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts [notice] A new release of pip available: 22.2.1 -> 23.0.1 [notice] To update, run: pip install --upgrade pip

Im still on the previous versions of HA:

Home Assistant 2022.11.5
Supervisor 2022.11.2
Operating System 9.3
Frontend 20221108.0 - latest

I use teslapy to be able to set my PW in to ā€œautonomousā€ mode which I thought allows the highest charging ratesā€¦however I never seen my PW charge more that 3.6kWh. I read in this thread that it should allow charging at 5kWh can anyone confirm this and if there a setting in the direct battery login menu that limits the maximum charging rate?

Thanx.

I thought it might be nice if we share some of our favourite automatons that others can use. Here one thatā€™s working really well for me. I have my battery reserve set to 35% each morning after charging from grid. But then if itā€™s a low solar day you can get down to 35% and then whatā€¦so here is my automation that starts reducing the reserve setting by 5% when the SOC gets to 3% of the set reserveā€¦I.e. It reduces the reserve all the way to 0% rather than keeping a reserve and having to use the grid.

alias: "POWERWALL: Reduce reserve percentage by 5 % "
description: Or when Powerwall charge SOC drops below 35% during day or night
trigger:
  - platform: numeric_state
    entity_id: sensor.powerwall_charge_corrected
    below: 38
  - platform: numeric_state
    entity_id: sensor.powerwall_charge_corrected
    below: 33
  - platform: numeric_state
    entity_id: sensor.powerwall_charge_corrected
    below: 28
  - platform: numeric_state
    entity_id: sensor.powerwall_charge_corrected
    below: 23
  - platform: numeric_state
    entity_id: sensor.powerwall_charge_corrected
    below: 18
  - platform: numeric_state
    entity_id: sensor.powerwall_charge_corrected
    below: 13
  - platform: numeric_state
    entity_id: sensor.powerwall_charge_corrected
    below: 8
condition:
  - condition: numeric_state
    entity_id: sensor.powerwall_charge_corrected
    above: 0
action:
  - service: number.set_value
    data:
      value: "{{states('number.home_energy_gateway_backup_reserve') | float(0) - 5}}"
    target:
      entity_id: number.home_energy_gateway_backup_reserve
mode: single

1 Like

Great idea to share automations.

Practically what is the difference with your automation to just setting your backup reserve to 0% in the first place?

:joy: maybe none!

But I always thought of it as good to have a backup reserve but you are right, Iā€™m effectively overriding that.

I love this thread and have read through it many times. My powerwall was installed last week and I have written automations to change the mode to Time-Based Control and reserve value when my electricity is cheap and I have calculated that I need to charge from the grid. After my 4 hours of cheap electriciy I change the mode back to Self-Powered and reserve back to 10%. Iā€™ve also set up a boolean helper that changes to ā€˜onā€™ when I run the first automation. Iā€™m stuck a bit now on how to revert to Self-Powered and 10% reserve when the Powerwall charge is greater than my set point. Something like IF input_boolean.solar_powerwall_charging = on AND sensor.powerwall_battery_now > input_number.solar_powerwall_reserve_setpoint THEN change mode to Self-Powered and reseve to 10%. Probably missing the obvious but Iā€™ll ask anway.

alias: Powerwall Stop Charging
description: Stop the Powerwall charging when it reaches the set point
trigger:
  - platform: numeric_state
    entity_id: sensor.powerwall_charge_3
    above: input_number.solar_powerwall_reserve_setpoint
condition:
  - condition: state
    entity_id: input_boolean.solar_powerwall_charging
    state: "on"
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.solar_powerwall_charging
  - service: select.select_option
    data:
      entity_id: select.my_home_operation_mode
      option: Self-Powered
  - service: number.set_value
    target:
      entity_id: number.my_home_backup_reserve
    data:
      value: "{{ 10 }}"
mode: single

Here is something similar that I use. I have my powerwall set point called ā€œovernight_powerwall_max_chargeā€ and I also have a EV and Myenergi got water heater (EDDI) so when either of they are ON I just want to stop the PW from further charging but donā€™t want the PW to discharge in to the EV or heat the hot water. So there are some choices that the automation makes to prevent thatā€¦

alias: "POWERWALL: Stop grid charging when SOC > Max overnight charge"
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.powerwall_charge_corrected
    above: input_number.overnight_powerwall_max_charge
  - platform: state
    entity_id:
      - binary_sensor.powerwall_charging
    to: "off"
  - platform: time_pattern
    minutes: /20
  - platform: template
    value_template: |-
      platform: template
      value_template: >-
        {{ states('sensor.powerwall_charge_corrected') | float(0) >  
states('input_number.overnight_powerwall_max_charge') | float(0) + 9 }}
condition:
  - condition: time
    after: "00:30:00"
    before: "04:30:00"
  - condition: template
    value_template: >-
      {{ states('sensor.powerwall_charge_corrected') | float(0) >
      states('input_number.overnight_powerwall_max_charge') | float(0) + 9 }}
action:
  - choose:
      - conditions:
          - condition: not
            conditions:
              - condition: state
                entity_id: binary_sensor.ix_xdrive40_charging_status
                state: "on"
              - condition: state
                entity_id: input_boolean.eddi_boosting
                state: "on"
            enabled: true
        sequence:
          - service: select.select_option
            data:
              option: "No"
            target:
              entity_id: select.home_energy_gateway_grid_charging
          - service: select.select_option
            data:
              option: Self-Powered
            target:
              entity_id: select.home_energy_gateway_operation_mode
          - service: number.set_value
            data:
              value: "0"
            target:
              entity_id: number.home_energy_gateway_backup_reserve
      - conditions:
          - condition: or
            conditions:
              - condition: state
                entity_id: binary_sensor.ix_xdrive40_charging_status
                state: "on"
              - condition: state
                entity_id: input_boolean.eddi_boosting
                state: "on"
        sequence:
          - service: select.select_option
            data:
              option: "No"
            target:
              entity_id: select.home_energy_gateway_grid_charging
          - service: select.select_option
            data:
              option: Backup
            target:
              entity_id: select.home_energy_gateway_operation_mode
          - service: number.set_value
            data:
              value: "100"
            target:
              entity_id: number.home_energy_gateway_backup_reserve
    default:
      - condition: not
        conditions:
          - condition: state
            entity_id: select.home_energy_gateway_grid_charging
            state: "No"
        enabled: true
      - condition: not
        conditions:
          - condition: state
            entity_id: binary_sensor.ix_xdrive40_charging_status
            state: "on"
          - condition: state
            entity_id: input_boolean.eddi_boosting
            state: "on"
        enabled: true
      - service: select.select_option
        data:
          option: "No"
        target:
          entity_id:
            - select.home_energy_gateway_grid_charging
        enabled: true
      - service: select.select_option
        data:
          option: Self-Powered
        target:
          entity_id: select.home_energy_gateway_operation_mode
        enabled: true
      - service: number.set_value
        data:
          value: "0"
        target:
          entity_id: number.home_energy_gateway_backup_reserve
        enabled: true
trace:
  stored_traces: 48
mode: single

1 Like

Very helpful, TYVM.