Skip to content

Sensor for the first occurrence of the month #2256

Answered by igrybkov
igrybkov asked this question in Q&A
Discussion options

You must be logged in to vote

I came up with some solution. Not as elegant as I expected, but it works. So, 1st things I needed was to changed recycling sensor details format to "Generic" so I can have all upcoming dates in a single list.

Then I created new template entity that calculates days until the first recycling of a month.

{% if state_attr('sensor.days_until_recycle_pickup', 'upcoming') | length > 0 %}
{% for pickup in state_attr('sensor.days_until_recycle_pickup', 'upcoming') -%}
  {%- if pickup.date.day < 14 %}{{ ((pickup.date) - now().date()).days }}{% break %}{% endif -%}
{%- endfor %}
{% endif %}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by igrybkov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant