From 829a6f2cf4ef39b5cc9866a6e2e2cc87b62607ea Mon Sep 17 00:00:00 2001 From: "J.P. Krauss" Date: Wed, 3 Aug 2022 16:53:36 -0700 Subject: [PATCH] Update Energy Package --- packages/energy/energy.yaml | 48 +++++++++++++++++++++++++++++++++- packages/energy/energy.yaml.j2 | 48 +++++++++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/packages/energy/energy.yaml b/packages/energy/energy.yaml index e296cf4..b2250d3 100644 --- a/packages/energy/energy.yaml +++ b/packages/energy/energy.yaml @@ -447,6 +447,36 @@ template: + states('sensor.emporia_d937d0_1min')|float }} +# ----------------------------------------------------------------------------- +# TOU Schedules + - name: TOU Season + state: "{{ ['Winter', 'Summer'][now().month >= 6 and now().month < 10] }}" + icon: mdi:weather-cloudy-clock + + - name: TOU Period + icon: mdi:calendar-clock + state: > + {% set is_weekend = now().strftime("%w") == 0 or now().strftime("%w") == 6 %} + {% if states('sensor.tou_season') == "Summer" %} + {% if now().hour >= 16 and now().hour < 21 %} + {% if is_weekend %} + {{ "Mid-Peak" }} + {% else %} + {{ "On-Peak" }} + {% endif %} + {% else %} + {{ "Off-Peak" }} + {% endif %} + {% else %} + {% if now().hour >= 16 and now().hour < 21 %} + {{ "Mid-Peak" }} + {% elif now().hour >= 21 or now().hour < 8 %} + {{ "Off-Peak" }} + {% else %} + {{ "Super Off-Peak" }} + {% endif %} + {% endif %} + # ----------------------------------------------------------------------------- # Utility Meters utility_meter: @@ -459,4 +489,20 @@ utility_meter: - Off-Peak - Mid-Peak - On-Peak - - Surplus + + +automation: +# ----------------------------------------------------------------------------- +# Utility Meter Automations + - alias: Set Utility Meter TOU Tariff + trigger: + - platform: state + entity_id: sensor.tou_period + - platform: homeassistant + event: start + action: + - service: select.select_option + target: + entity_id: select.daily_energy + data: + option: "{{ sensor.tou_period }}" diff --git a/packages/energy/energy.yaml.j2 b/packages/energy/energy.yaml.j2 index 8c04f86..2c46a04 100644 --- a/packages/energy/energy.yaml.j2 +++ b/packages/energy/energy.yaml.j2 @@ -98,6 +98,36 @@ template: + states('sensor.emporia_d937d0_1min')|float }} +# ----------------------------------------------------------------------------- +# TOU Schedules + - name: TOU Season + state: "{{ ['Winter', 'Summer'][now().month >= 6 and now().month < 10] }}" + icon: mdi:weather-cloudy-clock + + - name: TOU Period + icon: mdi:calendar-clock + state: > + {% set is_weekend = now().strftime("%w") == 0 or now().strftime("%w") == 6 %} + {% if states('sensor.tou_season') == "Summer" %} + {% if now().hour >= 16 and now().hour < 21 %} + {% if is_weekend %} + {{ "Mid-Peak" }} + {% else %} + {{ "On-Peak" }} + {% endif %} + {% else %} + {{ "Off-Peak" }} + {% endif %} + {% else %} + {% if now().hour >= 16 and now().hour < 21 %} + {{ "Mid-Peak" }} + {% elif now().hour >= 21 or now().hour < 8 %} + {{ "Off-Peak" }} + {% else %} + {{ "Super Off-Peak" }} + {% endif %} + {% endif %} + # ----------------------------------------------------------------------------- # Utility Meters utility_meter: @@ -110,5 +140,21 @@ utility_meter: - Off-Peak - Mid-Peak - On-Peak - - Surplus + + +automation: +# ----------------------------------------------------------------------------- +# Utility Meter Automations + - alias: Set Utility Meter TOU Tariff + trigger: + - platform: state + entity_id: sensor.tou_period + - platform: homeassistant + event: start + action: + - service: select.select_option + target: + entity_id: select.daily_energy + data: + option: "{{ sensor.tou_period }}"