diff --git a/README.md b/README.md index faa3d4c..a92152e 100644 --- a/README.md +++ b/README.md @@ -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! ------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/eco7-automations.yaml b/eco7-automations.yaml index 6d93dac..393878d 100644 --- a/eco7-automations.yaml +++ b/eco7-automations.yaml @@ -90,4 +90,54 @@ automations: entity_id: input_number.eco7_target_soc data: value: '{{ states(''sensor.target_battery_charge_weekday'') | int(0) }}' - mode: single \ No newline at end of file + 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 diff --git a/inputs.yaml b/inputs.yaml index 11e6845..024e915 100644 --- a/inputs.yaml +++ b/inputs.yaml @@ -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 @@ -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 @@ -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 @@ -101,4 +127,4 @@ input_number: min: 0 max: 13 step: 0.5 - icon: mdi:home-battery \ No newline at end of file + icon: mdi:home-battery diff --git a/scripts.yaml b/scripts.yaml index fc79f57..f3418f9 100644 --- a/scripts.yaml +++ b/scripts.yaml @@ -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 + diff --git a/solis-template.yaml b/solis-template.yaml index 44e200a..a5f81b0 100644 --- a/solis-template.yaml +++ b/solis-template.yaml @@ -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" @@ -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