Skip to content

Commit

Permalink
Added check solar assistant script to octopus energy.
Browse files Browse the repository at this point in the history
Update #108
  • Loading branch information
dannytsang committed Nov 2, 2024
1 parent abc3ad9 commit 2ce78fa
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 93 deletions.
52 changes: 17 additions & 35 deletions packages/integrations/energy/octopus_energy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ automation:
conditions: []
actions:
- parallel:
- alias: Check Solar Assistant
if:
- condition: state
entity_id: input_boolean.enable_solar_assistant_automations
state: "on"
- not:
- condition: state
entity_id: select.growatt_sph_work_mode_priority
state: "unavailable"
then:
- action: script.solar_assistant_check_charging_mode
data:
event: "event"
current_electricity_import_rate: "{{ states('sensor.electricity_current_rate') }}"
current_electricity_import_rate_unit: "{{ state_attr('sensor.electricity_current_rate', 'unit_of_measurement') }}"
current_electricity_export_rate: "{{ states('sensor.electricity_export_current_rate') }}"
current_electricity_export_rate_unit: "{{ state_attr('sensor.electricity_export_current_rate', 'unit_of_measurement') }}"
- alias: Check Zappi
choose:
- conditions:
Expand Down Expand Up @@ -88,41 +105,6 @@ automation:
current_electricity_import_rate_unit: "{{ state_attr('sensor.electricity_current_rate', 'unit_of_measurement') }}"
default: []
#region Solar Assistant
- id: "1691009694613"
alias: "Octopus Energy: Current Rate Change"
description: ""
triggers:
- trigger: numeric_state
entity_id: sensor.electricity_current_rate
below: sensor.electricity_export_current_rate
id: event
- trigger: state
entity_id: sensor.electricity_current_rate
to: sensor.electricity_export_current_rate
id: event
- trigger: numeric_state
entity_id: sensor.electricity_current_rate
below: 0
id: event
- trigger: state
entity_id: sensor.electricity_current_rate
to: "0"
id: event
conditions: []
actions:
- if:
- condition: state
entity_id: input_boolean.enable_solar_assistant_automations
state: "on"
- not:
- condition: state
entity_id: select.growatt_sph_work_mode_priority
state: "unavailable"
then:
- action: script.solar_assistant_check_charging_mode
data:
event: "event"
mode: restart
- id: "1689626117481"
alias: "Solar Assistant: Electricity Rates Starts To Cost"
description: ""
Expand Down
120 changes: 62 additions & 58 deletions packages/integrations/energy/solar_assistant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ automation:
- action: script.solar_assistant_check_charging_mode
data:
event: "event"
current_electricity_import_rate: "{{ states('sensor.electricity_current_rate') }}"
current_electricity_import_rate_unit: "{{ state_attr('sensor.electricity_current_rate', 'unit_of_measurement') }}"
current_electricity_export_rate: "{{ states('sensor.electricity_export_current_rate') }}"
default:
- choose:
- conditions:
Expand All @@ -53,38 +56,17 @@ automation:
- action: script.solar_assistant_check_charging_mode
data:
event: "time"
current_electricity_import_rate: "{{ states('sensor.electricity_current_rate') }}"
current_electricity_import_rate_unit: "{{ state_attr('sensor.electricity_current_rate', 'unit_of_measurement') }}"
current_electricity_export_rate: "{{ states('sensor.electricity_export_current_rate') }}"
default:
- action: script.solar_assistant_check_charging_mode
data:
event: "event"
current_electricity_import_rate: "{{ states('sensor.electricity_current_rate') }}"
current_electricity_import_rate_unit: "{{ state_attr('sensor.electricity_current_rate', 'unit_of_measurement') }}"
current_electricity_export_rate: "{{ states('sensor.electricity_export_current_rate') }}"
mode: restart
# Octopus
- id: "1708679917302"
alias: Solar Assistant Target Octopus Rate Turned On
description: ""
triggers:
- trigger: state
entity_id:
- binary_sensor.octopus_energy_target_overnight_home_battery_charge_6_hours
to: "on"
conditions:
- condition: state
entity_id: input_boolean.charge_octopus_schedule
state: "on"
- condition: state
entity_id: input_boolean.enable_solar_assistant_automations
state: "on"
actions:
- parallel:
- action: script.send_to_home_log
metadata: {}
data:
log_level: Debug
message: Target battery charge turned on.
title: Solar Assistant
- action: script.solar_assistant_check_charging_mode
data: {}
mode: single

