Need fix for: Template error: as_timestamp got invalid input 'unavailable' when rendering template

Hi, I’m getting this error and I’m not able to fix it…

Logger: homeassistant.components.template.template_entity
Quelle: components/template/template_entity.py:101
Integration: Template (Dokumentation, Probleme)
Erstmals aufgetreten: 03:51:43 (6 Vorkommnisse)
Zuletzt protokolliert: 03:51:43

TemplateError('ValueError: Template error: as_timestamp got invalid input 'unavailable' when rendering template '{{ as_timestamp(states('sensor.neff_geschirrspuler_remaining_program_time')) | timestamp_custom('%H:%M') }}' but no default was specified') while processing template 'Template<template=({{ as_timestamp(states('sensor.neff_geschirrspuler_remaining_program_time')) | timestamp_custom('%H:%M') }}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.geschirrspueler_programmende'

Sounds like you have lost connectivity to your dishwasher integration and the value returned for the remaining program time is not valid.

Is it NEFF integration? Have you tried starting the integration in debugging mode and checking the output logs?

You’re right. The NEFF integration.
I didn’t start the integration in debugging mode. As soon as I’m back home, I’ll do.

The remaining program time is only published when the dishwasher is on. Same with the oven and by the way with other errors (Mercedes integration charging end)…

Do you have a greater problem, with your router not fetching the correct time via NTP and allowing devices accessing it over the Internetz?

Check your router NTP settings and make sure a valid NTP server is configured and the local time zone and daylight savings parameters are correct. Use the NPT server local to you, not the global one. Verify the time on the router is updated and correct.

Do you have something filtering NTP traffic?

Your integration may be working correctly, just not getting the correct time. The debugging logs will probably give more clues. Turn on debugging mode, turn your dishwasher on, and then wait a few minutes and turn it back off. Please make sure any logs are posted in formatted format </>

Comment: The integration should allow for graceful degradation rather than crashing for what could be a common problem. Your help could unearth a bug that has been lurking…

I’ll do so…

Morning,

I can exclude a NTP problem in the network. The router is well configured with a local NTP server (german one) and the devices in the network getting the published time without any problems.
I’ll do the debugging as soon as I’m on site…

You have a template with a missing default, which has been a required argument for over 4 years now.

Read this to understand how to set a default & fix the error. Updating Templates with the new default values in 2021.10.x

Thank you. Red it. Might this the right way?

- name: "Ende Geschirrspueler"
        unique_id: geschirrspueler_ende
        state: |
          {% set t = states('sensor.neff_geschirrspuler_remaining_program_time') %}
          {% set t = now() + timedelta(minutes=t | int) if t | is_number else now() %}
          {{ t.strftime("%H:%M") }}

That will work but you might as well use the default argument as shadowfist suggested:

- name: "Ende Geschirrspueler"
        unique_id: geschirrspueler_ende
        state: |
          {% set t = states('sensor.neff_geschirrspuler_remaining_program_time') %}
          {% set t = now() + timedelta(minutes=t | int(0)) %}
          {{ t.strftime("%H:%M") }}

You could also change the device class to a timestamp which will change how it is displayed in the frontend:

- name: "Ende Geschirrspueler"
        unique_id: geschirrspueler_ende
        device_class: timestamp
        state: |
          {% set t = states('sensor.neff_geschirrspuler_remaining_program_time') %}
          {{ now().replace(second=0,microsecond=0) + timedelta(minutes=t | int(0)) }}
1 Like

Thank you.

The first suggestion shows the “actual time” if the device (time) is 0. The second shows the complete timestamp. I just want the time to end in HH:MM. So I did this:

- name: "Geschirrspueler Programmende"
        unique_id: geschirrspueler_ende
        state: >
          {% set t = states('sensor.neff_geschirrspuler_remaining_program_time') | int(-1) %}
          {% if t > 0 %}
            {{ (now() + timedelta(minutes=t)).strftime('%H:%M') }}
          {% else %}
            Nicht verfügbar | Läuft nicht
          {% endif %}