Last active
February 16, 2023 17:55
-
-
Save bphermansson/8fd6ce21808b01c3f543edf2498959fc to your computer and use it in GitHub Desktop.
Code snippet to get number of hours until the electricity is cheap(?).
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
{% set hour_when = as_timestamp(state_attr('binary_sensor.nordpool_planner_time_when_low_electricity_price', 'starts_at'))|int%} | |
{% set real_hour = (state_attr('binary_sensor.nordpool_planner_time_when_low_electricity_price', 'starts_at')) %} | |
Electricity is cheap at: {{ real_hour }} | |
{% set time_now = as_timestamp(now())|int%} | |
{% set hour_now = time_now|timestamp_custom('%H') %} | |
{% set hours_until = -((time_now - hour_when)|int/3600)|int %} | |
Hours left until cheap electricity: {{ hours_until }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment