I’ve searched a lot and tried whatever I could think of but still get the warning on a missing default for a time. It is super annoying that it doesn’t tell me which one as I have multiple, but since it is one warning, and only one of my templates is different from the others, I am guessing it is the last one… but why, I have no idea.
I reviewed the Jinja documentation but I have a lot more learning to do before I understand it…
These are my templates. Can someone kindly help me understand what I did wrong? I copied them from examples I found so and they appear to work but I have no idea whether they are correct.
I believe the “False, 0” part was what made most of the missing default warnings go away, but one is left… Do I have to add a default after “states.sensor.date.state” in the last one? Just guessing…
- sensor:
- name: "Scheduled Alarm Kids"
icon: "hass:clock-outline"
state: "{{ state_attr('input_datetime.scheduled_alarm_kids', 'timestamp') | timestamp_custom('%H:%M', False, 0) }}"
- sensor:
- name: "People Wake-Up Time"
icon: "hass:clock-outline"
state: "{{ state_attr('input_datetime.next_wake_up_alarm_people', 'timestamp') | timestamp_custom('%H:%M', False, 0) }}"
- sensor:
- name: "Adjusted Alarm Kids"
icon: "hass:clock-end"
state: "{{ state_attr('input_datetime.adjusted_alarm_kids', 'timestamp') | timestamp_custom('%H:%M', False, 0) }}"
- sensor:
- name: "Adjusted People Wake-Up Time"
icon: "hass:clock-end"
state: "{{ state_attr('input_datetime.adjusted_people_wake_up_time', 'timestamp') | timestamp_custom('%H:%M', False, 0) }}"
- sensor:
- name: "Expanded Date"
state: "{{ as_timestamp(states.sensor.date.state) | timestamp_custom('%A - %d %B, %Y', False, 0) }}"
icon: "mdi:calendar"
Edit: This is the warning:
2022-02-08 09:03:46 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'timestamp_custom' got invalid input '00:00' when compiling template '{{ '00:00' | timestamp_custom('%H:%M') }}' but no default was specified. Currently 'timestamp_custom' will return '00:00', however this template will fail to render in Home Assistant core 2022.1
Edit2: These templates are part of a Node Red based automation where I went through hell trying to get node red to ignore the date part of the alarm. In some places I managed but in some others it still shows me a date too. It is quite possible that I am also not handling the value type (string/date/time/whatever) which may be what it is complaining about in the first part of the warning. IS that the case? If so I need to go hunt down that issue too.