Files
Home-AssistantConfig/config/packages/powerwall.yaml

327 lines
11 KiB
YAML
Raw Permalink Normal View History

#-------------------------------------------
# @CCOSTAN
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# Tesla Powerwall - Monitoring and outage automations.
#-------------------------------------------
######################################################################
## Powerwall status sensors and load-shedding helpers.
######################################################################
# Read more: https://www.vcloudinfo.com/2018/01/going-green-to-save-some-green-in-2018.html | Issue #272
# Tesla Powerwall added via UI Integration
# --------------------------------------------------------------
# Binary Sensors:
# - binary_sensor.powerwall_charging ............. battery_charging (on=charging)
# - binary_sensor.powerwall_connected_to_tesla ... connectivity (on=connected)
# - binary_sensor.powerwall_grid_services_active .. power (on=active)
# - binary_sensor.powerwall_grid_status .......... power (on=grid up)
# - binary_sensor.powerwall_status ............... power (on=system ok)
#
# Power & Energy Sensors:
# - sensor.powerwall_charge ...................... battery %, 0100
# - sensor.powerwall_backup_reserve .............. reserve %, 0100
# - sensor.powerwall_battery_power ............... kW (+discharge / -charge)
# - sensor.powerwall_load_power .................. kW house load
# - sensor.powerwall_site_power .................. kW (+export / -import)
# - sensor.powerwall_solar_power ................. kW solar production
#
# Lifetime kWh Meters:
# - sensor.powerwall_battery_export .............. kWh -> grid/load
# - sensor.powerwall_battery_import .............. kWh <- battery charged
# - sensor.powerwall_load_export ................. kWh exported from loads
# - sensor.powerwall_load_import ................. kWh imported to loads
# - sensor.powerwall_site_export ................. kWh site -> grid
# - sensor.powerwall_site_import ................. kWh site <- grid
# - sensor.powerwall_solar_export ................ kWh solar -> site/battery/grid
# - sensor.powerwall_solar_import ................ kWh solar <- grid (rare)
#
# Switches:
# - switch.powerwall_off_grid_operation .......... island mode toggle
######################################################################
2018-03-16 02:17:38 -04:00
#-------------------------------------------
automation:
- alias: Notify if Grid is down
2020-07-20 19:33:03 +01:00
id: 56a32121-5725-4510-a1fa-10f69a5c82ef
trigger:
- platform: state
entity_id: binary_sensor.powerwall_grid_status
condition:
- condition: template
# Check that both current and previous states are not 'unavailable', 'unknown', or 'null'.
value_template: >-
{{ states('binary_sensor.powerwall_grid_status') not in ['unavailable', 'unknown', 'null'] and
trigger.from_state.state not in ['unavailable', 'unknown', 'null'] }}
action:
- service: script.notify_engine
data:
title: "Electrical Grid Status {{ (trigger.to_state.state)|replace('on', 'up')|replace('off', 'down') }}."
value1: "Please verify with the Tesla App."
who: 'parents'
group: 'information'
# https://github.com/CCOSTAN/Home-AssistantConfig/issues/779
- alias: Shut Things down if running on PowerWall
mode: restart
2020-07-20 19:33:03 +01:00
id: 37288a96-5f49-46c2-85c8-7e8794d23612
trigger:
- platform: state
entity_id: binary_sensor.powerwall_grid_status
to: 'off'
action:
- service: homeassistant.turn_off
entity_id:
- group.interior_lights
- group.exterior_lights
- switch.kitchen_accent_2
- switch.master_bathroom_accent_2
- service: script.notify_engine
data:
title: "Electrical Grid Status {{ (trigger.to_state.state)|replace('True', 'up')|replace('False', 'down') }}."
value1: "Taking actions to turning off the House Lights to preserve Battery Power."
who: 'family'
group: 'information'
2020-06-30 14:28:05 -04:00
- delay:
minutes: 1
- service: homeassistant.turn_off
entity_id:
- group.interior_lights
- group.exterior_lights
- switch.kitchen_accent_2
- switch.master_bathroom_accent_2
- service: script.speech_engine
data:
value1: "Because of the Power Outage, the Lights will be recycled for 3 minutes. Lights may turn on and off during this time."
- delay:
minutes: 3
- service: homeassistant.turn_off
entity_id:
- group.interior_lights
- group.exterior_lights
- switch.kitchen_accent_2
- switch.master_bathroom_accent_2
- service: script.speech_engine
data:
value1: "Automatic light recycling has been completed. Any abnormalities will have to be addressed in the Hue App most likely. "
- alias: Powerwall Low Charge Monitoring with Grid Status
id: fda6116b-b2a5-4198-a1ce-4cf4bb3254b2
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.powerwall_charge
below: 60
for:
hours: 24
condition:
- condition: state
entity_id: binary_sensor.powerwall_grid_status
state: 'on'
action:
- service: script.notify_engine
data:
title: "Powerwall Low Charge Alert - Current Charge: {{ states('sensor.powerwall_charge') }}"
value1: "The Powerwall has been below 50% charge for more than 24 hours while the grid is online. This may indicate an issue."
who: 'parents'
group: 'information'
- alias: "Shut down Docker hosts and camera PoE at 75% Powerwall"
id: 25b3d3d8-92fa-454a-9f1c-6d3fd0f3af58
description: "Protect battery by shutting down non-essentials when Powerwall drops below 75%"
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.powerwall_charge
below: 75
for:
minutes: 3
action:
- service: button.press
target:
entity_id:
- button.qemu_docker2_101_shutdown
- button.qemu_docker69_169_shutdown
- service: switch.turn_off
target:
entity_id:
- switch.poe_garage_port_3_poe
- switch.poe_garage_port_4_poe
- switch.poe_garage_port_5_poe
- switch.poe_garage_port_6_poe
- alias: "Powerwall outage - Rheem WH off at night"
id: d686f650-65ad-4cc6-8e27-8b5ee76b5338
description: "During outages, turn off the water heater after sunset to protect battery"
mode: single
trigger:
- platform: sun
event: sunset
- platform: state
entity_id: binary_sensor.powerwall_grid_status
to: 'off'
for:
minutes: 1
condition:
- condition: state
entity_id: binary_sensor.powerwall_grid_status
state: 'off'
- condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
action:
- service: water_heater.set_operation_mode
target:
entity_id: water_heater.rheem_wh
data:
state: off
- alias: "Powerwall outage - Rheem WH heat pump after sunrise and 50%"
id: 7b6e8bb0-7d0c-4e63-89cf-ff6e7811b579
description: "During outages, restore water heater to heat pump once battery is healthy during daytime"
mode: single
trigger:
- platform: sun
event: sunrise
- platform: numeric_state
entity_id: sensor.powerwall_charge
above: 50
for:
minutes: 5
- platform: state
entity_id: binary_sensor.powerwall_grid_status
to: 'off'
for:
minutes: 1
condition:
- condition: state
entity_id: binary_sensor.powerwall_grid_status
state: 'off'
- condition: numeric_state
entity_id: sensor.powerwall_charge
above: 50
- condition: sun
after: sunrise
before: sunset
action:
- service: water_heater.set_operation_mode
target:
entity_id: water_heater.rheem_wh
data:
state: heat_pump
- alias: "Notify to restore PoE ports when grid returns"
id: 1ae8b5c5-8627-4a44-8c8a-5bf8ca5e1bf5
description: "Prompt to turn PoE ports back on after outage shutdown steps"
mode: single
trigger:
- platform: state
entity_id: binary_sensor.powerwall_grid_status
from: 'off'
to: 'on'
for:
minutes: 10
condition:
- condition: or
conditions:
- condition: state
entity_id: switch.poe_garage_port_3_poe
state: 'off'
- condition: state
entity_id: switch.poe_garage_port_4_poe
state: 'off'
- condition: state
entity_id: switch.poe_garage_port_5_poe
state: 'off'
- condition: state
entity_id: switch.poe_garage_port_6_poe
state: 'off'
action:
- service: script.notify_engine
data:
title: "Grid restored - turn PoE ports back on"
value1: "Power is back. Remember to re-enable PoE ports 3-6 if cameras stayed offline."
who: 'family'
group: 'information'
2020-06-30 14:28:05 -04:00
# https://github.com/CCOSTAN/Home-AssistantConfig/issues/547
- alias: Turn off the Nest Thermostats during a Power Outage
2020-07-20 19:33:03 +01:00
id: 022bd9da-ab7c-4c1b-9e95-2ff4ffe5f9cc
2020-06-30 14:28:05 -04:00
trigger:
- platform: state
entity_id: binary_sensor.powerwall_grid_status
to: 'off'
2020-06-30 14:28:05 -04:00
for:
minutes: 6
2020-06-30 14:28:05 -04:00
condition:
- condition: template
value_template: "{{ states('binary_sensor.powerwall_grid_status') == 'off' }}"
2020-06-30 14:28:05 -04:00
action:
- service: climate.turn_off
data:
entity_id:
- climate.downstairs
- climate.upstairs
- service: script.notify_engine
data:
2020-06-30 14:28:05 -04:00
title: "Electrical Grid Status {{ (trigger.to_state.state)|replace('True', 'up')|replace('False', 'down') }}."
value1: "Taking actions to turning off the AC units to preserve Battery Power."
who: 'family'
group: 'information'
2020-06-30 14:28:05 -04:00
- alias: Turn back on the Nest Thermostats after a Power Outage
2020-07-20 19:33:03 +01:00
id: 14faf84b-cb24-4391-a97f-b83479a67fc7
2020-06-30 14:28:05 -04:00
trigger:
- platform: state
entity_id: binary_sensor.powerwall_grid_status
from: 'off'
to: 'on'
2020-06-30 14:28:05 -04:00
for:
minutes: 10
2020-06-30 14:28:05 -04:00
condition:
- condition: template
value_template: "{{ states('binary_sensor.powerwall_grid_status') == 'on' }}"
2020-06-30 14:28:05 -04:00
- condition: or
conditions:
- condition: state
entity_id: climate.downstairs
state: 'off'
- condition: state
entity_id: climate.upstairs
state: 'off'
action:
- service: climate.set_hvac_mode
data:
entity_id: climate.downstairs
hvac_mode: cool
- service: climate.set_hvac_mode
data:
entity_id: climate.upstairs
hvac_mode: cool
- service: climate.set_temperature
data:
entity_id: climate.upstairs
temperature: 80
- service: script.notify_engine
data:
title: "Electrical Grid Status {{ (trigger.to_state.state)|replace('True', 'up')|replace('False', 'down') }}."
value1: "All AC systems are set back to normal operations."
who: 'family'
group: 'information'