this post was submitted on 05 Jul 2023
3 points (80.0% liked)

homeassistant

12055 readers
36 users here now

Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io

founded 1 year ago
MODERATORS
 

I'm trying to improve my morning routines with Home Assistant. I have a set of Eve Motionblinds connected to Home Assistant, along with my Sonos with Alexa.

My goal is to set an alarm with Alexa, and have the Eve Motionblines raise 15-20m before the alarm goes off as a sort of sunrise alarm clock.

I've looked through the docs, but I can't figure out any way to make something like this happen. Anyone have any ideas?

top 3 comments
sorted by: hot top controversial new old

This is the template trigger code I use in my automation. Automations triggers and ramps up lighting 5min before phone alarm goes off.

The template checks the current time/date at the start of ever minute (the bracketed bit formats the current timestamp) then checks to see if current time matches my next alarm time formula and triggers automation if it does match.

The next alarm formula gets the (time to) next alarm in milliseconds, devides that by a thousand to make it seconds then, subtracts 300 (= 5 minutes) then prints that formula to a time stamp formatted the same as the current time stamp (for it to compare against)

This is for an Android phone and using the companion app sensor for 'next alarm'. #USER# is to be replaced with users own name/entity. Not sore how much of this translates to an Amazon thing but, hopefully give you a bit of an idea of how to perform it once you find the right entity?

{{now().strftime('%H:%M %Z %a %d %h %Y') == (((state_attr('sensor.#USER#_phone_next_alarm', 'Time in Milliseconds') | int / 1000 | int - 300 )) | timestamp_custom('%H:%M %Z %a %d %h %Y'))}}

[–] Rosegold@kbin.social 1 points 1 year ago* (last edited 1 year ago)

My initial thought would be to go about it the other way, trigger the alarm 15 minutes after the blinds. That would probably be easier.

But that means that you need to redo/rethink and let the blinds be the "alarm" instead.

Otherwise you would have to parse the alarm settings for each day to get the unique (if you jag different times for different days which I am assuming you do) alarm time for that specific day if that even is possible.

I turn on and off my Sonos alarms from within Home assistant but have never thought if it's possible to read the specific time to HA.

[–] knapoc@lemmy.world 1 points 1 year ago* (last edited 1 year ago)

There are probably multiple ways to solve this...

Here's an approach I'd choose (note that I do not use Alexa, so my knowledge about the integration's capabilities is limited):

  1. define an input datetime used as an alarm time.
  2. allow Alex to manipulate this input datetime
  3. use a template trigger to compare the current time with the defined alarm time - and yes you can do calculation; e.g., automations triggers when current time = (alarm time - 20 minutes)
  4. trigger the alarm from within home assistant by either using a delay in the same automation or use a separate automation triggered at alarm time.
load more comments
view more: next ›