KNX-Notification with timestamp from Sensor

Hello all,

I have a problem and I just can’t get ahead:
I would like to set a status text via KNX per notify - this also works wonderfully. However, this does not work from an automation.

{{ as_timestamp(states('sensor.dishwasher_remaining_program_time')) | timestamp_custom('%H:%M', false) }}

results:

20:08

But it does not work in automation:

service: notify.knx_kuche_status
data:
  message: {{ as_timestamp(states('sensor.dishwasher_remaining_program_time')) | timestamp_custom('%H:%M', false) }}

results:

template value should be a string for dictionary value @ data[‘message’]. Got None

Do I have a thought error there?

Hi :wave:!

Wrap the template in "" :wink:

service: notify.knx_kuche_status
data:
  message: "{{ as_timestamp(states('sensor.dishwasher_remaining_program_time')) | timestamp_custom('%H:%M', false) }}"

results:

Error rendering data template: ValueError: Template error: as_timestamp got invalid input ‘unknown’ when rendering template ‘{{ as_timestamp(states(‘sensor.dishwasher_remaining_program_time’)) | timestamp_custom(’%H:%M’, false) }}’ but no default was specified

that means that states('sensor.dishwasher_remaining_program_time') results in “unknown”.
So the state of sensor.dishwasher_remaining_program_time is “unknown” (exactly that string) at time of execution.
If this is the case when the dishwasher is not running, you’ll have to handle that case - maybe with an if/else and a variable or something.