I’m trying to configure a sensor created from an attribute of a binary sensor to display the date time in a readable format (day of the week and time in 24h format). I am wanting to change the onset and expires sensors.
Currently I have this as my template:
sensor:
- platform: template
sensors:
meteoalarm_onset:
friendly_name: "Meteoalarm - Alert Onset"
value_template: "{{as_timestamp(state_attr('binary_sensor.meteoalarm', 'Onset')) | timestamp_custom('%A %x %X') }}"
meteoalarm_certainty:
friendly_name: "Meteoalarm - Alert Certainty"
value_template: "{{ state_attr('binary_sensor.meteoalarm', 'certainty' ) }}"
meteoalarm_expires:
friendly_name: "Meteoalarm - Alert Expires"
value_template: "{{ state_attr('binary_sensor.meteoalarm', 'expires' ) }}"
meteoalarm_headline:
friendly_name: "Meteoalarm - Alert Headline"
value_template: "{{ state_attr('binary_sensor.meteoalarm', 'headline' ) }}"
meteoalarm_description:
friendly_name: "Meteoalarm - Alert Discription"
value_template: "{{ state_attr('binary_sensor.meteoalarm', 'Description' ) }}"
meteoalarm_instruction:
friendly_name: "Meteoalarm - Alert Instruction"
value_template: "{{ state_attr('binary_sensor.meteoalarm', 'Instruction' ) }}"
and the sensor is showing as unavailable. The sensor before trying to format shows as:
Log error:
TemplateError('ValueError: Template error: as_timestamp got invalid input 'None' when rendering template '{{as_timestamp(state_attr('binary_sensor.meteoalarm', 'Onset')) | timestamp_custom('%A %x %X') }}' but no default was specified') while processing template 'Template<template=({{as_timestamp(state_attr('binary_sensor.meteoalarm', 'Onset')) | timestamp_custom('%A %x %X') }}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.meteoalarm_onset'
As a side point, I’d also like to display the description and instruction attributes as well as currently they only show up as unavailable.
Any ideas?