diff --git a/config/packages/energy.yaml b/config/packages/energy.yaml index e5d3dba..413e0ea 100644 --- a/config/packages/energy.yaml +++ b/config/packages/energy.yaml @@ -146,7 +146,7 @@ sensor: # # Note: Ideally, if we drain from battery and then the sun re-charges it, it wouldn't be counted, but that might be trickier so I'll have to work on that later. budgeted_property_power_usage: - unique_id: property_power_usage + unique_id: budgeted_property_power_usage value_template: | {{ [0, (states('sensor.eagle_200_meter_power_demand') | float + states('sensor.inverter_active_power') | float - states('sensor.inverter_pv_power') | float)| round(0)] | max }} unit_of_measurement: W diff --git a/config/packages/meta.yaml b/config/packages/meta.yaml new file mode 100644 index 0000000..65827b7 --- /dev/null +++ b/config/packages/meta.yaml @@ -0,0 +1,20 @@ +automation: + # https://community.home-assistant.io/t/auto-update-esphome-devices-via-automation/536573/15 + - id: 0f9b330f-a026-49bc-9d1e-57d52f5ac625 + alias: Auto-update ESP devices + trigger: + - platform: time_pattern + hours: "3" + minutes: "*" + + condition: + - "{{ states.update | selectattr('entity_id', 'match', 'update\.node\d+_firmware') + | selectattr('state', 'eq', 'on') | list | count > 0 }}" + - "{{ states.update | selectattr('entity_id', 'match', 'update\.node\d+_firmware') + | selectattr('attributes.in_progress') | list | count == 0 }}" + action: + - service: update.install + target: + entity_id: "{{ (states.update | selectattr('entity_id', 'match', 'update\.node\d+_firmware') + | selectattr('state', 'eq', 'on') | first).entity_id }}" + mode: single diff --git a/config/packages/optimise_solar.yaml b/config/packages/optimise_solar.yaml index de289d8..e60a5ba 100644 --- a/config/packages/optimise_solar.yaml +++ b/config/packages/optimise_solar.yaml @@ -293,7 +293,6 @@ template: - unique_id: d257272c-3ac0-4d93-9ef7-00717757cef3 name: Solar forecast remaining pessimistic - state_class: measurement device_class: energy unit_of_measurement: kWh attributes: @@ -303,6 +302,21 @@ template: {% set forecast_hour = states('sensor.solcast_forecast_this_hour') | float(default=0) / 1000.0 %} {{ [0, forecast_remaining - forecast_hour] | max }} + - unique_id: dfdaea61-8c96-4b09-82bf-b76e25800cca + name: Solar future peak amount + device_class: energy + unit_of_measurement: kWh + attributes: + solar: "true" + period_start: >- + {{ (state_attr('sensor.solcast_forecast_today', 'detailedForecast') + | selectattr('period_start', 'ge', now()) + | max(attribute='pv_estimate90')).period_start }} + state: >- + {{ (state_attr('sensor.solcast_forecast_today', 'detailedForecast') + | selectattr('period_start', 'ge', now()) + | max(attribute='pv_estimate90')).pv_estimate90 }} + - unique_id: 6bf7ad20-cf6a-4689-8214-13cd63de80a9 name: Inverter target battery level state_class: measurement @@ -313,7 +327,14 @@ template: {% set battery_lower_limit = states('input_number.inverter_battery_reserve') | int + 5 %} {% set forecast_remaining_pessimistic = states('sensor.solar_forecast_remaining_pessimistic') | float(default=0) %} {% set forecast_total = states('sensor.solcast_forecast_today') | float(default=0) %} - {{ [[battery_lower_limit, 100.0 * (1.0 - (forecast_remaining_pessimistic/forecast_total)) | round(2)] | max, 100] | min }} + + {% if states('sensor.solar_future_peak_amount') | float(default=0) <= 1.5 %} + 100 + {% elif states('sensor.solar_future_peak_amount') | float(default=0) <= 2.5 %} + 90 + {% else %} + {{ [[battery_lower_limit, 100.0 * (1.0 - (forecast_remaining_pessimistic/forecast_total)) | round(2)] | max, 100] | min }} + {% endif %} - unique_id: f603d8f8-92ce-4e77-b271-048110394658 name: Inverter battery mode diff --git a/config/packages/sungrow.yaml b/config/packages/sungrow.yaml index 9edf633..209ccb0 100644 --- a/config/packages/sungrow.yaml +++ b/config/packages/sungrow.yaml @@ -124,6 +124,7 @@ automation: # it will become re-enabled again. enabled_1: | {{ is_state('input_boolean.inverter_charging_schedule_enabled', 'on') and + states('input_number.inverter_charging_schedule_target_soc') | float(default = 0) > states('sensor.inverter_battery_level') | float(default = 0) and not is_state('input_datetime.inverter_charging_schedule_start', 'unknown') and not is_state('input_datetime.inverter_charging_schedule_end', 'unknown')