So I have this template to monitor a non-smart dryer. The goal is to keep track of the timestamp the dryer completes its cycle. I already have a sensor to track the status of the dryer based on consumption, but the timestamp sensor is not updated (or not displayed? I don’t know!)
I think the sensor is populated because if I put this in the Developer Tools → Template I can see {{ now() }} is correctly converted to a timestamp, but if I put the sensor in a card, the output is “Unknown”
I am also pretty sure about the dryer.dryer_status transition to “Done” as I use it in automation for notifications, and it works.
Please feel free to correct any wrong assumption I made, as I started using HA a copule of months ago
It is wise to pick a standard (two spaces) for indentation and stick to it but as long as you are consistent within each block it is ok. So no that is not your issue.
Has the dryer status changed from something to Done?
Yours is not ideal but is fine. As each block has consistent indentation. e.g.
OK:
- something: # this is a block of yaml with consistent indentation
- petunias
- a_whale
- fortytwo
- something_else: # this is a completely separate block of yaml with consistent but different indentation
- trillian
- marvin
- slartibartfast
This is not OK:
- something: # this is a block of yaml with inconsistent indentation
- petunias
- a_whale
- fortytwo
- something_else: # this is a completely separate block of yaml also with inconsistent indentation
- trillian
- marvin
- slartibartfast
Ok I found the problem,
I referenced the entity_id in the trigger with the unique_id and not with the entity_id
# Not Working
- trigger:
- platform: state
entity_id: dryer.dryer_status # using the wrong unique_id
to: "Done"
sensor:
- name: dryer_last_cycle_end
device_class: timestamp
unique_id: dryer.dryer_last_cycle_end
state: "{{ now() }}"
# Working
- trigger:
- platform: state
entity_id: sensor.dryer_status # using the correct entity_id
to: "Done"
sensor:
- name: dryer_last_cycle_end
device_class: timestamp
unique_id: dryer.dryer_last_cycle_end
state: "{{ now() }}"