128 lines
3.9 KiB
YAML
Executable File
128 lines
3.9 KiB
YAML
Executable File
######################################################################################################
|
|
### @Tesla Powerwall - https://www.vcloudinfo.com/2018/01/going-green-to-save-some-green-in-2018.html
|
|
# # @CCOSTAN
|
|
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
|
|
######################################################################################################
|
|
|
|
#-------------------------------------------
|
|
group:
|
|
Power:
|
|
entities:
|
|
- sensor.grid_status
|
|
- sensor.powerwall_battery_capacity
|
|
- sensor.powerwall_battery_now
|
|
- sensor.grid_now
|
|
- sensor.house_now
|
|
- sensor.solar_now
|
|
- camera.grafana_solar_graph
|
|
#-------------------------------------------
|
|
|
|
sensor:
|
|
- platform: rest
|
|
resource: https://192.168.10.90/api/system_status/grid_status
|
|
verify_ssl: false
|
|
method: GET
|
|
name: Grid Status
|
|
scan_interval: 60
|
|
value_template: "{{ value_json.grid_status == 'SystemGridConnected' }}"
|
|
icon_template: >-
|
|
{%- if is_state('sensor.grid_status', 'True') %}
|
|
mdi:flash
|
|
{%- else %}
|
|
mdi:flash-off
|
|
{%- endif %}
|
|
|
|
- platform: rest
|
|
name: House now
|
|
resource: https://192.168.10.90/api/meters/aggregates
|
|
method: GET
|
|
verify_ssl: false
|
|
value_template: '{{ value_json.load.instant_power / 1000 | round(2) }}'
|
|
unit_of_measurement: kWh
|
|
|
|
- platform: rest
|
|
name: Grid now
|
|
resource: https://192.168.10.90/api/meters/aggregates
|
|
method: GET
|
|
verify_ssl: false
|
|
value_template: '{{ value_json.site.instant_power / 1000 | round(2) }}'
|
|
unit_of_measurement: kWh
|
|
|
|
- platform: rest
|
|
name: Solar now
|
|
resource: https://192.168.10.90/api/meters/aggregates
|
|
method: GET
|
|
verify_ssl: false
|
|
value_template: '{{ value_json.solar.instant_power / 1000 | round(2) }}'
|
|
unit_of_measurement: kWh
|
|
|
|
- platform: rest
|
|
name: PowerWall Battery now
|
|
resource: https://192.168.10.90/api/meters/aggregates
|
|
method: GET
|
|
verify_ssl: false
|
|
value_template: '{{ value_json.battery.instant_power / 1000 | round(2) }}'
|
|
unit_of_measurement: kWh
|
|
icon_template: >-
|
|
{%- if states('sensor.powerwall_battery_now') | float > 0 %}
|
|
mdi:battery
|
|
{%- else %}
|
|
mdi:battery-charging
|
|
{%- endif %}
|
|
|
|
- platform: rest
|
|
name: PowerWall Battery Capacity
|
|
resource: https://192.168.10.90/api/system_status/soe
|
|
method: GET
|
|
verify_ssl: false
|
|
value_template: '{{ (value_json.percentage | float | round(0)) }}'
|
|
unit_of_measurement: '%'
|
|
scan_interval: 300
|
|
icon_template: >-
|
|
{%- set battery = states('sensor.powerwall_battery_capacity') | float %}
|
|
{%- if battery > 90 %}
|
|
mdi:battery
|
|
{%- elif battery > 80 %}
|
|
mdi:battery-90
|
|
{%- elif battery > 70 %}
|
|
mdi:battery-80
|
|
{%- elif battery > 60 %}
|
|
mdi:battery-70
|
|
{%- elif battery > 50 %}
|
|
mdi:battery-60
|
|
{%- elif battery > 40 %}
|
|
mdi:battery-50
|
|
{%- elif battery > 30 %}
|
|
mdi:battery-40
|
|
{%- elif battery > 20 %}
|
|
mdi:battery-30
|
|
{%- elif battery > 10 %}
|
|
mdi:battery-20
|
|
{%- else %}
|
|
mdi:battery-outline
|
|
{%- endif %}
|
|
|
|
#-------------------------------------------
|
|
# Located in the Grafana package. Tweets out Solar Production Daily!
|
|
#
|
|
automation:
|
|
- alias: Notify if Grid is down
|
|
hide_entity: True
|
|
trigger:
|
|
- platform: state
|
|
entity_id: sensor.grid_status
|
|
|
|
condition:
|
|
condition: or
|
|
conditions:
|
|
- condition: template
|
|
value_template: "{{ states('sensor.grid_status') == 'True' }}"
|
|
- condition: template
|
|
value_template: "{{ states('sensor.grid_status') == 'False' }}"
|
|
|
|
action:
|
|
- service: script.notify_engine
|
|
data_template:
|
|
value1: "The electrical grid is reporting to be {{ (trigger.to_state.state)|replace('True', 'up')|replace('False', 'down') }}. Please verify with Tesla App."
|
|
who: 'parents'
|