script:
battery_first_priority_mode:
Expand Down Expand Up @@ -420,7 +402,36 @@ script:
options:
- event
- time
current_electricity_import_rate:
description: Pounds per kiloWatt for importing.
example: "0.1501"
selector:
number:
min: -15
max: 100
step: 2
current_electricity_import_rate_unit:
description: Unit describing the unit rate.
example: "GBP/kWh"
selector:
text:
current_electricity_export_rate:
description: Pence per kiloWatt for exporting.
example: "0.15"
selector:
number:
min: 0
max: 50
step: 2
current_electricity_export_rate_unit:
description: Unit describing the unit rate.
example: "GBP/kWh"
selector:
text:
sequence:
- variables:
current_import_rate: "{{ current_electricity_import_rate|default(states('sensor.electricity_current_rate'), true) }}"
current_export_rate: "{{ current_electricity_export_rate|default(states('sensor.electricity_current_rate'), true) }}"
- if:
- condition: time
after: "00:00:00"
Expand Down Expand Up @@ -536,9 +547,8 @@ script:
max_charge: "{{ states('sensor.growatt_sph_battery_state_of_charge')|float(100) }}"
- alias: "Unit rate is 0p/kw"
conditions:
- condition: state
entity_id: sensor.electricity_current_rate
state: "0.0"
- condition: template
value_template: "{{ current_import_rate == 0 }}"
- condition: state
entity_id: input_boolean.solar_assistant_charge_electricity_cost_nothing
state: "on"
Expand All @@ -559,7 +569,7 @@ script:
data:
message: >-
Electrictity rate is
({{ states('sensor.electricity_current_rate', with_unit=True) }})p/kw
({{ current_import_rate ~ ' ' ~ current_electricity_import_rate_unit }})p/kw
and inverter has not switched from
{{ states('sensor.growatt_sph_inverter_mode') }} to load first mode.
title: Solar Assistant
Expand All @@ -571,7 +581,7 @@ script:
data:
message: >-
Electrictity rate costs nothing
({{ states('sensor.electricity_export_current_rate', with_unit=True) }}).
({{ current_export_rate ~ ' ' ~ current_electricity_export_rate_unit }}).
Charging house battery.
title: Solar Assistant
people:
Expand All @@ -586,9 +596,8 @@ script:
data: {}
- alias: "Unit rate is below 0p/kw"
conditions:
- condition: numeric_state
entity_id: sensor.electricity_current_rate
below: "0"
- condition: template
value_template: "{{ current_import_rate < 0 }}"
- condition: state
entity_id: input_boolean.solar_assistant_charge_electricity_cost_below_nothing
state: "on"
Expand All @@ -609,7 +618,7 @@ script:
data:
message: >-
Electrictity rate has gove below 0
({{ states('sensor.electricity_current_rate', with_unit=True) }})p/kw
({{ current_import_rate ~ ' ' ~ current_electricity_import_rate_unit }})p/kw
and inverter has not switched from
{{ states('sensor.growatt_sph_inverter_mode') }} to load first mode.
title: Solar Assistant
Expand All @@ -621,7 +630,7 @@ script:
data:
message: >-
Electrictity rate
({{ states('sensor.electricity_current_rate', with_unit=True) }}) has fallen
({{ current_import_rate ~ ' ' ~ current_electricity_import_rate_unit }}) has fallen
below 0.00 GBP/kWh.
Charging house battery.
title: Solar Assistant
Expand All @@ -637,12 +646,10 @@ script:
data: {}
- alias: Unit rate below export and charge below export enabled
conditions:
- condition: numeric_state
entity_id: sensor.electricity_current_rate
below: sensor.electricity_export_current_rate
- condition: numeric_state
entity_id: sensor.electricity_current_rate
above: 0
- condition: template
value_template: "{{ current_import_rate < current_electricity_export_rate }}"
- condition: template
value_template: "{{ current_import_rate > 0 }}"
- or:
- condition: state
entity_id: input_boolean.enable_permanent_charge_below_export
Expand Down Expand Up @@ -685,8 +692,8 @@ script:
data:
message: >-
Electrictity rate
({{ states('sensor.electricity_current_rate', with_unit=True) }}) has fallen
below export ({{ states('sensor.electricity_export_current_rate', with_unit=True) }})
({{ current_import_rate ~ ' ' ~ current_electricity_import_rate_unit }}) has fallen
below export ({{ current_export_rate ~ ' ' ~ current_electricity_export_rate_unit }})
and inverter has not switched to battery first mode.
title: Solar Assistant
people:
Expand All @@ -697,8 +704,7 @@ script:
data:
message: >-
Electricity unit rate is below export rate
({{ states('sensor.electricity_current_rate') ~'<=' ~
states('sensor.electricity_export_current_rate') }}). Charging house battery.
({{ current_import_rate ~'<=' ~ current_export_rate }}). Charging house battery.
title: Solar Assistant
debug: "Debug"
- action: number.set_value
Expand All @@ -713,9 +719,8 @@ script:
- condition: state
entity_id: input_boolean.enable_target_electricity_unit_rate
state: "on"
- condition: numeric_state
entity_id: sensor.electricity_current_rate
below: input_number.target_electricity_unit_rate
- condition: template
value_template: "{{ current_import_rate < states('input_number.target_electricity_unit_rate')|float(0) }}"
sequence:
- if:
- not:
Expand All @@ -733,8 +738,8 @@ script:
data:
message: >-
Electrictity rate
({{ states('sensor.electricity_current_rate')|round(0) }}) has fallen
below export ({{ states('sensor.electricity_export_current_rate', with_unit=True) }})
({{ current_import_rate }}) has fallen
below export ({{ current_export_rate ~ ' ' ~ current_electricity_export_rate_unit }})
and inverter has not switched to battery first mode.
title: Solar Assistant
people:
Expand All @@ -745,7 +750,7 @@ script:
data:
message: >-
Electricity unit rate is below target rate
({{ states('sensor.electricity_current_rate')|round(0) ~'<=' ~
({{ current_import_rate|round(0) ~'<=' ~
states('input_number.target_electricity_unit_rate') }}). Charging house battery.
title: Solar Assistant
debug: "Debug"
Expand Down Expand Up @@ -1056,9 +1061,8 @@ script:
continue_on_error: true
- alias: Rates go above export fail safe
conditions:
- condition: numeric_state
entity_id: sensor.electricity_current_rate
above: sensor.electricity_export_current_rate
- condition: template
value_template: "{{ current_import_rate > current_export_rate }}"
- not:
- condition: state
entity_id: select.growatt_sph_work_mode_priority
Expand All @@ -1071,8 +1075,8 @@ script:
data:
message: >-
Electrictity rate has gove above export
({{ states('sensor.electricity_export_current_rate', with_unit=True) }})
{{ states('sensor.electricity_current_rate', with_unit=True) }}
({{ current_export_rate ~ ' ' ~ current_electricity_export_rate_unit }})
{{ current_import_rate ~ ' ' ~ current_electricity_import_rate_unit }}
and inverter has not switched from
{{ states('sensor.growatt_sph_inverter_mode') }} to load first mode.
Expand Down

0 comments on commit 2ce78fa

Please sign in to comment.