Hey all. I’m finally playing around with the new sections dashboard layout and it’s pretty great. However, I want to show a card with the next sun rise and sun set but it just displays as “in X hours”. On the my old dashboard layout i could add
entity: sensor.sun_next_rising
format: time
and that would show the actual time (ie: 6:23). But with the new cards I can’t seem to get it to work.
My temporary workaround is just to add an “entity” card. They’re not formatted the same/are a bit bigger than the normal sections cards.
- name: "my sunrise"
icon: mdi:weather-sunset-up
state: "{{ as_timestamp(state_attr('sun.sun', 'next_rising')) |float| timestamp_custom('%-H:%M')}}"
- name: "Coucher du soleil"
unique_id: daylight_remaining
attributes:
friendly_name: "Coucher du soleil"
state: >
{% set now = as_timestamp(now()) %}
{% set lever = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
{% set coucher = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
{% if now < lever %}
{{(coucher - now)|abs|timestamp_custom('%-H:%M',false)}}
{% else %}
0
{% endif %}
And a mushroom template card with this code below which give duration between actual time and the next sunset or if it’s after sunset, the next sunrise time.
type: custom:mushroom-template-card
primary: >-
{% set temperature = states('sensor.airqualityext_temperature') | float |
round (1)%}
{% if temperature == temperature | int %}
{% set result = temperature | int %} {% else %} {% set result = temperature |
round (1) %} {% endif %}
{{ states ('sensor.time') }} | {{ result }}°C
secondary: |
{% set remaining_time = states('sensor.daylight_remaining') %}
{% set sunrise_time = states('sensor.my_sunrise') %}
{% if is_state('binary_sensor.night', 'off') %}
Nuit dans {{ strptime(remaining_time, '%H:%M').strftime('%-Hh%M') }}
{% else %}
Lever à {{ strptime(sunrise_time, '%H:%M').strftime('%-Hh%M') }}
{% endif %}
icon: |
{% if states ('weather.maison') == 'partlycloudy' -%}
mdi:weather-partly-cloudy
{%- elif states ('weather.maison') == 'snowyrainy'-%}
mdi:weather-snowy-rainy
{%- elif states ('weather.maison') == 'lightningrainy'-%}
mdi:weather-lightning-rainy
{%- elif states ('weather.maison') == 'lightningrainy'-%}
mdi:weather-lightning-rainy
{%- else -%}
mdi:weather-{{ states ('weather.maison') }}
{%- endif %}
tap_action:
action: navigate
navigation_path: /lovelace/meteo
fill_container: true
multiline_secondary: true
icon_color: |-
{% if is_state('binary_sensor.night','off') %}
amber
{% else %}
#318ce7
{% endif %}
entity: weather.maison
badge_icon: ''
layout: vertical