I am trying to do something seemingly simple, and have exhausted my abilities searching through the forums which end up throwing me in different directions, which use different methods, and so far, 15 different attempts and I am no closer to achieving my goal.
Goal: Use the timestamp from a door/window sensor to print to an e-paper display using lambdas. I only want to access the date/time for the most recent event/state when the door/window sensor was either opened, or closed - it doesn’t matter to me because the sensor is used to detect when a dog food container was last opened/closed. Both opening and closing will happen within a relatively quick time.
I have been directed to create a sensor using templates, but to me, it seems like you should just be able to pull the timestamp from the latest sensor log as the timestamp is there - why the need to create a sensor when said timestamp is already stored. I am a pretty big newbie and have programming challenges, so I would love it if someone could dumb this down a bit. Thanks for any help!
EDIT: I believe I am closer, but still feels like I am unable to do this. I now have a DateTime helper which is working to store the timestamp of the entity. However, I do not know how to use this in the display portion with lambda and keep getting an error because I do not know how to declare and/or store the variable.
There are people that have written blueprints to to that. Perhaps look those up and use or snag the code.
Also I believe there is a native Z2M way to do that in the Z2M add-on/container.
Thank you, I am very close, and have gotten this to work (it prints (2024-06-23 13:52:00) using the code below. However, I would love to format it as (Sunday, 1:52 PM).
Using strftime, with a regular sensor (not text_sensor) complains that it cannot convert float to char. Using strftime with my text_sensor and using %d, etc. I have been completely unsuccessful.
Is this a limitation that I am going to have to live with?
Create a template sensor in HA that turns the ISO date string in the input datetime into the format that you want (see the Time section of the Templating doc) and send that to your ESP device.