alandtse / alexa_media_player

This is a custom component to allow control of Amazon Alexa devices in Home Assistant using the unofficial Alexa API.
Apache License 2.0
1.44k stars 277 forks source link

Alexa Sensors are unavailable when no timer, reminder, or alarm is set. #1107

Closed piny0 closed 3 years ago

piny0 commented 3 years ago

Describe the bug Alexa sensors stopped working, entities are unavailable (e.g. sensor.device_next_reminder, sensor.device_next_alarm, while do_not_disturb switch is working/responding)

To Reproduce Installed the addon via HACS and then let it add the devices, afterwards only the media_player entity and do_not_disturb switch are available. Tried with provided 2FA code and also with built in 2FA method.

Expected behavior Entities response (it worked until last week or so)

Screenshots n/a

System details

Logs

2021-01-14 10:11:12 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/.storage/alexa_media.xxx@googlemail.com.pickle 2021-01-14 10:11:12 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/alexa_media.xxx@googlemail.com.pickle 2021-01-14 10:11:12 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/.storage/alexa_media.xxx@googlemail.com.txt 2021-01-14 10:11:12 DEBUG (MainThread) [alexapy.alexalogin] Using credentials to log in 2021-01-14 10:11:22 DEBUG (MainThread) [alexapy.alexalogin] Saving cookie to /config/.storage/alexamedia.xxx@googlemail.com.pickle 2021-01-14 10:11:22 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.de/api/np/player?deviceSerialNumber=xxx&deviceType=xxx&screenWidth=2560&=1610615482531 returned 200:OK:application/json 2021-01-14 10:11:23 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.de/api/np/player?deviceSerialNumber=xxx&deviceType=xxx&screenWidth=2560&_=1610615482890 returned 400:Bad Request:application/json 2021-01-14 10:11:23 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.de/api/np/player?deviceSerialNumber=xxx&deviceType=xxx&screenWidth=2560&_=1610615483277 returned 200:OK:application/json 2021-01-14 10:11:23 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.de/api/np/player?deviceSerialNumber=xxx&deviceType=xxx&screenWidth=2560&_=1610615483445 returned 200:OK:application/json 2021-01-14 10:11:23 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.de/api/np/player?deviceSerialNumber=xxx&deviceType=xxx&screenWidth=2560&_=1610615483611 returned 200:OK:application/json 2021-01-14 10:11:24 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.de/api/phoenix returned 200:OK:application/json 2021-01-14 10:11:33 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.de/api/np/player?deviceSerialNumber=xxx&deviceType=xxx&screenWidth=2560&_=1610615493791 returned 200:OK:application/json 2021-01-14 10:11:33 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.de/api/np/player?deviceSerialNumber=xxx&deviceType=xxx&screenWidth=2560&_=1610615493792 returned 200:OK:application/json 2021-01-14 10:11:33 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.de/api/np/player?deviceSerialNumber=xxx&deviceType=xxx&screenWidth=2560&_=1610615493793 returned 200:OK:application/json 2021-01-14 10:11:34 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.de/api/np/player?deviceSerialNumber=xxx&deviceType=xxx&screenWidth=2560&_=1610615493790 returned 200:OK:application/json 2021-01-14 10:11:34 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.de/api/np/player?deviceSerialNumber=xxx&deviceType=xxx&screenWidth=2560&_=1610615493790 returned 400:Bad Request:application/json

Additional context

As already mentioned, it worked (at least) until last saturday (9th of January).

Thanks in advance

nrd2001 commented 3 years ago

I have this issue as well. Glad it's not just me

alandtse commented 3 years ago

There should be a request to the notification api. Please find it in the logs. It will also print out the sensors being discovered.

2021-01-14 10:16:32 DEBUG (MainThread) [alexapy.alexaapi] a******e@g*******m: static GET: https://alexa.amazon.com/api/notifications returned 200:OK:application/json
2021-01-14 10:16:32 DEBUG (MainThread) [custom_components.alexa_media] a******e@g*******m: Updated 37 notifications for 8 devices at 2021-01-14 02:16:32.394218-08:00
2021-01-14 04:05:43 DEBUG (MainThread) [custom_components.alexa_media.sensor] Sensor value xxxxxx
nrd2001 commented 3 years ago

