Hoping I haven’t put @jbardi on the spot; I just respect his skills. (If I have, please accept my apologies.)
That would be very nice… I still think Daemon is something out of Poltergeist…
p.s. In the AppDaemon Q&A there is already some content to use AppDaemon for dumies like me (starts here AppDaemon Q&A) but we are actually stuck.
I may have found a painfully long resolution to this. Time & Date - Home Assistant
For one year you would have to create up to 26 automations and edit them at the start of each new year!!! Hopefully there will be a better way to go about this by then.
Anyway would something like this work?
- alias: automation for schedule 1of26
trigger:
platform: state
entity_id: sensor.date
state: '2016-10-05'
condition:
condition: state
entity_id: sensor.time
state: '16:33'
action:
service: service.do_something
entity_id: entity.you_want
Now you just have to do this again and again for every date and time you need, at least through 2016 (Potentially 8 automations).
Regards
Would also love a walk through to get started. I’m using Docker for all my components/setup and would love to add AppDaemon and Node-Red (and HADashboard) to beef it up. My big thing is finding AppDaemon examples and a “starting point”.
Coming across this while looking for an “every other week” for a “take out the recyclables” reminder.
I don’t think that this particular example would work - at least as it is. I think you need the time to be the trigger and the time and the condition would be the date. Otherwise, you’d get a trigger as the date changes, but the condition would halt it.
I got thinking - a date can be formatted as “week of year” (the first week of Jan is 1, the last week of Dec is 52). I wonder if you could format “today’s” date like that, then check to see if the result is even or odd.
You are correct, I did not test the automation. I was just looking for a way to run a service on a specific date and time within HA.
This does work…
- alias: automation time and date
trigger:
platform: state
entity_id: sensor.time
state: '12:30'
condition:
condition: state
entity_id: sensor.date
state: '2016-10-05'
action:
service: switch.turn_on
entity_id: switch.wemo_switch
Thanks again!
By the way I have solved this via IFTT which as least up till now works reliable.
- Created the events I need in Google calendar
- Created a select_input in HASS (in my case with three option: Away, Sleep, Warm)
- Created the recipes in IFTT (search for keyword). One for each input select value (so 3). For people that don’t know how to do this, check out Bruhs video https://www.youtube.com/watch?v=-Tkb04xRs-o)
- Recipes switch the HASS input_select to the appropriate value
- Hass Automation triggers on value input_select
First I had input Booleans but as the IFTT automation triggers an ‘ON’ only, I had to make automation to put it off when anther boolean goes ‘ON’. Much easier to just use input_select
i am a very big fan off appdaemon but making a automation going every other week could also be done with a template which determines if the week is odd or even.
value_template: {%if (now.isocalendar()[1]/2)|round(0)==(now.isocalendar()[1]/2)%}true{%else%}false{%endif%}
this gives true for even week and fals for odd weeks.
Hello,
Would like to set similar but for days not weeks
Thanks
Do you mean you want a template that will evaluate to true every other day? If so:
{{ now().timetuple().tm_yday % 2 == 0 }}
The caveat being that it will probably be wrong on January 1, since most years have an odd number of days.
EDIT: Wait! This is probably better:
{{ now().timestamp()|int % 2 == 0 }}
Would like to give true on odd days and false on even days
{{ now().timestamp()|int % 2 == 1 }}
By “odd days”, do you mean odd days of the month? I thought you just wanted something that was true every other day, continually. So, for example, if it is true on January 31, do you want it to be true or false on February 1?
Thanks so much!
I would like to fire automations every odd day of the month or vice versa
For example: automation should run on 1-3-5…31 dated days
Or should run 2-4-6…30th days of the month
If 2 days have same out put for the last of the month it doesn’t matter
Thanks again
Ok, for true on even numbered days of the month:
{{ now().day % 2 == 0 }}
and for true on odd numbered days of the month:
{{ now().day % 2 == 1 }}
Really appreciate your support!
Many thanks
Hey everyone, please if any one could answer this. How should I do to get a template sensor that just displays the current week as a number? for example “30” as it is now.
sensor:
- platform: time_date
display_options:
- 'date'
- platform: template
sensors:
week:
friendly_name: Week Number
value_template: >
{{ strptime(states('sensor.date'), '%Y-%m-%d').strftime('%V') }}
Depending on how your sensor.date is formatted, you may need to adjust the strptime format string accordingly.
Thank you sooo much, you’re a godsend!