Sensor dinâmico para card pôr do sol com nome condicional
sensor:
- platform: template
sensors:
sun_dynamic_sensor:
friendly_name: >
{% if is_state('sun.sun', 'below_horizon') %}
"Nascer do Sol"
{% else %}
"Pôr do Sol"
{% endif %}
value_template: >
{% if is_state('sun.sun', 'below_horizon') %}
{% if state_attr('sun.sun', 'next_rising') %}
{{ state_attr('sun.sun', 'next_rising') | as_timestamp | timestamp_custom('%d-%m-%Y %H:%M') }}
{% else %}
"Unknown"
{% endif %}
{% else %}
{% if state_attr('sun.sun', 'next_dusk') %}
{{ state_attr('sun.sun', 'next_dusk') | as_timestamp | timestamp_custom('%d-%m-%Y %H:%M') }}
{% else %}
"Unknown"
{% endif %}
{% endif %}
device_class: timestamp
attribute_templates:
next_rising: >
{% if state_attr('sun.sun', 'next_rising') %}
{{ state_attr('sun.sun', 'next_rising') | as_timestamp | timestamp_custom('%d-%m-%Y %H:%M') }}
{% else %}
"Unknown"
{% endif %}
next_dusk: >
{% if state_attr('sun.sun', 'next_dusk') %}
{{ state_attr('sun.sun', 'next_dusk') | as_timestamp | timestamp_custom('%d-%m-%Y %H:%M') }}
{% else %}
"Unknown"
{% endif %}
I need that sensor shows me the exactly time of sunrise and sun dusk but now for me shows unknown
better I sayng after sunrise show me Por do sol and exactly time of sun dusk after the sun dusk shows me nascer do show and exactly time of sunrise
but on the time shows me unknown