Looks like my issue was for some reason it had reverted to my old password in the integration.

piny0 commented 3 years ago

Hey @alandtse thanks for your answer. I've found this line:

2021-01-14 18:11:40 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.de/api/notifications returned 200:OK:application/json

Followed by

2021-01-14 18:21:42 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.de/api/devices-v2/device returned 200:OK:application/json 2021-01-14 18:21:42 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.de/api/dnd/device-status-list returned 200:OK:application/json 2021-01-14 18:21:43 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.de/api/device-preferences returned 200:OK:application/json 2021-01-14 18:21:43 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.de/api/bluetooth?cached=false returned 200:OK:application/json 2021-01-14 18:21:43 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.de/api/activities?startTime=&size=10&offset=1 returned 200:OK:application/json 2021-01-14 18:21:43 DEBUG (MainThread) [alexapy.alexalogin] Updating self._cookies with amazon.de session cookies:

After that the mentioned cookies will be set. But I've searched through a damn long log file (because of some Homematic components that flood the log 😄 ) and found nothing about "Updated xx notifications for xx devices at..." or "Sensor value ..."

alandtse commented 3 years ago

Did you enable logging for the custom component too? Or is it just alexapy?

piny0 commented 3 years ago

I have added alexapy: debug into my configuration file and clicked on debugging while plugin configuration. Is there any other I have to do for it? Like the alexapy: debug? Can you tell me what to add to the configuration.yaml?

alandtse commented 3 years ago

https://github.com/custom-components/alexa_media_player/wiki/FAQ#how-do-i-enable-debug-logging-for-the-component

piny0 commented 3 years ago

Hey there, I found this after enabling debuggin for the custom component:


2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found 9************9F8 dnd switch with status: True
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found 9************9F8 shuffle switch with status: False
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found 9************9F8 repeat switch with status: False
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************C0U dnd switch with status: True
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************C0U shuffle switch with status: False
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************C0U repeat switch with status: False
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************061 dnd switch with status: False
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Skipping shuffle for G************061
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Skipping repeat for G************061
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************3H6 dnd switch with status: True
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************3H6 shuffle switch with status: False
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************3H6 repeat switch with status: False
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************1TN dnd switch with status: True
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************1TN shuffle switch with status: False
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************1TN repeat switch with status: False
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************PCS dnd switch with status: True
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************PCS shuffle switch with status: False
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.switch] p*****4@g************m: Found G************PCS repeat switch with status: False

Edit: Forgot the Sensor logs sorry:

2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Loading sensors
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found 9************9F8 Alarm sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found 9************9F8 Timer sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found 9************9F8 Reminder sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************C0U Alarm sensor (5) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************C0U Timer sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************C0U Reminder sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************061 Alarm sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************061 Timer sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************061 Reminder sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************3H6 Alarm sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************3H6 Timer sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************3H6 Reminder sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************1TN Alarm sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************1TN Timer sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************1TN Reminder sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************PCS Alarm sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************PCS Timer sensor (0) with next: None
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] p*****4@g************m: Found G************PCS Reminder sensor (0) with next: None

2021-01-17 13:37:10 DEBUG (SyncWorker_40) [custom_components.alexa_media.sensor] Updating sensor <Entity Küche next Alarm: unavailable>
2021-01-17 13:37:10 DEBUG (SyncWorker_40) [custom_components.alexa_media.sensor] Updating sensor <Entity Küche next Timer: 2021-01-17T13:44:09+01:00>
2021-01-17 13:37:10 DEBUG (SyncWorker_40) [custom_components.alexa_media.sensor] Updating sensor <Entity Küche next Reminder: unavailable>

2021-01-17 13:44:18 DEBUG (MainThread) [custom_components.alexa_media] p*****4@g************m: Updated 6 notifications for 3 devices at 2021-01-17 13:44:18.808105+01:00

