I want an automation to run on specific months. It seems you cannot do this simply in HA (what an oversight!). I’ve got this far but got stuck. I’ve created a sensor to identify the current month;
And I’m now trying to use this as a part of a condition in an automation;
- condition: numeric_state
entity_id: sensor.current_month
state:
- 1
- 2
- 3
- 4
- 10
- 11
- 12
However, this doesn’t work. What am I doing wrong?
Sorry for reviving an old thread. I tried to use this condition on the Christmas lights. I want them to trigger in December and January, and I put this in as a condition:
And that will Execute the actions, that is the purpose of the button.
If you want to trigger the automation then edit the trigger to something you can control.
Like an input_boolean for example.
As mentioned by others, manually triggering an automation will only execute the action (the trigger and condition are skipped). Use dennis84de’s suggestion to prevent skipping the condition:
Anyway, I didn’t post just to repeat what others have already stated but to mention that you can streamline your template like this:
condition: '{{ now().month in [1, 12] }}'
It appears on one line because it employs the shorthand notation for Template Conditions. In addition it checks if the current month exists in a list of months. This is a more compact way, especially if there are several possible valid months.
Hey everybody. I have been a Home Assistant user for a few hours and already the friendliness in this community is overwhelming. Thank you all who replied to my question - not only solving my misunderstanding, but even providing a better solution.
I should clarify that the OR-condition with seasons didn’t use to be there, it’s a part of me trying to get this to work at least a little bit.
All the other conditions tests green where expected (it’s not summer so that won’t turn green)
alias: Close Cover at bedtime
description: ''
trigger:
- at: '19:30'
platform: time
condition:
- condition: template
value_template: ' "{{ now().month in [4,5,6,7,8,9,10] }}"'
- condition: state
entity_id: input_boolean.manual_control_barnensrum
state: 'off'
- condition: or
conditions:
- condition: state
entity_id: sensor.season
state: spring
- condition: state
entity_id: sensor.season
state: summer
action:
- data: {}
entity_id: cover.rullgardin_barnens_rum
service: cover.close_cover
- data: {}
entity_id: cover.rullgardin_sovrummet
service: cover.close_cover
- service: cover.close_cover
target:
entity_id: cover.rullgardin_allrum
data: {}
mode: single