Created
June 4, 2018 20:33
-
-
Save swilson/d2ffc2ef7e580cd1d331895191399515 to your computer and use it in GitHub Desktop.
Home Assistant Ontario Hydro Time-Of-Use sensor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- platform: template | |
sensors: | |
hydro_rate: | |
# TODO account for holidays | |
value_template: >- | |
{% if now().weekday() > 4 or now().hour < 7 or now().hour >= 19 %} | |
off_peak | |
{% elif now().hour >= 7 and now().hour < 11 %} | |
{% if now().month >= 5 and now().month <= 10 %} | |
mid_peak | |
{% else %} | |
on_peak | |
{% endif %} | |
{% elif now().hour >= 11 and now().hour < 17 %} | |
{% if now().month >= 5 and now().month <= 10 %} | |
on_peak | |
{% else %} | |
mid_peak | |
{% endif %} | |
{% elif now().hour >= 17 and now().hour < 19 %} | |
{% if now().month >= 5 and now().month <= 10 %} | |
mid_peak | |
{% else %} | |
on_peak | |
{% endif %} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment