Help with formatting time

This code

{% if state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'raw_today') != none %}

{% set remaining_hours = state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'raw_today')|sort(attribute='start') %}

{% set l = (remaining_hours[now().hour+1:])|sort(attribute='value') %}

{% if l|length > 0 %}Den næste billig time er klokken {{ l[0].start.time()}} Prisen er der {{ l[0].value |round (2) }} krone pr kilo watt time{% endif %}

{% else %}

Der er desværre Ingen information om det lige noget.

{% endif %}

gives

Den næste billig time er klokken 12:00:00 Prisen er der 1.09 krone pr kilo watt time

how do I make It to show

Den næste billig time er klokken 12 Prisen er der 1.09 krone pr kilo watt time

{% if state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'raw_today') != none %}

{% set remaining_hours = state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'raw_today')|sort(attribute='start') %}

{% set l = (remaining_hours[now().hour+1:])|sort(attribute='value') %}

{% if l|length > 0 %}Den næste billig time er klokken {{ (l[0].start.time() | string)[0:2]  }} Prisen er der {{ l[0].value |round (2) }} krone pr kilo watt time{% endif %}

{% else %}

Der er desværre Ingen information om det lige noget.

{% endif %}

If it is a datetime value then you might be able to use just .hour() instead of .time(). But the above should also work.

1 Like

Thanks, for your help :slight_smile: