Hi All
We have scheduled rolling blackouts where I live. We have access to a nice app (with an API) that communicates the next scheduled blackout. Although the API communicates this as an attribute, I managed (as a noob) to extract this into its own sensor.
However, this sensor is not a time class sensor, so it cannot be use as a trigger in the classic time sense. For example, I would like to automate some tasks 1 hour before this scheduled blackout time.
My current yaml configuration to get the sensor is as follows:
# Create Loadshedding sensors
- platform: template
sensors:
# Strip next loadshedding start time from Loadshedding Schedule - this returns hh:mm:ss dd:mm:yyy
loadshedding_local_starttime:
unique_id: "loadshedding_local_starttime"
friendly_name: "Loadshedding Attribute: Next Start Time"
value_template: "{{ state_attr('calendar.loadshedding_local_schedule','start_time') }}"
# Getting Time Only from next load shedding event - this returns hh:mm:ss
loadshedding_local_starttime_next:
unique_id: "loadshedding_local_starttime_next"
friendly_name: "Loadshedding Attribute: Next Start Time (Time Only)"
value_template: >-
{% set time = states('sensor.loadshedding_local_starttime') %}
{% set ftime = as_timestamp(time)|timestamp_custom('%H:%M:%S') %}
{{ ftime }}
The above is successful and returns a state for example
sensor.loadshedding_local_starttime_next = 22:00:00
I am trying to make this sensor a timestamp device class.
Please help?
My current effort looks as follows:
- platform: template
sensors:
# Create Loadshedding sensors in timestamp class
loadshedding_next_timeformat:
device_class: timestamp
unique_id: "loadshedding_next_timeformat"
friendly_name: "Loadshedding Attribute: Next Start Time (Time Format)"
value_template: "{{ states('sensor.loadshedding_local_starttime') }}"
But although the yaml compiles without problem, this returns an unkown value. I suspect that the template platform does not allow timestamp device class, but I have no idea how to change.
Thanks