-
-
Notifications
You must be signed in to change notification settings - Fork 134
Automations
David Rapan edited this page Apr 3, 2025
·
40 revisions
Change 'entity_ids' in following automations accordingly 😉
Dependency: Czech Energy Spot Prices, Solcast PV Forecast
alias: Inverter Time of Use
description: >-
Controls all Time of Use programs at once throughout the day based on the spot
electricity price and solar forecast
triggers:
- trigger: state
entity_id:
- sensor.grid_metrics_total_cost
- binary_sensor.spot_electricity_is_cheapest
- binary_sensor.energy_prices_electricity_is_below_average
for:
hours: 0
minutes: 0
seconds: 15
conditions: []
actions:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.energy_prices_electricity_is_cheapest
state: "on"
- condition: time
before: "08:00:00"
sequence:
- sequence:
- action: solcast.update_forecasts
data: {}
- action: solarman.write_multiple_registers
metadata: {}
data:
device: bd3eff81f9b0984e91f40426cba9c0e1
address: 166
values:
- "{{ states('sensor.inverter_battery_precharge') }}"
- "{{ states('sensor.inverter_battery_precharge') }}"
- "{{ states('sensor.inverter_battery_precharge') }}"
- "{{ states('sensor.inverter_battery_precharge') }}"
- "{{ states('sensor.inverter_battery_precharge') }}"
- "{{ states('sensor.inverter_battery_precharge') }}"
- 1
- 1
- 1
- 1
- 1
- 1
- conditions:
- condition: state
entity_id: binary_sensor.energy_prices_electricity_is_below_average
state: "on"
- condition: time
before: "08:00:00"
sequence:
- sequence:
- action: solcast.update_forecasts
data: {}
- action: solarman.write_multiple_registers
metadata: {}
data:
device: bd3eff81f9b0984e91f40426cba9c0e1
address: 166
values:
- "{{ states('sensor.inverter_battery_precharge') }}"
- "{{ states('sensor.inverter_battery_precharge') }}"
- "{{ states('sensor.inverter_battery_precharge') }}"
- "{{ states('sensor.inverter_battery_precharge') }}"
- "{{ states('sensor.inverter_battery_precharge') }}"
- "{{ states('sensor.inverter_battery_precharge') }}"
- 0
- 0
- 0
- 0
- 0
- 0
- conditions:
- condition: state
entity_id: binary_sensor.energy_prices_electricity_is_cheapest
state: "on"
sequence:
- action: solarman.write_multiple_registers
metadata: {}
data:
device: bd3eff81f9b0984e91f40426cba9c0e1
address: 166
values:
- 90
- 90
- 90
- 90
- 90
- 90
- 1
- 1
- 1
- 1
- 1
- 1
- conditions:
- condition: state
entity_id: binary_sensor.energy_prices_electricity_is_below_average
state: "on"
sequence:
- action: solarman.write_multiple_registers
metadata: {}
data:
device: bd3eff81f9b0984e91f40426cba9c0e1
address: 166
values:
- 80
- 80
- 80
- 80
- 80
- 80
- 0
- 0
- 0
- 0
- 0
- 0
default:
- action: solarman.write_multiple_registers
metadata: {}
data:
device: bd3eff81f9b0984e91f40426cba9c0e1
address: 166
values:
- 20
- 20
- 20
- 20
- 20
- 20
- 1
- 1
- 1
- 1
- 1
- 1
mode: single
*sensor.grid_metrics_total_cost holds price for current hour
*binary_sensor.energy_prices_electricity_is_cheapest is On during few cheapest hours
*binary_sensor.energy_prices_electricity_is_below_average is On during below average price hours
Everything is calculated including the distribution part of the price.
And create following template sensor sensor.inverter_battery_precharge:
{% set n = now() %}
{% set d = n.weekday() %}
{% set v = states('sensor.solcast_pv_forecast_forecast_today') | float %}
{% if n.hour > 6 %}
{% set v = states('sensor.solcast_pv_forecast_forecast_tomorrow') | float %}
{% set d = (d + 1) if d < 6 else 0 %}
{% endif %}
{% if v > 50 %}
{{ 20 }}
{% elif v > 40 %}
{{ 25 }}
{% elif v > 35 %}
{{ 30 }}
{% elif v > 30 or (v > 20 and d > 4) %}
{{ 40 }}
{% elif v > 25 or (v > 15 and d > 4) %}
{{ 50 }}
{% elif v > 20 or (v > 10 and d > 4) %}
{{ 60 }}
{% elif v > 10 or (v > 5 and d > 4) %}
{{ 80 }}
{% else %}
{{ 90 }}
{% endif %}
Description: Control energy surplus export according current spot price
Dependency: Czech Energy Spot Prices
alias: Inverter Grid Export Surplus
description: Export Surplus when non negative spot price
trigger:
- platform: template
value_template: "{% if has_value('sensor.current_spot_electricity_price') %}true{% endif %}"
condition: []
action:
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.current_spot_electricity_price
below: 0
- condition: state
entity_id: switch.inverter_grid_export_surplus
state: "on"
sequence:
- service: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.inverter_grid_export_surplus
- conditions:
- condition: numeric_state
entity_id: sensor.current_spot_electricity_price
above: 0
- condition: state
entity_id: switch.inverter_grid_export_surplus
state: "off"
sequence:
- service: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.inverter_grid_export_surplus
mode: single
alias: Inverter time synchronization
description: Set device's time to `now()`
trigger:
- platform: time
at: sensor.sun_next_dawn
- event: start
trigger: homeassistant
actions:
- data:
datetime: "{{ now() }}"
target:
entity_id: datetime.inverter_date_time
action: datetime.set_value
mode: single
alias: PVOutput Uploader
description: Uploads production data to PVOutput
trigger:
- platform: time_pattern
minutes: /5
action:
- service: rest_command.pvoutput_upload
data: {}
mode: single
And configure RESTful Command in configuration.yaml:
rest_command:
pvoutput_upload:
url: https://pvoutput.org/service/r2/addstatus.jsp
method: post
content_type: "application/x-www-form-urlencoded"
headers:
X-Pvoutput-Apikey: KEY
X-Pvoutput-SystemId: ID
payload: "d={{now().strftime('%Y%m%d')}}&t={{now().strftime('%H:%M')}}&c1=1&v1={{(states('sensor.inverter_total_production'))|float*1000|round(0)}}"
Replace KEY and ID using yours. More 'bout the parameters here