2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.helpers] alexa_media.notify.async_get_service: Trying with limit 5 delay 2 catch_exceptions True
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.helpers] alexa_media.notify.async_get_service: Try: 1/5 after waiting 0 seconds result: <custom_components.alexa_media.notify.AlexaNotificationService object at 0x7f85e2af1d90>
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] Sensor value ('xxxx', {'alarmTime': 1608508800000, 'assigner': None, 'automationId': None, 'createdDate': 1606858423467, 'deferredAtTime': None, 'deliveryType': None, 'deviceName': None, 'deviceSerialNumber': 'xxxx', 'deviceType': 'A10A33FOX2NUBK', 'extensibleAttribute': None, 'geoLocationTriggerData': None, 'id': 'xxx', 'lastOccurrenceTimeInMilli': 0, 'lastUpdatedDate': 0, 'loopCount': None, 'mrmGroupContext': None, 'musicAlarmId': None, 'musicEntity': None, 'notificationIndex': 'xxx', 'originalDate': '2020-12-21', 'originalTime': '06:21:00.000', 'personProfile': None, 'provider': None, 'rRuleData': None, 'recurrenceEligibility': False, 'recurringPattern': 'XXXX-WD', 'remainingTime': 0, 'reminderAppLabel': None, 'reminderLabel': None, 'reminderSubLabel': None, 'skillInfo': None, 'snoozedToTime': None, 'sound': {'displayName': 'Orcas', 'folder': None, 'id': 'system_alerts_soothing_05', 'isChildDirected': False, 'pricing': None, 'providerId': 'ECHO', 'sampleUrl': 'https://s3.amazonaws.com/deeappservice.prod.notificationtones/system_alerts_soothing_05.mp3'}, 'status': 'OFF', 'targetPersonProfiles': None, 'timeZoneId': None, 'timerLabel': None, 'tmwNotificationProperties': None, 'triggerTime': 0, 'type': 'Alarm', 'version': '848', 'date_time': datetime.datetime(2020, 12, 21, 6, 21, tzinfo=<DstTzInfo 'Europe/Paris' CET+1:00:00 STD>)})
2021-01-17 01:05:40 DEBUG (MainThread) [custom_components.alexa_media.sensor] Sensor value ('xxxx', {'alarmTime': 0, 'assigner': None, 'automationId': None, 'createdDate': 1608681740753, 'deferredAtTime': None, 'deliveryType': None, 'deviceName': None, 'deviceSerialNumber': 'xxxx', 'deviceType': 'A10A33FOX2NUBK', 'extensibleAttribute': None, 'geoLocationTriggerData': None, 'id': 'xxx', 'lastOccurrenceTimeInMilli': 0, 'lastUpdatedDate': 0, 'loopCount': None, 'mrmGroupContext': None, 'musicAlarmId': None, 'musicEntity': None, 'notificationIndex': 'xxx', 'originalDate': '2021-01-03', 'originalTime': '10:30:00.000', 'personProfile': None, 'provider': None, 'rRuleData': None, 'recurrenceEligibility': False, 'recurringPattern': None, 'remainingTime': 0, 'reminderAppLabel': None, 'reminderLabel': None, 'reminderSubLabel': None, 'skillInfo': None, 'snoozedToTime': None, 'sound': {'displayName': 'Orcas', 'folder': None, 'id': 'system_alerts_soothing_05', 'isChildDirected': False, 'pricing': None, 'providerId': 'ECHO', 'sampleUrl': 'https://s3.amazonaws.com/deeappservice.prod.notificationtones/system_alerts_soothing_05.mp3'}, 'status': 'OFF', 'targetPersonProfiles': None, 'timeZoneId': None, 'timerLabel': None, 'tmwNotificationProperties': None, 'triggerTime': 0, 'type': 'Alarm', 'version': '6', 'date_time': datetime.datetime(2021, 1, 3, 10, 30, tzinfo=<DstTzInfo 'Europe/Paris' CET+1:00:00 STD>)})
alandtse commented 3 years ago

Which sensor isn't working? The log is showing data is coming in.

piny0 commented 3 years ago

Especially those regarding next alarm, next reminder, see here:

grafik

next_reminder applies to all my Echo devices, whereas next_alarm is working on one device:

grafik

grafik

Edit: Although I do agree with your solution, none of my automations get triggered. It seems that I somehow messed up with my HA instance, I've set up a new one and installed your addon there and it works now in the new instance but not in the old one. I start to migrate all my settings to the new one and hope everything works as expected. Thanks for you assistance!

alandtse commented 3 years ago

Those are always unavailable if you do not have a timer, alarm, or notification setup. Once you have one of those, they will become available. That is expected behavior.