-
-
Notifications
You must be signed in to change notification settings - Fork 134
Automations
David Rapan edited this page Jan 17, 2026
·
40 revisions
Change 'entity_ids' and 'device' in following automations accordingly 😉
Energy Management (Time of Use) [Blueprint]
Dependency: Energy Management (w/ Solcast PV Forecast)
alias: "Inverter: Energy Management"
description: Controls the inverter time of use schedule based on electricity prices and solar forecasts.
triggers:
- trigger: state
entity_id:
- sensor.energy_management_battery
- binary_sensor.energy_management_battery_charge_from_grid
- sensor.energy_management_cost_rate
for:
hours: 0
minutes: 0
seconds: 0
- trigger: state
entity_id:
- binary_sensor.inverter_connection
to: "on"
conditions:
- condition: template
value_template: >-
{{ has_value('sensor.energy_management_battery') and
has_value('binary_sensor.energy_management_battery_charge_from_grid') }}
- condition: state
entity_id: binary_sensor.inverter_connection
state: "on"
actions:
- sequence:
- variables:
charge_from_grid: >-
{{ 1 if
is_state('binary_sensor.energy_management_battery_charge_from_grid',
'on') else 0 }}
- action: solarman.read_holding_registers
metadata: {}
data:
count: 7
address: 166
device: bd3eff81f9b0984e91f40426cba9c0e1
response_variable: resp
- if:
- condition: template
enabled: true
value_template: >-
{{ states('sensor.energy_management_battery') | float != resp[166]
or charge_from_grid != resp[172] }}
then:
- action: solarman.write_multiple_registers
metadata: {}
data:
device: bd3eff81f9b0984e91f40426cba9c0e1
address: 166
values:
- "{{ states('sensor.energy_management_battery') }}"
- "{{ states('sensor.energy_management_battery') }}"
- "{{ states('sensor.energy_management_battery') }}"
- "{{ states('sensor.energy_management_battery') }}"
- "{{ states('sensor.energy_management_battery') }}"
- "{{ states('sensor.energy_management_battery') }}"
- "{{ charge_from_grid }}"
- "{{ charge_from_grid }}"
- "{{ charge_from_grid }}"
- "{{ charge_from_grid }}"
- "{{ charge_from_grid }}"
- "{{ charge_from_grid }}"
- if:
- condition: numeric_state
entity_id: sensor.energy_management_compensation_rate
below: 0
then:
- if:
- condition: state
entity_id: switch.inverter_export_surplus
state: "on"
then:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.inverter_export_surplus
- action: number.set_value
metadata: {}
data:
value: "120"
target:
entity_id: number.inverter_zero_export_power
else:
- if:
- condition: state
entity_id: switch.inverter_export_surplus
state: "off"
then:
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.inverter_export_surplus
- action: number.set_value
metadata: {}
data:
value: "20"
target:
entity_id: number.inverter_zero_export_power
mode: single
max_exceeded: silent
alias: "Inverter: Time Synchronization"
description: "Set device's time to `now().replace(microsecond=0) + timedelta(seconds=1)`"
triggers:
- trigger: sun
event: sunrise
offset: 0
- trigger: state
entity_id:
- binary_sensor.inverter_connection
to: "on"
conditions:
- condition: state
entity_id: binary_sensor.inverter_connection
state: "on"
actions:
- data:
datetime: "{{ now().replace(microsecond=0) + timedelta(seconds=1) }}"
target:
entity_id: datetime.inverter_date_time
action: datetime.set_value
max_exceeded: silent
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