Hello! I’m trying to use a Jinja2 template to correctly show me the dates for my waste collection. This is the JSON I’m using to inform two rest sensors. One for the recycling and one for the waste. As far as I’m aware, “grey bins” (landfill) is always position 0 and recycling is always position 1. What I’m finding is, I am needing to manually swap the < for an > every week so far to 'correct the template and get it to show the correct collection! If I don’t do this, it always skips a week. i.e. this morning it was showing me the next collection being on the 4th of March for grey bins, and as soon as I swapped the < for >, I now get recycling happening on 25/2 !
Any ideas?! Thank you!!!
{% set binbags = "states.sensor.testbin_d.state" %}{% set recycle = "states.sensor.testbin_e.state" %}{% if strptime(binbags, "%d/%m/%y") < strptime(recycle, "%d/%m/%y") %}Bin bags on {{ states.sensor.testbin_d.state }}{% else %}Recycling on {{ states.sensor.testbin_e.state }}{% endif %}
@Petro, curious thing if you have a moment? Normally my “put the bloody bins out!!!” trigger triggers on Sunday evening. Which is correct. Bins get collected Monday morning.
Today, out of the blue, it triggers today (a saturday!)
Any ideas why?!
{% set d = (strptime(states('sensor.testbin_d'), '%d/%m/%y')
.timestamp() - 24*60*60)|timestamp_custom('%Y-%m-%d') %}
{{ states('sensor.date_time') == d ~ ', 21:00' }}
I really don’t understand how DST had that effect on the automation but if it’s only once every five years I suppose I can just forget about it! Just don’t understand the logic.
Well you said that daylight savings occurs 1 hour past midnight, and you are 1 hour ahead. In UTC that makes the time change happen at UTC midnight. It’s possible that the time change occurred slightly before midnight UTC which caused the sensor to be off by a day.