Skip to content

Instantly share code, notes, and snippets.

@swilson
Created June 4, 2018 20:33
Show Gist options
  • Save swilson/d2ffc2ef7e580cd1d331895191399515 to your computer and use it in GitHub Desktop.
Save swilson/d2ffc2ef7e580cd1d331895191399515 to your computer and use it in GitHub Desktop.
Home Assistant Ontario Hydro Time-Of-Use sensor
- 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