-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Supply Alexa notifications (alarms/timers/reminders) #144
Comments
Should be possible; I just don't know what alarm components exist in HA. Can you point to one? |
@Walter-Bishop Is your goal only to know when an alarm or timer goes off? Or are you also interested in setting them? |
I'm also really interested in this! Mostly interested in knowing when it goes off, to trigger other stuff in HA. |
Would it work if you had to call a service to get the next alarm/timer time? The API doesn't appear to report when the timer or alarm goes off so it's a little hackey to figure it out. |
I would be fine with that, would just be a scheduled service call at like 3AM, so that you know the next mornings alarm if any, and then setup some other stuff based off that. |
For me, just having the data available in a sensor entity would be useful. https://alexa.amazon.com/api/notifications The above API call will provide the reminders/alarms/timers information. Each of them includes an indication of which device it's set on via deviceSerialNumber. Exposing something like sensor.my_alexa_device_name_alarms, sensor.my_alexa_device_name_reminders, and sensor.my_alexa_device_name_timers that contained all of the data available from the API would be incredibly useful. Even more... a service could be exposed to allow the setting of reminders. This is done with a PUT call to /api/notifications/createReminder with data like the following: { PUT and DELETE calls are also handled for /api/notifications/ I have a strong feeling that a PUT call to /api/notifications/createAlarm would work too, though I don't have sample JSON data for this yet. |
Thanks. The issue isn't so much the API as I found it but figuring out the best way to represent it in HA. I asked the dev channel and didn't get a response. The existing calendars are using binary sensors so I might just do that. |
That's a great idea! The binary_sensor can be ON if there are any alarms, reminders, timers, and OFF if there are not. And then the actual data can be in the binary_sensor attributes. |
That would work perfectly, you can then trigger on the sensor change, and put the attribute in it's own sensor or use it some other way, either way, that will enable some truly smart stuff! |
To follow the other calendars, each alarm would have its own binary sensor. Let me know if you see any issues with that method. If anyone can confirm the calls for setting alarms, I can also see about adding that somehow. |
The issue with each alarm having it's own sensor is that alarms are, by
nature, temporary. So we'd have sensors showing up and going away all the
time with no easy way to tell what the name of the next one will be.
With one sensor holding all the alarms for each echo device (one sensor per
device) automation code can easily iterate over them.
…On Fri, May 24, 2019, 12:39 PM Alan Tse ***@***.***> wrote:
To follow the other calendars, each alarm would have its own binary
sensor. Let me know if you see any issues with that method.
If anyone can confirm the calls for setting alarms, I can also see about
adding that somehow.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/keatontaylor/alexa_media_player/issues/144?email_source=notifications&email_token=AA7PP37FDBGJDTM345ZHZFLPXAR3RA5CNFSM4HCC6EN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWGCUCI#issuecomment-495725065>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA7PP33ODKXSWCGCMRX2EPDPXAR3RANCNFSM4HCC6ENQ>
.
|
@dlashua Can you please provide some examples of how an automation could iterate through the data so I can see about what would be the best implementation? For example, I could do it in an ordered queue like |
An example is how the GoogleHome Alarm is displayed as a sensor within Homeassistant (see here). I personally don't like that it shows only the one next approaching but would prefer attributes with every alarm set... |
an ordered queue would be fine, as long as there is a separate sensor for each device. This way I can make an automation that says when it's 30 minutes until the alarm in the bedroom, start turning on the lights. When the alarm in the kitchen has been going off for 30 seconds without being stopped, start blinking the lights in the house. For alarms, specifically, that's about as far as it goes since Alexa doesn't allow you to name alarms. Timers, however, can also have a name, so even more things could be done. Like, when my "dinner" timer in the kitchen sounds, announce on all devices "dinner is ready". |
Hi, it would be very usefull for me to set alarm timers from Home Assistant |
Can someone please help me to get the following sensor working:
I want to use the cookie file of this custom component to get the alarm times. (In my browser it works with an active session) Edit: working sensor see below. |
@ronmichel I don't think you can use the pickle file like that. At least, just on plain command line, it doesn't work for me. On top of that, even if it did work, the value_template needed to get a specific alarm from a specific echo device would be far too complicated. What you have there would only get the very first alarm's time, which may, in fact, be a timer, not an alarm, and, even if it is an alarm, might be turned off. I have some working code that gets the most recent alarm time from each echo device and sets it as a sensor that you can access. However, it's written for AppDaemon (so that would be a requirement). And, as of right now (though I'm adding this feature next) it doesn't read alexa_media_player's pickle file, so you have to perform the captcha for it as well. This code can't be used in a python_script because it imports alexapy which python_scripts don't allow. It could be made into a custom_component, though. However, it would be getting the devices list a second time, so it's really better off being integrated into alexa_media_player. |
Hi @dlashua, |
I have a working sensor now (@dlashua was right, the pickle can't be loaded into curl, it needs requests).
|
I used the alexapy library to make an AppDaemon based integration to find currently set alarms and set a sensor to that value for each echo device. It's not feature complete, so I'm not sharing the AppDaemon app just yet. But the central code that finds the alarms and builds a list of them might be useful to kickstart this feature in the alexa_media_player code base:
|
Thanks @dlashua. Is your sensor showing the next alarm or every alarm per device? I got stalled in trying to figure out the best way to show this but may be able to look at implementing this again now that async is done. You can tell when I got stalled because I added the underlying alexapy call but never implemented the feature. ;) As a note, with the new aiohttp library, the cookie format has changed. It may be possible to use curl with it but I haven't tested. |
I create one sensor per discovered device. There are other bits that look at "capabilities" returned by the device retrieval method and only add sensors if they have TIMERS_AND_ALARMS. The sensor is always set to the string of the next alarm for each device. It is False if there is no alarm. And I add a timestamp attribute with the epoch time to make the sensor usable in Home Assistant templates. Also, in case it matters, this uses alexapy as it was maybe... 2 months ago. If there have been breaking changes since then, I've not kept it up to date. |
Yah, we just moved alexapy to async so it's a breaking change at 1.0.0. |
@alandtse |
@ronmichel it will probably work until 1.0.0 needs to create a new cookie. Then it'll save it in the aiohttp format which is the format that may work in curl. Requestcookies are different from standard cookies I think. |
Just bought an echo show 5 to be used as an alarm clock. I would also like to get the alarms set into HA, so I can do more automation, like for example do wake-up lights. This would require HA knowing what time the alarm is set to. |
I have a version where it'll show the next alarm, reminder, and timer each as a separate sensor. In terms of showing all items, do you only want to see what is actually 'on' or everything? If you've seen the notifications json, you'll notice that Amazon likes to create many items. |
Just active ones for me @alandtse, since we set a different time most mornings we have a ton of alarms in the app and I wouldn't want all of those in my HA, just active ones! |
@alandtse |
Agree with @ronmichel on this! |
Ok. Is there value in throwing an alarm going off event or would exposing the time be enough? Sending an event will be guess work since there isn't a direct event from the API to monitor. |
For me, just having the time is enough. If I need to know when it's going off I can make an automation that triggers at that exact time. |
Also don’t see a use for sending events, especially if it isn’t easy to do. Once the time is in Hass, it’s easy enough to make an automation trigger. |
For the adventurous and advanced users, there's a PR staged which also requires replacing alexapy. It exposes sensors for each device that will tell you the next active notification (alarm/timer/reminder). It also exposes attributes with a sorted list of all upcoming notifications or all notifications in the system. For those who are building template sensors, let me know if it needs any tweaking. I'm looking at adding switches for enabling alarms/pausing timers or just doing a service call. That may make it in the next release or may be further along. May also look at adding the ability to add such notifications. |
This is live in 2.3.0. |
I'm assuming you mean the sensor.device_name_next_alarm entity. Mine doesn't seem to update after I've added an alarm to the device. Even though my custom code (that uses alexapy) sees the update. Thoughts? |
I’ve seen this happening twice in my setup. The first time I tested the hell out of it and it worked every time, until I added an alarm with Spotify playlist on shuffle and the sensor would show no alarm. Even restarted, no go. Removed the alarm and set it the simplest way, instantly updated. The second time it was a simple alarm, but it just wouldn’t update. Restarting Hass fixed it. Anyway, thanks for adding this feature. Love it. Might still need some ironing though :) |
There's a bug for MusicAlarms. #402 One thing to check is whether you're seeing websocket requests for alexapy in the logs when editing alarms. If you aren't, then you're probably experiencing other update issues as we've lost the connection to the server. |
ciao, |
By doing something like this: or minutes to next alarm: |
Thank You ! I will work on it :) |
I created an issue: #409 (comment) |
ok lo faccio! : Slight_smile:
`- id: RQ Attiva Buongiorno
|
Hello,
your component has been very useful for me. To further improve it, I'm suggesting the following new feature:
Since I'm using Alexa's alarm feature for waking up in the morning it would be great having access to the alarm time through home assistant. Then I would be able to create an automation that, for example, sets the heating or lights up the bedroom previously to the alarm ringing.
Do you think it would make sense to add such a feature to your component?
The text was updated successfully, but these errors were encountered: