I am still trying to get my head around how things work in Home Assistant and I can use a little help on some very basic things.
I like to keep the level of interaction with HA to the absolute minimum, but unfortunately me and my housemates do not wake-up every day at the same time. I looked at how people created an alarm clock alarm clock as a package and many similar posts, but all I want is a variable alarm_time with a card to adjust it so that I can use this alarm_time in my automations. In automations.yaml it most likely looks something like this:
I tried adding in the format of alarm time the seconds as well so that it has a value something like: 07:30:00, but that does not work.
As there are many things that need to happen in at least my house so depending on the alarm time I want to be able to also trigger automations at different times depending on the alarm time which looks like:
- id: '9876543210'
alias: Master Bedroom - Wakeup Gently
description: ''
trigger:
- platform: time
at: `alarm_time` - 00:30:00 (but then formatted in the right way)
I can of course make a total spagetti off all these automations creating an complete list of actions in that one automation, but then it easily becomes totally unmanagable and intransparent what is happening in your house.
So the solution to combine it with a boolean sensor as done in the alarm clock as a package to create a state change but does not sound very attractive to me or is there a smarter way than creating a whole list of actions in that one automation?
A question that goes along with this one, where to find how to format the alarm_time in this case in the right way? or if it is impossible to use a variable for alarm_time where is that written?
I integrated an alarm clock as well, was some work with a template that subtracts seconds from the time sensor, however you donāt need to do that anymore as of v0.115.
Take a look at the blog post.
Go to Configuration - Helpers, click on āAdd new Helperā -> āDate and/or timeā.
Choose what fits your use case best:
Time: Triggers each day on this time (e.g. every day, 06 AM)
Date: Triggers on this specific date (e.g. at 05.12.2020)
Date and time: Triggers on specific date on specific time (e.g. at 06 AM on 05.12.2020)
The name of those helpers is something like input_datetime.alarm or similar, depending on the name youāve chosen. You can see the entity_id in āConfiguraion - Helpersā
For an alarm clock, Iād go with a Time one only. Have that as your automation trigger.
Now, the alarm will trigger every day. To avoid that on weekends for example, you can add a time condition to your automation, so that the automation only fires on weekdays.
Additionally, Iād add another āToggleā helper āAlarm Statusā, and have that as a condition as well (state of input_boolean.alarm_status is on as condition). Then, from the frontend, you can easily turn on and off your alarm clock.
Hello,
Iām also busy getting myself an alarm clock.
I have already done most of the revival, although I would still like to add things. (Iām new to, HA)
I implemented in my Lovelace a card with the time of my alarm clock which activates the automation
I would like to be able to take this time (ok, I have my variable wake_time_1) and take a time from it in order to create a variable wake_time_1_1 to activate an automation that turns on my phone charger. So when I wake up, my phone is charged and good for the day.
The problem is that I donāt know how to deduct a time from my variable wake_time_1 and create my variable wake_time_1_1.
Best case scenario, Iād like to retrieve my battery capacity and deduce the ideal time before I wake up so that the battery is at 90% by the time I wake up. Well, itās more complex, so activating one hour before I wake up already suits me.
Especially since I already have an automation that stops the charger at 90% of my battery.
In order to help you, we need to know what type of entity wake_time_1 is. The specific way to achieve your goal is different for an Input number helper vs. Input datetime (date & time) vs. Input datetime (time-only) helper.
Not, quiteā¦ Take a look at the documentation that I linked in the post. Template sensors need to ve set uo in your configuration file, not within the automation.
Yes, the above can be added to the configuration.yaml file. If this is your first Template entity, you should be able to just copy/paste it into the file. Make sure template: is all the way to the left. Also, make sure to restart Home Assistant to load your changes.
After your have loaded the changes, confirm that the sensor has been created by searching for it in the Developer Tools > States page or the Settings > Devices & Services > Entities page.
No, if you are using the graphical Automation editor you do not need to add your automation to the configuration.
That is a bug... just type the complete entity ID into the field.
I have a little problem.
The activation of the automation is not done.
When I tested, it worked. That is, when I changed the wake-up time.
But at the āofficial time - 1hā of my alarm clock. It does not work.
I find it weird that he tells me that Wake Time 1 Pre is September 6th. Since itās already September 6th at 10:10 a.m.
But what disturbs me the most is that he said 4 hours ago
Whereas, when I modify and encode a closer time, it tells me in 20 minutes. (It was 10:10 a.m. at my house)
And also I wanted to test with 20h, but it didnāt update. It rested on September 6 10:30.
The sensor will always be in the past if you look at it past that time for the current day. You can modify the template to jump ahead in time to tomorrows time, but you have to build that into your template.
template:
- sensor:
- name: "Wake Time 1 Pre"
device_class: timestamp
state: >
{% set alarm = today_at(states('input_datetime.wake_time_1')) %}
{% set offset = 23 if now() >= alarm else -1 %}
{{ alarm + timedelta(hours=offset) }}