-
Notifications
You must be signed in to change notification settings - Fork 0
/
energy_smarts.yaml
29 lines (27 loc) · 1.13 KB
/
energy_smarts.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
sensor:
- platform: statistics
name: Average power to grid
entity_id: sensor.solaredge_m1_ac_power
state_characteristic: average_linear
max_age:
minutes: 1
input_number:
demand_warning_threshold:
name: Demand Warning Threshold
min: 0
max: 1
step: 0.01
mode: box
template:
- binary_sensor:
- name: Electricity Import Exceeds Max Demand
state: >-
{% if states('select.electricity_imported_demand') in ['low-demand','high-demand'] %}
{% set min_remaining = 30 - now().minute if now().minute < 30 else 60 - now().minute %}
{% set current_usage = (states('sensor.electricity_imported_demand_high_demand') + states('sensor.electricity_imported_demand_low_demand')) | float(0) * 1000 %}
{% set forecast_usage = states('sensor.average_power_to_grid')|float(0) / -30 %}
{% set threshold = states('input_number.demand_warning_threshold')|float(0.9) %}
{{ current_usage + forecast_usage * min_remaining > states('sensor.electricity_demand_max')|float(0) * 1000 * threshold }}
{% else %}
False
{% endif %}