Last active
March 10, 2022 15:37
-
-
Save JBoye/0fa525123053e5df6a35758e01ec747f to your computer and use it in GitHub Desktop.
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
template: | |
- sensor: | |
- name: Under gennemsnit | |
state: > | |
{% set start_time = now().hour %} | |
{% set prices = (state_attr("sensor.elpris", "today") + state_attr("sensor.elpris", "tomorrow"))[start_time:] %} | |
{% set index = prices.index(prices | select('lt', prices | average) | first) %} | |
{{today_at("00:00") + timedelta(hours = index + start_time)}} |
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
type: custom:html-template-card | |
ignore_line_breaks: true | |
content: > | |
{% set value = states("sensor.billigste_time") | as_datetime %} <div | |
style="display:flex; | |
flex-direction:column;align-items:center;padding:20px;text-align:center"> | |
Start strømslugere{{" om" if value > now() }}: | |
{% if value > now() -%} | |
<h1>{{'%02d' % ((value - now()).total_seconds() / 60 / 60) | round(0, 'floor')}}:{{'%02d' % ((value - now()).total_seconds() / 60 % 60) | round(0, 'floor')}}</h1> | |
{%- else -%} | |
<h1>NU</h1> | |
{%- endif %} | |
</div> |
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
template: | |
- sensor: | |
- name: Billigste time | |
state: > | |
{% set start_time = now().hour %} | |
{% set prices = (state_attr("sensor.elpris", "today") + state_attr("sensor.elpris", "tomorrow"))[start_time:] %} | |
{% set index = prices.index(prices | min) %} | |
{{today_at("00:00") + timedelta(hours = index + start_time)}} |
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
template: | |
- sensor: | |
- name: Billigste time | |
state: > | |
{% set start_time = now().hour %} | |
{% set prices = (state_attr("sensor.elpris", "today") + state_attr("sensor.elpris", "tomorrow"))[start_time:] %} | |
{% set index = prices.index(prices | min) %} | |
{{"I morgen " if index + start_time >= 24}}kl {{((today_at("00:00") + timedelta(hours = index + start_time))).strftime('%H:%M') }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment