From 45f1c4908627deeb754f14bee60e83f8b3561c8a Mon Sep 17 00:00:00 2001 From: 31c0fe9c6dbd74bcdde92e1d2aaa03e1d272f75f Date: Wed, 31 Aug 2022 14:00:40 +1000 Subject: [PATCH] Home Assistant Git Exporter --- config/packages/sungrow.yaml | 59 +++++++++++++++-------------------- config/zigbee2mqtt/state.json | 8 ++--- 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/config/packages/sungrow.yaml b/config/packages/sungrow.yaml index bc0fd1d..8dbabef 100644 --- a/config/packages/sungrow.yaml +++ b/config/packages/sungrow.yaml @@ -241,21 +241,6 @@ automation: # So, preventing the battery from getting full too early on a sunny day will increase our overall yield, because the # inverter won't have to derate the PV power to 5kW. # - # Possible approaches: - # - # 1. Set general charge/discharge limits or start power for charging from PV[1][2] - # Unfortunately, it seems like these registers don't work on my inverter SH5.0RS, so this avenue is out. - # 2. When PV is >5.0kW and battery is not full (but not too low), set forced charging mode and set the charging power - # to be `PV power - 5.0kW` to maintain 5kW of AC constantly. Unfortunately, forced charge/discharge power register - # (13052) can't be set over Modbus (just ignored). So this option is out _at least until_ this is fixed or I have a - # way to programmatically set this using the SunGather HTTP method (i.e. WiNet-S) - # 3. Set battery mode to Stop when all of: - # * Cloud cover is low / weather is sunny - # * PV power is higher than household demand (by some margin, like 1.5x to minimise grid buying) - # * battery is not too low nor full - # * the forecast has enough remaining in the day to fill battery AND cover remaining household usage (or a proxy - # for this like, `forecast > 2*kWh_till_battery_full`) - # # [1]: https://discord.com/channels/936031869001158666/1008992991643455529 # [2]: https://discord.com/channels/936031869001158666/936031869001158669/1011882768021590036 - id: 05bdc8eb58714c26c2fe @@ -292,16 +277,21 @@ automation: battery_capacity: 12.8 # kWh # Shorthands - current_active_power: "{{ states('sensor.inverter_active_power') | int }}" - current_pv_power: "{{ states('sensor.inverter_pv_power') | int }}" + current_active_power: "{{ states('sensor.inverter_active_power') | int(default=active_power_limit) }}" + current_pv_power: "{{ states('sensor.inverter_pv_power') | int(default=0) }}" current_ems_mode: "{{ states('sensor.inverter_ems_mode_raw') | int(default=-1) }}" current_battery_mode: "{{ states('sensor.inverter_forced_battery_mode_raw') | int(default=0) }}" - battery_level: "{{ states('sensor.inverter_battery_level') | float }}" - forced_battery_power: "{{ states('sensor.inverter_battery_forced_charge_discharge_power') | int }}" - forecast_remaining: "{{ states('sensor.solcast_forecast_remaining_today') | float }}" + battery_level: "{{ states('sensor.inverter_battery_level') | float(default=0) }}" + forced_battery_power: "{{ states('sensor.inverter_battery_forced_charge_discharge_power') | int(default=0) }}" + forecast_remaining: "{{ states('sensor.solcast_forecast_remaining_today') | float(default=0) }}" target_active_power: "{{ active_power_limit - active_power_buffer }}" - desired_forced_battery_power: 2000 + desired_forced_battery_power: > + {% if current_pv_power > target_active_power %} + {{ current_pv_power - target_active_power }} + {% else %} + 10 + {% endif %} is_forced_charging: > {{ current_ems_mode == ems_forced and current_battery_mode == battery_charge }} is_self_consuming: > @@ -309,26 +299,29 @@ automation: kwh_until_full: > {{ battery_capacity * ((100 - battery_level)/100) }} enough_in_day: > - {{2*kwh_until_full < forecast_remaining}} + {{ 2.5 * kwh_until_full < forecast_remaining }} battery_high_enough: "{{ battery_level > battery_lower_limit }}" sunsetting: > - {{ now() + timedelta(hours = 1) > state_attr('sun.sun', 'next_setting')| as_datetime }} + {{ now() + timedelta(hours = 1) > state_attr('sun.sun', 'next_setting') | as_datetime }} should_slow_battery: > - {{ states('sensor.inverter_pv_power') | float > 5100 and - states('sensor.inverter_active_power') | float < 4200 }} + {{ not sunsetting and battery_high_enough and enough_in_day }} action: - - service: input_number.set_value - target: - entity_id: input_number.inverter_forced_mode_battery_power - data_template: - value: "{{ desired_forced_battery_power }}" + # TODO: discharge battery if too high and PV has dropped while forecast remains high - choose: - conditions: - - "{{ should_slow_battery and not sunsetting and enough_in_day }}" + - "{{ should_slow_battery }}" sequence: - - service: script.inverter_force_battery_charge # with low charge rate -- which i have to manually set for now + - service: input_number.set_value + target: + entity_id: input_number.inverter_forced_mode_battery_power + data_template: + value: "{{ desired_forced_battery_power }}" + - condition: "{{ is_self_consuming or not is_forced_charging }}" + - service: script.inverter_force_battery_charge - conditions: - - "{{ states('sensor.inverter_pv_power') | float < 4900 or not enough_in_day or sunsetting }}" + - not: + - "{{ should_slow_battery }}" + - "{{ is_self_consuming }}" sequence: - service: script.inverter_self_consumption default: [] diff --git a/config/zigbee2mqtt/state.json b/config/zigbee2mqtt/state.json index 19ad85e..c6f0629 100644 --- a/config/zigbee2mqtt/state.json +++ b/config/zigbee2mqtt/state.json @@ -17,7 +17,7 @@ "power_outage_count": 8 }, "0x00158d00080915bd": { - "contact": false, + "contact": true, "voltage": 3005, "battery": 44, "temperature": 17, @@ -40,7 +40,7 @@ "battery": 50, "temperature": 12, "linkquality": 255, - "device_temperature": 14, + "device_temperature": 15, "power_outage_count": 13 }, "0x00158d0007e4c4f2": { @@ -53,7 +53,7 @@ "power_outage_count": 41 }, "0x5c0272fffee93bae": { - "occupancy": false, + "occupancy": true, "tamper": false, "battery_low": false, "linkquality": 255 @@ -71,7 +71,7 @@ "battery": 100, "sensitivity": "high", "keep_time": "120", - "illuminance": 826, + "illuminance": 850, "linkquality": 127 }, "0x84b4dbfffe850fda": {