Skip to content

Commit

Permalink
Merge pull request #20 from finalbillybong/main
Browse files Browse the repository at this point in the history
Added discharge support
  • Loading branch information
fboundy authored Dec 3, 2023
2 parents 271b560 + 7107616 commit 2606c1b
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Fill in the three input numbers for charge, and set your usable battery capacity

Requires forcast.solar integration: https://www.home-assistant.io/integrations/forecast_solar/

I plan to add support for setting battery discharge times and current to accomodate people who are on the new Octopus Flux tariff. Everything is written for this and being tested now. I should be able to upload in the next week or so.
I have also added support for Discharging - can be used for Flux to discharge at peak times, for Octopus saving sessions. I also use this to dump excess enegry into my EV overnight. It works exactly as the charging. Fill in the inputs for start and stop times and target SOC, the automations do the rest!


-------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
52 changes: 51 additions & 1 deletion eco7-automations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,54 @@ automations:
entity_id: input_number.eco7_target_soc
data:
value: '{{ states(''sensor.target_battery_charge_weekday'') | int(0) }}'
mode: single
mode: single

- id: '1678731184171'
alias: Set Flux Discharge Current
description: >-
Sets the Flux Discharge Current at the start of the Flux period every 5
minutes during the Flux Period provided the Flux input_boolean is on
trigger:
- platform: time_pattern
minutes: "0"
- platform: time_pattern
minutes: /5
- platform: time
at: input_datetime.flux_discharge_start
condition:
- condition: template
value_template: >-
{{(now() >= today_at(states('input_datetime.flux_discharge_start'))) and
(now() < today_at(states('input_datetime.flux_discharge_end'))) and
states('input_boolean.solis_flux_discharging') == 'on'}}
action:
- service: script.solis_set_discharge_current
data:
discharge_current: "{{states('sensor.solis_flux_discharge_current_template') | float}}"
mode: restart

- id: '1678731184172'
alias: " Solis Set Flux Discharge Times "
description: >-
Changes the Fixed Discharging times on the inverter whenever the Flux
input_datetime entities change
trigger:
- platform: time_pattern
minutes: /5
- platform: state
entity_id:
- input_boolean.solis_flux_discharging
condition:
- condition: template
value_template: >-
{{strptime(states('input_datetime.flux_discharge_end'),'%H:%M:%S').time()
>strptime(states('input_datetime.flux_discharge_start'),'%H:%M:%S').time()}}
action:
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- service: script.solis_set_flux_times
data: {}
mode: single
28 changes: 27 additions & 1 deletion inputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ input_boolean:
name: Solis Eco7 Charging
icon: mdi:flash

solis_flux_discharging:
name: Octopus Flux Discharging
icon: mdi:battery-charging-high

saver_session:
name: Saver Session
icon: mdi:transmission-tower
Expand Down Expand Up @@ -45,6 +49,18 @@ input_datetime:
has_time: true
icon: mdi:clock-digital

flux_discharge_start:
name: Discharge Start
has_date: false
has_time: true
icon: mdi:clock-digital

flux_discharge_end:
name: Discharge End
has_date: false
has_time: true
icon: mdi:clock-digital

input_number:
eco7_target_soc:
name: Economy 7 Target SOC
Expand All @@ -56,6 +72,16 @@ input_number:
step: 1
icon: mdi:battery

flux_target_soc:
name: Flux Discharge Target SOC
initial: 60
mode: box
unit_of_measurement: "%"
min: 0
max: 100
step: 1
icon: mdi:battery

solis_battery_capacity:
name: Solis Battery Capacity
initial: 5
Expand Down Expand Up @@ -101,4 +127,4 @@ input_number:
min: 0
max: 13
step: 0.5
icon: mdi:home-battery
icon: mdi:home-battery
33 changes: 33 additions & 0 deletions scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,36 @@ solis_set_eco7_times:
mode: single
icon: mdi:battery-clock-outline

alias: "Solis Set Discharge Current "
sequence:
- service: script.solis_write_holding_register
data:
register_addr: 43142
register_value: "{{ discharge_current * 10 }}"
fields:
solis_set_charge_current:
description: Fixed time charge current (A)
example: 50
mode: single

alias: Solis Set Discharge Times
sequence:
- service: script.solis_write_holding_register
data:
register_addr: 43147
register_value: "{{(states('input_datetime.flux_discharge_start')).split(':')[0] | int}}"
- service: script.solis_write_holding_register
data:
register_addr: 43148
register_value: "{{(states('input_datetime.flux_discharge_start')).split(':')[1] | int}}"
- service: script.solis_write_holding_register
data:
register_addr: 43149
register_value: "{{(states('input_datetime.flux_discharge_end')).split(':')[0] | int}}"
- service: script.solis_write_holding_register
data:
register_addr: 43150
register_value: "{{(states('input_datetime.flux_discharge_end')).split(':')[1] | int}}"
mode: single
icon: mdi:battery-clock-outline

29 changes: 29 additions & 0 deletions solis-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ sensor:
{{max((((today_at(states('input_datetime.economy_7_end')) -
max(now(), today_at(states('input_datetime.economy_7_start')))).total_seconds() / 36) | int) / 100,0)}}
{%- endif %}
- name: "Solis Flux Discharge Hours Remaining"
unique_id: "Solis Flux Discharge Time Remaining"
state_class: measurement
state: >-
{% if today_at(states('input_datetime.flux_discharge_end')) < now() -%}
{{(((today_at(states('input_datetime.flux_discharge_end')) -
today_at(states('input_datetime.flux_discharge_start')))).total_seconds() / 36) | int / 100}}
{%- else -%}
{{max((((today_at(states('input_datetime.flux_discharge_end')) -
max(now(), today_at(states('input_datetime.flux_discharge_start')))).total_seconds() / 36) | int) / 100,0)}}
{%- endif %}
- name: "Solis Eco7 Charge Current"
unique_id: "Solis Eco7 Charge Current"
Expand All @@ -118,6 +130,23 @@ sensor:
/ (states('sensor.solis_battery_voltage_bms') | float) ) | int / 10
}}
- name: "Solis Flux Discharge Current"
unique_id: "Solis Flux Discharge Current"
device_class: current
state_class: measurement
unit_of_measurement: A
state: >-
{% set value = (
((states('input_number.solis_battery_capacity') | int * 1000) *
((states('sensor.solis_battery_soc') | int) - (states('input_number.flux_target_soc') | int))
)
/ 10
/
(states('sensor.solis_flux_discharge_hours_remaining') | float)
/ (states('sensor.solis_battery_voltage_bms') | float) ) | int / 10 %}
{{ value if value >= 0 else 0 }}
- name: "Solis Battery Charge Power"
unique_id: "Solis Battery Charge Power"
device_class: power
Expand Down

0 comments on commit 2606c1b

Please sign in to comment.