-
Notifications
You must be signed in to change notification settings - Fork 303
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
Timers still not updating reliably after 4.6.5 fix #1976
Comments
I'm also having this issue too. |
I see in the discussion here - #1974 - that this fix is probably the best that can be done right now considering that Amazon have stopped (temporarily? who knows) the call that the code previously relied upon to update the timer sensors. I can completely understand that, but putting that info in the fix and/or the original issue before closing that would be useful. As the timers are working right now, I can no longer use them in the automations I was previously using. Right now, setting a timer seems to get reflected in HA most of the time (sometimes after 30 seconds or more, sometimes just never), timers ending also get reflected most of the time, but cancelling a timer part way through hardly ever gets sent through to HA. The new mechanism might be the best available at the moment, but for whatever reason, on my system it just isn't reliable. |
I have about 20 Alexa devices, and the timers have never worked at all in the roughly 1 year that I have been using Home Assistant, always showing "Unknown". With this 4.6.5 release, they have started working for the first time. There is an inconsistent delay, usually a minute or two, but the timers work consistently except for a short timer that expires before the entity gets updated. |
Dont know if we are facing the same issue. Does _next_alarm entities works for you guys? |
I have been testing this timer problem and I am fairly certain it is a timing issue to do with when the push_activity gets sent compared to when the previous command that is no longer being sent was. Sometimes setting a timer and then cancelling it updates HA as expected, sometimes the set never gets picked up, and then the cancel actually causes the HA sensor to update with the timer that was originally set. A subsequent voice interaction (anything, even just "alexa" with no command) then causes the sensor to revert to "Unknown" as it should have after the cancel. This behaviour led me to thinking that the information that is being fetched from Amazon when this push_activity is seen has (sometimes) not yet been updated with the timer info (either being set, or cancelled/stopped). I started work in mainframe IT over 40 years ago, don't know python, don't know GIT and don't know the API details so forgive me if this is complete nonsense, but after this testing and looking through the code changes in the 4.6.5 fix I have found that putting a delay in at the point in
The result is a delay between the push coming in and the various API calls as seen here (edited):
Someone has mentioned elsewhere that snoozing a timer still does not update HA with the extended time, I have found that with this delay in place that seems to work too. Solving a timing problem with an arbitrary pause is obviously not a guaranteed 100% solution, there may well be occasions when 5 seconds is not enough, but it certainly seems good enough on my system for my needs now. Without it, it is far too hit and miss. |
@dpgh947 nice find! Does ..._next_alarm entities also works for you? In my case since HA 2023/06 it doesnt work, also not with 4.6.5. |
I don't use alexa alarms in HA but looking at the entities I can see that the relevant one was updated when I set an alarm last night for getting up this morning. I would guess that they get picked up by the same mechanism. If you want to try my bodge, you can just edit the file in \config\custom_components\alexa_media (it's around line 910 onwards) and then restart HA to pick it up (reloading the integration won't do). EDIT - this edit update works on a raspberry pi install using HAOS, don't know about other platforms... |
OK, hold your horses... this delay is sometimes causing the update of last_alexa to get delayed too... |
Have patched the file manually and restarted HA. |
It would be so nice if the alexa data (alarm/timers/...) would be reliable again. |
I have also observed that alarms stopped updating with the 4.6.5 update reliably. With debug logging enabled, I noticed that I was seeing between 2 and 3 PUSH_ACTIVITY messages after setting or clearing an alarm and the duplicate suppression added in 4.6.5 (enforces a minimum of 100 second delay between subsequent PUSH_ACTIVITY being processed) was firing for the second and third occurrence of the PUSH_ACTIVITY message. I eliminated the duplicate suppression check and now find that the alarms are being processed reliably. Incidentally, I've also observed that my Alexa routine that is set to fire when an alarm is dismissed also broke around the same time, so I suspect that Amazon's change may have unintentionally broke something in their own stack in addition to affecting this component. This gives me some hope they may revert the change. |
Can you please give us details what to revert/change in the code to get alarms working reliable again? |
EDIT - forget this update below, after working flawlessly during loads of tests, I just had another instance of saying "stop" to an expired timer going off failing to update HA properly. There is clearly a random timing issue here to do with the push_activity being sent and the timer info coming out of the api, but I can't figure out how to address it without causing other issues. I had also experimented with taking out that check for double PUSH_ACTIVITY calls, but couldn't see it making any consistent difference - but I don't use alarms in HA so wasn't looking at them then. Trying to figure out what this code is actually doing, and what the intention is, when I don't know python or the way all this asynchronous handling of the push commands and the API hangs together is making my brain hurt, but here is what I have now done, which might be complete garbage but might point someone who does know what they are doing in the right direction: The routine that handles(handled) PUSH_NOTIFICATION_CHANGE, and which I believe is therefore no longer being used at all, calls "process_notifications". That has code handling alarms, so I added a call to that to the PUSH_ACTIVITY routine where I had tried the delay,
I found this was also causing a delay in last_alexa getting updated like my first delay bodge did, because there is a sleep(4) in the process_notifications routine, so I took that out too,
Having last_alexa updated promptly is important to me because I have lots of node red stuff that responds to custom alexa phrases and responds to the device spoken to using TTS. With these changes (note check for double calls still in place), I have found that last_alexa gets updated promptly, my alarm entities are getting updated when I set/cancel alarms, and timers work completely reliably, with one exception that I have found so far - if you set a timer on one echo, and then cancel it from another, that change is never picked up in HA, due to the fact (I think) that there is no push seen coming from the original device in that situation. The only way to clear it is to speak something - anything - to the original device. Clearly it would be possible to update all timer sensors rather than just the ones for the device that is being dealt with because the info is there in the "notifications" API call result, but that is beyond my so-far-few-hours-worth of python experience.... |
I found a horrid work around for now. When the current timer goes off in the kitchen. I send service: media_player.play_media Which makes the Alexa go ding and the timer information is updated on the integration. |
That's clever, not horrid. What do you trigger that off? |
When the current timer time is reached I trigger it. It is not perfect but it helps. |
Well it's not perfect, but I'm running with those changes above still. On the latest code I'd say timers work about 60% of the time, either not starting or not picking up when they are stopped or cancelled, and with the changes I've made it's about 98%. Very occasionally when I "stop" a timer that's going off, it doesn't update HA until I speak to it again. |
@dpgh947 which changes, exactly? You have two comments here which different code changes. I made all your suggested edits and my timer is more of a mess than it was with the vanilla 4.6.5 code. Are you able to post a gist or full file of what you have working? Maybe I misunderstood your changes/which file to make them in. Thanks. |
@jane-t thanks for the bandaid. Works to clear the status of a cancelled/stopped timer. However doesn't quite work when snoozing: Timer starts going off, "Alexa, snooze 10 minutes" "OK" -- no updates happen and timer is still at original time in HA. Before all this API change nonsense, the snooze request would update the HA timer datetime, which I used as a trigger condition (to recognize the snooze action). Now when we say that phrase, the HA sensor never updates and continues to be in the past. |
Sorry if I caused confusion... it's just the updates in my latest post, forget my first attempt, so only adding the
call at around line 927 and removing the sleep(4) at around line 677 (which was only put there in 4.6.5 but not explained), both these in EDIT - snoozing a timer that's going off works for me too. |
Ok I made that change (only those two changes) and snoozing is working GREAT. But now stopping the timer is impossible. When the timer rings, I say "Alexa, stop timer" and the noise stops. However, HA's sensor datetime just updates to a new value, instead of returning to "unknown" which is what is expected. I tried @jane-t 's service call and it also bumps the datetime - the the current time (time I made the call). I tried reloading AMP, and same behavior. The datetime just changes from "12 seconds ago" to "now" (in datetime format of course). I tried talking to the Echo Dot and same behavior - it just keeps increasing the timer sensor time to the current time, causing infinite loops in my automations. What the heck is going on? |
I have never seen anything like that, all I can think is the echo is screwed up somehow, try unplugging it and see if that clears it. |
thx for the hints. Does alarms update for you? thx |
This works perfectly for me on my daily alarm. Thanks! |
I do see alarm entities updating when I set and clear alarms, yes, but I don't use them in ha so I can't say if they were working without my update anyway. |
Nice to see that you are also facing these problems with alarms not updating. Sad that it's officially not working for ages anymore. I did try your code changes but cannot confirm that it's working for me sadly enough. I will follow the discussion further hoping to find a solution for me as well as it's annoying to restart HA every time I change the alarm in the Alexa app :) |
Well since yesterday, timers are completely broken for me, any changes only get picked up on integration reload, AND last_called is not being reliably updated either. Calling the alexa_media_update_last_called service does cause the last_called attribute to get updated, but just speaking to a device no longer does, although an update might randomly come through several minutes later... so either something is broken at amazon's end, or it's another deliberate change from them which is further breaking the api link to HA. |
For my echo dot 5th the update never works. |
As a workaround for wakeup alarms I have now created virtual lights for every bedroom and exposed them in emulated hue. Alexa can use an wakeup light for all alarms, which is now set to the individual virtual light. So I can react in HA's automations again. This way it's better than using Alexa's wakeup routine, because you can set an wakeup light per Alexa device and they also stick on new alarms for reach device. So a family member can not mess the alarms up so quickly or forget to add an routine 😉 Hope this helps |
Not sure if this is related but I have noticed that the total_active attribute is not getting updated. I use this to determine whether a timer has been started and then display an actual timer on a dashboard. For me the total_active won't update unless I reload the integration. |
This is a key point. If Amazon has disabled this, then there will be no updates possible without going the polling route.
You'll know you've hit the limit when your account gets blocked or all of us who use the API get blocked. Amazon doesn't publish that type of info. |
has anyone found a work around for this? I know reloading the integration gets the timers to show up but theres no way to automate a reload of an integration (as far as I am aware?) |
You can do this: #1992 (comment) But don't run it too frequently or your developer account will get locked out. This means it is only really useful for Alarms which don't require real time updates. |
thanks for this - I thought I could activate it with "last_call" to reload the integration when I said the word "timer" but last_called does not update anymore either without a reload so I am fresh out of ideas |
I used to use IFTTT before I really got in to HA, and I remembered that had a trigger for when an alexa timer goes off. I just looked and that trigger is still there, and interestingly it still works, so there's a mechanism of sorts somewhere that is still in place... |
I think what we are seeing is the gradual complete shutdown of this api by amazon (just about). I am now not seeing ANY updates to media player entities coming through at all. I have had to completely change the way I handle the "last alexa" - I now cannot maintain this based off the activity that used to be seen whenever any device was spoken to. The only way it will work now is to call the update_last_called service whenever I am about to send a TTS announcement and I have not specified a target (in other words, I want it sent to the device spoken to). That service still works at the moment... |
Any updates on this? Can we have an "workround" version which just polls, until the notification method work again (or is shutdown completly :-( ) thx |
I have no update but a workaround for alarms that I have tested for a while and that I'm using now. Information
Workaround does not work for:
Description
emulated_hue:
Now when the alarm goes off the trigger will be switched "on" within HomeAssistant. Hope that helps some of you to achieve something independent from Amazon API. |
I've implemented a similar solution to @NivaBarCar above, however I have it able to trigger up to an hour before the scheduled alarm. Instead of using Emulated Hue, I'm exposing my device to Alexa using the standard Alexa Skill/Home Assistant Cloud integration. In addition, I'm using a virtual "light" entity instead of the input_boolean. The virtual light entity is created by the Virtual Components custom component: https://github.com/twrecked/hass-virtual By exposing a dimable light to Alexa instead of an on/off switch, the wake-up light before alarm setting in Alexa works. You can specify up to an hour before the alarm time. Alexa will start with the "light" set to low brightness and gradually increase it to 100% by the time alarm time is reached. With a switch, that setting is ignored and she simply turns on the light at the alarm time. My automations don't care about the dimming level. They simply trigger when the "light" transitions to on, so they fire as soon as Alexa starts the wake up lighting sequence. |
Thanks for sharing @elarsson1. You are right by mentioning that in case you use the cloud integration this works "better". |
Did anyone figure out a way to fix the timer/last called feature. I just want the timers to show without spamming the API |
@NivaBarCar I suspect you could get this to work with Emulated Hue just as well, rather than relying on the Alexa skill and the HA Cloud subscription. The key, I believe, is using a light entity instead of an input_boolean (which shows up in Alexa as an on/off switch) as the trigger. You could create a virtual light, that is dimmable, using the Virtual Components and expose that via Emulated Hue instead of the input_boolean and then Alexa would be able to turn it on at low brightness before your schedule alarm time. |
:-) But i have automations which checks if something is playing and if not play something. Is there also an workaround? |
Any chance to get volume updates working? |
I was going to implement @elarsson1 's idea but found out Timers (which I used for tons of cool automations) don't provide any Alexa-side routine or trigger effects like the wake-up lighting. So i'm still looking for a better way to workaround this for timers. I suppose I can create a routine that creates an alarm when asked a certain way, which might be the way to do it for now. As of now, I've increased my "completely reload the Alexa integration" automation from every 12 hours to every hour, and even that is fairly useless for timers, since A) it doesn't capture snooze command changes and B) many timers are created on the fly and expire within the hour. I could increase the integration reload frequency more but I read I will start getting throttled... |
Issue still exist for newest update 4.7.0 |
@alandtse So if users automations are using data from Alexa (timers, alarms, volume, ...) are working again? Thx a lot |
Updated to 4.7.1 and still not working for timers. |
Same for me 4.7.1 is still broken. |
Please review the release notes. Neither of the releases that came out recently promise or describe any fixes to this situation. Do not expect it to be magically fixed when the number goes up. |
The only thing that will fix timers is Amazon reverting the api changes they made which broke them in the first place. The only dependency I had on timers in HA was an automation that announced in the lounge if a kitchen timer went off. It was pretty useful when I was cooking and wandering about, it's a shame it's gone, but I've quickly learned to do without it. |
Follow #1953 for update since it's the same root cause now. Closing dupe. |
IMPORTANT: Please search the issues, including closed issues, and the FAQ before opening a new issue. The template is mandatory; failure to use it will result in issue closure.
Describe the bug
Alexa timers not being updated in HA reliably, even after the fix to the previous reports of this in 4.6.5
To Reproduce
Set an alexa timer, look at HA sensors.
Expected behavior
Timers should appear, count down, and get reset at end, or if the timer is cancelled.
Screenshots
System details
const.py
or HA startup): 4.6.5pip show alexapy
or HA startup):Logs
Please provide logs.
I have a debug log but am not sure all sensitive info is removed? Serial numbers are mostly obscured but still appear in some URLs logged
Additional context
I have been waiting on this fix as I have some automations which rely on timers (for example, if a cooking timer on my kitchen echo ends, I send a TTS alert to other echoes in case we can't hear the kitchen). I installed 4.6.5 straight away this morning and tested. First time I set a timer, it wasn't picked up in HA at all. I then enabled debug log and set another timer, it also was not picked up in HA for around 30 seconds, so I then cancelled the timer, at which point it WAS then picked up in HA. So I then had the situation where HA had an active timer sensor, but there was no actual live timer on the alexa device. The only way out of this was to reload the integration.
I have the debug log for this, but as noted above, I am not sure that all sensitive info is blocked out of the log? I can see most occurrences of serial number are blocked out, but there are still some visible in URLs that are logged. Is this an exposure?
The text was updated successfully, but these errors were encountered: