I was looking for an alarm clock and was slightly surprised to not find a built in version, as I would have thought this would be one of the most used things when you start going into the world of smart home.
I found this Creating an Alarm Clock Updated! very cool post but that was a lot of code in my configuration.yaml. I also wanted some reusable code, as I need more than one alarm clock. So I encapsulated the code I foundin this post into a more generic and reusable package.
This is how it looks (I added the alarm to a group along the temperate I would like to have my room to be heated up):
Note: This solution is using packages. They are not yet supported by the automation editor or group reload. So if you reload groups the groups you define in packages will disappear (same with automations)
In the home assistant section of configuration.yaml:
The alarm.yamlās are designed that you never really need to touch them. For a second alarm, copy the āalarm_1.yamlā, search and replace āalarm_1ā with āalarm_2ā , and finally add one line to the configuration yaml. Done. The alarm fires an event āalarm_1_eventā which you can pick up in an automation of your choice.
I use a similar package setup but use input_datetime to reduce the code right down and make it a bit less hacky for WAF. I also fire the actual automation in the package as mine are packaged for the rooms theyāre in. This is the bedroom oneā¦
link removed
The other rooms are in the parent directory, thereās 4 of them in the house, and then I have a āsync alarmsā package that sets the time and activates the alarms for all 4ā¦
I agree with your post in that issue thread. Packages are the best way to organise your configuration.
I totally understand that the devs want to make things more accessible to non-techie types, but itās starting to feel a little bit like those of us that are happy to do our own config are just being pushed to the back bench since hass.io was released really.
So long as the option to manually configure never goes and the docs continue to show what you can do with each component Iām not too fussed, I always restart my whole instance each time anyway so the issue you raised doesnāt affect me, but you wonāt be the only āregularā user who wants this and to say, basically āshove off, we want to be noob friendly now so in spite of your contribution to the community weāre not interested in helping youā is a bit off, and thatās one of several GitHub issues Iāve seen go that way recently which is a bit upsetting really.
Plus, packages are what the community is trying to put together to actually make it noob friendly. āCopy and paste this and you have an alarm clockā is always going to be easier than making your own no matter how clever the gui editor gets.
Did not know that they have datetime as input type by now. I played with it, but ended up not using it, as one cannot cascade groups. I have my generic alarm group in a group with all the things that should happen (that is in my case set temperature, time how long it should stay warm, etc). So the changing of the alarm settings will be displayed in an overlay. Once this is open you will not be able to open another one on top of this. Changing datetime however opens another overlay, or at least tries to, and will fail to do so.
It is always easy to say from the outside, but there are a lot of design decisions which I would not have made this way and which make it really hard to debug automations and get things to run. Given the time I spend on debugging and the state of HA, I find it really ambitious to make it āaccessible for non-techie typesā. But again itās just an outside view and Iāll take what I can get.
I decided after all that it is easier and much shorter to move the automation to appdaemon. The actual automation can then be written in 2-3 lines.
Note: It is currently for appdaemon v2.x. For v3 use hass instead of appapi (comments below)
#import appdaemon.plugins.hass.hassapi as hass
import appdaemon.appapi as appapi
from datetime import datetime
#class WatchAlarm(hass.Hass):
class WatchAlarm(appapi.AppDaemon):
def initialize(self):
self.run_every(self.watchAlarm, datetime.now(), 60)
def watchAlarm(self, kwargs):
ifWeek = self.get_state(self.args["ifWeek"])
ifWeekend = self.get_state(self.args["ifWeekend"])
time = self.get_state(self.args["time"])
time = datetime.strptime(time, '%H:%M:%S')
eventName = self.args["eventName"]
now = datetime.now()
if (now.isoweekday() <= 5 and ifWeek) or (now.isoweekday() >= 6 and ifWeekend):
if time.hour == now.hour and time.minute == now.minute:
self.log("It is now {0:%H:%M} and we fire {1}".format(time, eventName))
self.fire_event(eventName)
The bedroom one is a bit more advanced and wakes us up 15 minutes early in bad weather, the girls and boys ones are just ānormalā, and the sync-all, ummm, syncs them all to the same time.
templates now need entity_idās included⦠check for errors in your log relating to those templates. Iām guessing you will see some. Add the entity_idās and they should work again
within each template you now need to include the entity_id that it relates to. You have a few templates in that package. Iām not great with templates but you need to add the entity_idās under āfriendly_nameā in each template.
So it does work? I have a few templates which were giving entity_id errors but I think they may have still worked⦠I didnāt test them, I just added the idās and the errors stopped