Hi
Im starting to go through all my logs and fix the no default before it kicks in on 2022.1
Ive sorted some as_timestamps and strptime issues but I have this entity below that I use to extract from google calendar. Its my rugby teams fixtures. This has worked putting at end of the as_timestamp ,0,0) and stopped it appearing in the logs as an error warning.
{% set d = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %d') %}
Currently its out of season, so no fixtures but 2 things. 1 how can I make it show blanks when no data and number 2, how can I get rid of the errors on this.
Thank you
2021-11-30 06:49:56 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'timestamp_custom' got invalid input '0' when rendering template '{%- macro ordinal(num) %} {%- set d = {1:'st',2:'nd',3:'rd'} %} {%- set num = num | int %} {%- if 10 < num % 100 <= 20 %}
{{- num }}th
{%- else %}
{{- num }}{{ d.get(num % 10, 'th') }}
{%- endif %} {%- endmacro %} {% set d = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %d') %} {% set day = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom('%A ' ) %} {% set end = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %B %Y') %} {{ (day) ~ ordinal(d) ~ end }}' but no default was specified. Currently 'timestamp_custom' will return '0', however this template will fail to render in Home Assistant core 2022.1
2021-11-30 06:49:56 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'timestamp_custom' got invalid input '0' when rendering template '{%- macro ordinal(num) %} {%- set d = {1:'st',2:'nd',3:'rd'} %} {%- set num = num | int %} {%- if 10 < num % 100 <= 20 %}
{{- num }}th
{%- else %}
{{- num }}{{ d.get(num % 10, 'th') }}
{%- endif %} {%- endmacro %} {% set d = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %d') %} {% set day = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom('%A ' ) %} {% set end = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %B %Y') %} {{ (day) ~ ordinal(d) ~ end }}' but no default was specified. Currently 'timestamp_custom' will return '0', however this template will fail to render in Home Assistant core 2022.1
2021-11-30 06:49:56 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'timestamp_custom' got invalid input '0' when rendering template '{%- macro ordinal(num) %} {%- set d = {1:'st',2:'nd',3:'rd'} %} {%- set num = num | int %} {%- if 10 < num % 100 <= 20 %}
{{- num }}th
{%- else %}
{{- num }}{{ d.get(num % 10, 'th') }}
{%- endif %} {%- endmacro %} {% set d = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %d') %} {% set day = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom('%A ' ) %} {% set end = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %B %Y') %} {{ (day) ~ ordinal(d) ~ end }}' but no default was specified. Currently 'timestamp_custom' will return '0', however this template will fail to render in Home Assistant core 2022.1
2021-11-30 06:49:56 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'timestamp_custom' got invalid input '0' when rendering template '{%- macro ordinal(num) %} {%- set d = {1:'st',2:'nd',3:'rd'} %} {%- set num = num | int %} {%- if 10 < num % 100 <= 20 %}
{{- num }}th
{%- else %}
{{- num }}{{ d.get(num % 10, 'th') }}
{%- endif %} {%- endmacro %} {% set d = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %d') %} {% set day = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom('%A ' ) %} {% set end = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %B %Y') %} {{ (day) ~ ordinal(d) ~ end }}' but no default was specified. Currently 'timestamp_custom' will return '0', however this template will fail to render in Home Assistant core 2022.1
2021-11-30 06:49:56 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'timestamp_custom' got invalid input '0' when rendering template '{%- macro ordinal(num) %} {%- set d = {1:'st',2:'nd',3:'rd'} %} {%- set num = num | int %} {%- if 10 < num % 100 <= 20 %}
{{- num }}th
{%- else %}
{{- num }}{{ d.get(num % 10, 'th') }}
{%- endif %} {%- endmacro %} {% set d = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %d') %} {% set day = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom('%A ' ) %} {% set end = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %B %Y') %} {{ (day) ~ ordinal(d) ~ end }}' but no default was specified. Currently 'timestamp_custom' will return '0', however this template will fail to render in Home Assistant core 2022.1
Below are the entities pulling the info from google calendar
# Leeds Rhinos Fixtures
- platform: template
sensors:
rhinos_next_game:
value_template: "{{ states.calendar.leeds_rugby.attributes.message }}"
friendly_name: "Next Up"
- platform: template
sensors:
rhinos_next_game_location:
value_template: "{{ states.calendar.leeds_rugby.attributes.location }}"
friendly_name: "Venue"
- platform: template
sensors:
rhinos_next_game_date:
value_template: >
{%- macro ordinal(num) %}
{%- set d = {1:'st',2:'nd',3:'rd'} %}
{%- set num = num | int %}
{%- if 10 < num % 100 <= 20 %}
{{- num }}th
{%- else %}
{{- num }}{{ d.get(num % 10, 'th') }}
{%- endif %}
{%- endmacro %}
{% set d = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %d') %}
{% set day = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom('%A ' ) %}
{% set end = as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'0') | timestamp_custom(' %B %Y') %}
{{ (day) ~ ordinal(d) ~ end }}
friendly_name: "Game Day"
- platform: template
sensors:
rhinos_next_game_kickoff:
value_template: "{{ as_timestamp(strptime(state_attr('calendar.leeds_rugby', 'start_time'), '%Y-%m-%d %H:%M:%S',0),'N/A') | timestamp_custom('%H:%M') }}"
friendly_name: "Kick Off"
- platform: template
sensors:
rhinos_next_game_countdown:
friendly_name: Days to Go
value_template: >
{% set daystogo = strptime(states.calendar.leeds_rugby.attributes.start_time, "%Y-%m-%d %H:%M:%S",0).strftime("%A") %}
{% set daystogo2 = strptime(states.calendar.leeds_rugby.attributes.start_time, "%Y-%m-%d %H:%M:%S",0).strftime("%b %d, %Y") %}
{% if as_timestamp(states.calendar.leeds_rugby.attributes.start_time) / 86400 - as_timestamp(as_timestamp(states.sensor.time.last_updated) | timestamp_custom("%Y-%m-%d 00:00:00",true)) / 86400 == 0.0 %}
TODAY
{% elif as_timestamp(states.calendar.leeds_rugby.attributes.start_time) / 86400 - as_timestamp(as_timestamp(states.sensor.time.last_updated) | timestamp_custom("%Y-%m-%d 00:00:00",true)) / 86400 == 1.0 %}
TOMORROW
{% elif as_timestamp(states.calendar.leeds_rugby.attributes.start_time) / 86400 - as_timestamp(as_timestamp(states.sensor.time.last_updated) | timestamp_custom("%Y-%m-%d 00:00:00",true)) / 86400 >= 7.0 %}
{{ (as_timestamp(states.calendar.leeds_rugby.attributes.start_time) / 86400 + 1 - as_timestamp(states.sensor.time.last_updated) / 86400) | int }} days
{% elif as_timestamp(states.calendar.leeds_rugby.attributes.start_time) / 86400 - as_timestamp(as_timestamp(states.sensor.time.last_updated) | timestamp_custom("%Y-%m-%d 00:00:00",true)) / 86400 >= 2.0 %}
{{ daystogo }}
{% else %}
{{ daystogo if "Unknown" != None else " " }}
{% endif %}
Thank you