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.51k stars 289 forks source link

notification sensors (next_alarm, next_timer, next_reminder) do not exist #1272

Closed hugalafutro closed 3 years ago

hugalafutro commented 3 years ago

Describe the bug I'm interested in reacting to timer/alarm firing off on my echo dot, for which I'd like to utilise sensor.media_player_next_alarm sensor.media_player_next_timer sensors, but these entities are non-existent. The only things I am able to see when clicking on the echo dot entity are standby button, volume slider and speaker dropdown.

To Reproduce Steps to reproduce the behavior: N/A

Expected behavior I'd like to have the aforementioned sensors exist and contain values corresponding to next alarm/timer expiration or None as the documentation suggests.

Screenshots N/A

System details

Logs

2021-05-02 17:19:44 DEBUG (MainThread) [custom_components.alexa_media] Nothing to import from configuration.yaml, loading from Integrations
2021-05-02 17:19:45 INFO (MainThread) [custom_components.alexa_media]
-------------------------------------------------------------------
alexa_media
Version: 3.9.0
This is a custom component
If you have any issues with this you need to open an issue here:
https://github.com/custom-components/alexa_media_player/issues
-------------------------------------------------------------------
2021-05-02 17:19:45 INFO (MainThread) [custom_components.alexa_media] Loaded alexapy==1.25.0
2021-05-02 17:19:45 DEBUG (MainThread) [custom_components.alexa_media.helpers] s*******s@g*******m: Returning uuid {'uuid': '72a31afd1e68d474229577ad43a9e49a', 'index': 0}
2021-05-02 17:19:46 DEBUG (MainThread) [custom_components.alexa_media.helpers] s*******s@g*******m: Returning uuid {'uuid': '72a31afd1e68d474229577ad43a9e49a', 'index': 0}
2021-05-02 17:19:52 DEBUG (MainThread) [custom_components.alexa_media] Testing login status: {'login_successful': True}
2021-05-02 17:19:52 DEBUG (MainThread) [custom_components.alexa_media] Setting up Alexa devices for s*******s@g*******m
2021-05-02 17:19:52 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Websocket created: <alexapy.alexawebsocket.WebsocketEchoClient object at 0xe6a69430>
2021-05-02 17:19:52 DEBUG (MainThread) [custom_components.alexa_media] Testing login status: {'login_successful': True}
2021-05-02 17:19:52 DEBUG (MainThread) [custom_components.alexa_media] Setting up Alexa devices for s*******s@g*******m
2021-05-02 17:19:52 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Websocket created: <alexapy.alexawebsocket.WebsocketEchoClient object at 0xe6a690a0>
2021-05-02 17:19:53 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Received websocket error #0 <class 'alexapy.aiohttp.streams.EofStream'>: type <class 'str'>
2021-05-02 17:19:53 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Websocket closed; reconnect #1 in 10s
2021-05-02 17:19:53 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Websocket created: <alexapy.alexawebsocket.WebsocketEchoClient object at 0xea44dfe8>
2021-05-02 17:19:53 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Websocket creation failed: Cannot write to closing transport
2021-05-02 17:19:53 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Creating coordinator
2021-05-02 17:19:53 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Refreshing coordinator
2021-05-02 17:19:53 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Websocket successfully connected
2021-05-02 17:19:53 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Reusing coordinator
2021-05-02 17:19:53 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Refreshing coordinator
2021-05-02 17:19:53 DEBUG (MainThread) [custom_components.alexa_media] Alexa entities have been loaded. Prepared for discovery.
2021-05-02 17:19:53 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Found 2 devices, 2 bluetooth
2021-05-02 17:19:54 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Websocket successfully connected
2021-05-02 17:19:54 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Updated 34 notifications for 2 devices at 2021-05-02 17:19:54.401171+01:00
2021-05-02 17:19:54 DEBUG (MainThread) [custom_components.alexa_media] Alexa entities have been loaded. Prepared for discovery.
2021-05-02 17:19:54 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Found 2 devices, 2 bluetooth
2021-05-02 17:19:54 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Updated last_called: {'serialNumber': 'G************L96', 'timestamp': 1619972294361, 'summary': 'next one'}
2021-05-02 17:19:54 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: last_called changed: to {'serialNumber': 'G************L96', 'timestamp': 1619972294361, 'summary': 'next one'}
2021-05-02 17:19:54 DEBUG (MainThread) [custom_components.alexa_media] David's Echo Dot: Locale en-gb timezone Europe/London
2021-05-02 17:19:54 DEBUG (MainThread) [custom_components.alexa_media] David's Echo Dot: DND False
2021-05-02 17:19:54 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Existing: [] New: ["David's Echo Dot"]; Filtered out by not being in include: ['This Device'] or in exclude: []
2021-05-02 17:19:54 DEBUG (MainThread) [custom_components.alexa_media] Loading config entry for media_player
2021-05-02 17:19:54 DEBUG (MainThread) [custom_components.alexa_media] Finished fetching alexa_media data in 1.511 seconds
2021-05-02 17:19:54 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Updated 34 notifications for 2 devices at 2021-05-02 17:19:54.836063+01:00
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Updated last_called: {'serialNumber': 'G************L96', 'timestamp': 1619972294361, 'summary': 'next one'}
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media] David's Echo Dot: Locale en-gb timezone Europe/London
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media] David's Echo Dot: DND False
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Existing: [] New: ["David's Echo Dot"]; Filtered out by not being in include: ['This Device'] or in exclude: []
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media] Loading config entry for media_player
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media] Finished fetching alexa_media data in 1.075 seconds
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.media_player] s*******s@g*******m: Refreshing <Entity David's Echo Dot: standby>
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.media_player] s*******s@g*******m: David's Echo Dot: Last_called check: self: G************L96 reported:
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.helpers] s*******s@g*******m: Adding [<Entity David's Echo Dot: standby>]
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.media_player] s*******s@g*******m: Loading notify
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.media_player] s*******s@g*******m: Loading config entry for switch
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.media_player] s*******s@g*******m: Loading config entry for sensor
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.media_player] s*******s@g*******m: Loading config entry for alarm_control_panel
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.media_player] s*******s@g*******m: Loading config entry for light
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.switch] s*******s@g*******m: Loading switches
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.switch] s*******s@g*******m: Found G************L96 dnd switch with status: False
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.switch] s*******s@g*******m: Found G************L96 shuffle switch with status: False
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.switch] s*******s@g*******m: Found G************L96 repeat switch with status: False
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.helpers] s*******s@g*******m: Excluding device: <Entity David's Echo Dot do not disturb switch: off>
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.helpers] s*******s@g*******m: Excluding device: <Entity David's Echo Dot shuffle switch: off>
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.helpers] s*******s@g*******m: Excluding device: <Entity David's Echo Dot repeat switch: off>
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.sensor] s*******s@g*******m: Loading sensors
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.sensor] s*******s@g*******m: Found G************L96 Alarm sensor (30) with next: None
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.sensor] s*******s@g*******m: Found G************L96 Timer sensor (3) with next: None
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.sensor] s*******s@g*******m: Found G************L96 Reminder sensor (1) with next: None
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.helpers] s*******s@g*******m: Excluding device: <Entity David's Echo Dot next Alarm: None>
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.helpers] s*******s@g*******m: Excluding device: <Entity David's Echo Dot next Timer: None>
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.helpers] s*******s@g*******m: Excluding device: <Entity David's Echo Dot next Reminder: None>
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.helpers] alexa_media.notify.async_get_service: Trying with limit 5 delay 2 catch_exceptions True
2021-05-02 17:19:55 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 0xea303e80>
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.alarm_control_panel] sammaelus@gmail.com: No Alexa Guard entity found
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.alarm_control_panel] s*******s@g*******m: Skipping creation of uninitialized device: None
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media] Completing remaining startup tasks.
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media] Completing remaining startup tasks.
2021-05-02 17:20:05 DEBUG (MainThread) [custom_components.alexa_media.media_player] s*******s@g*******m: Refreshing <Entity David's Echo Dot: standby>
2021-05-02 17:20:05 DEBUG (MainThread) [custom_components.alexa_media.media_player] s*******s@g*******m: David's Echo Dot: Last_called check: self: G************L96 reported: G************L96
2021-05-02 17:20:05 DEBUG (MainThread) [custom_components.alexa_media.media_player] s*******s@g*******m: Refreshing notify targets
2021-05-02 17:20:05 DEBUG (MainThread) [custom_components.alexa_media.notify] s*******s@g*******m: Creating last_called target last_called using <Entity David's Echo Dot: standby>
2021-05-02 17:20:05 DEBUG (MainThread) [custom_components.alexa_media.notify] s*******s@g*******m: Creating last_called target last_called using <Entity David's Echo Dot: standby>
2021-05-02 17:20:09 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Updated 34 notifications for 2 devices at 2021-05-02 17:20:07.941997+01:00
2021-05-02 17:20:09 DEBUG (MainThread) [custom_components.alexa_media] Refreshing notify targets
2021-05-02 17:20:09 DEBUG (MainThread) [custom_components.alexa_media.notify] s*******s@g*******m: Creating last_called target last_called using <Entity David's Echo Dot: standby>
2021-05-02 17:20:09 DEBUG (MainThread) [custom_components.alexa_media.notify] s*******s@g*******m: Creating last_called target last_called using <Entity David's Echo Dot: standby>
2021-05-02 17:20:09 DEBUG (MainThread) [custom_components.alexa_media] Refreshing notify targets
2021-05-02 17:20:09 DEBUG (MainThread) [custom_components.alexa_media.notify] s*******s@g*******m: Creating last_called target last_called using <Entity David's Echo Dot: standby>
2021-05-02 17:20:09 DEBUG (MainThread) [custom_components.alexa_media.notify] s*******s@g*******m: Creating last_called target last_called using <Entity David's Echo Dot: standby>
2021-05-02 17:20:10 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Updated last_called: {'serialNumber': 'G************L96', 'timestamp': 1619972294361, 'summary': 'next one'}
2021-05-02 17:20:10 DEBUG (MainThread) [custom_components.alexa_media] David's Echo Dot: Locale en-gb timezone Europe/London
2021-05-02 17:20:10 DEBUG (MainThread) [custom_components.alexa_media] David's Echo Dot: DND False
2021-05-02 17:20:10 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Existing: [<Entity David's Echo Dot: standby>] New: []; Filtered out by not being in include: ['This Device'] or in exclude: []
2021-05-02 17:20:10 DEBUG (MainThread) [custom_components.alexa_media] Finished fetching alexa_media data in 6.611 seconds
2021-05-02 17:20:10 DEBUG (MainThread) [custom_components.alexa_media.media_player] s*******s@g*******m: Changing notify.targets is not supported by HA version < 2021.2.0; using toggle method
2021-05-02 17:20:12 DEBUG (MainThread) [custom_components.alexa_media.notify] s*******s@g*******m: Creating last_called target last_called using <Entity David's Echo Dot: standby>
2021-05-02 17:20:12 DEBUG (MainThread) [custom_components.alexa_media.notify] s*******s@g*******m: Creating last_called target last_called using <Entity David's Echo Dot: standby>
2021-05-02 17:20:13 DEBUG (MainThread) [custom_components.alexa_media.media_player] s*******s@g*******m: Disabling polling for David's Echo Dot

Additional context I only use alexa for TTS and playing sounds and that works no problem.

blm126 commented 3 years ago

2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media] s*******s@g*******m: Existing: [] New: ["David's Echo Dot"]; Filtered out by not being in include: ['This Device'] or in exclude: []

The sensors are being filtered out.

hugalafutro commented 3 years ago

Ok, that log line is to me quite confusing; what I read is that there was 1 new, 0 existing devices and no filtered out as neither criteria of include: ['This Device'] (ie a whitelist) nor exclude: [] (ie a blacklist) were satisfied and at no point I see it mentioning notifications.

edit: these lines prove the notifications are read:

2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.sensor] s*******s@g*******m: Found G************L96 Alarm sensor (30) with next: None
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.sensor] s*******s@g*******m: Found G************L96 Timer sensor (3) with next: None
2021-05-02 17:19:55 DEBUG (MainThread) [custom_components.alexa_media.sensor] s*******s@g*******m: Found G************L96 Reminder sensor (1) with next: None

the issue is the corresponding sensors are not created, as I understood from the documentation they should exist with value None inside HA in this state.

thexperiments commented 3 years ago

Same issue here. Timer devices/entities are not available anymore

I configured vie HACS and the Integrations UI, nothing in include_devices nor in exclude_devices...

            {
                "entry_id": "xxxxxxxx",
                "version": 1,
                "domain": "alexa_media",
                "title": "xxx.xxx@xxx.com - amazon.de",
                "data": {
                    "email": "xxx.xxx@xxx.com",
                    "password": "*xxx*!",
                    "url": "amazon.de",
                    "debug": false,
                    "scan_interval": 60,
                    "include_devices": "",
                    "exclude_devices": "",
                    "proxy": false,
                    "oauth": {
                        "access_token": "xxx",
                        "refresh_token": "xxx",
                        "expires_in": 1619983836.526745
                    }
                },
                "options": {},
                "system_options": {
                    "disable_new_entities": false
                },
                "source": "reauth",
                "connection_class": "cloud_poll",
                "unique_id": "xxx.xxx@xxx.com - amazon.de",
                "disabled_by": null
            },
alandtse commented 3 years ago

As @blm126 already said, if you didn't include the next_alarm, next_timer, next_reminder in your allow list. They'll be filtered out. https://github.com/custom-components/alexa_media_player/wiki/Configuration#inclusions

Remove your allow list and they'll populate.

thexperiments commented 3 years ago

Ok so I need to remove the include list completely in the config?

As said I have the default config when installing via HACS and configuring via Integrations. I guess this is the most common way to get alexa mediaplayer. Therfore many people will have this problem and I can't se a way to configure these details via the web UI.

Luckily I know that the config is in /config/.storage/core.config_entries and I can change it manually but this is a bit error prone.

It would be great if these configs are part of the web UI. Or is there any other way to change them I'm not aware of?

BTW: The help you linked is great if you have configured it manually, sadly when you add it via integrations web UI there is nothing in your config.yaml and you need to configure it within the "internal" config in a json file...

hugalafutro commented 3 years ago

I'll echo @thexperiments sentiments. This is very counterintuitive and obscure to set up especially if you set up via ui, which is supposed to be the easier way.

Can you offer instructions on how to achieve this when configured via ui? How do I "Remove my allow list" ? I can't see nothing of the like in the ui configuration.

Thanks

edit: I'm getting more confused the more I read the docs. "_NOTE: includedevices only loads devices that have been listed and functions like a deny list." What does that even mean?

the relevant section in core.config_entries:

 {
                "entry_id": "4836092992b048b5a6daed01521cc291",
                "version": 1,
                "domain": "alexa_media",
                "title": "Echo Dot",
                "data": {
                    "debug": false,
                    "email": "s***m",
                    "exclude_devices": [],
                    "include_devices": [
                        "David's Echo Dot"
                    ],
                    "password": "***",
                    "scan_interval": 60,
                    "url": "amazon.co.uk",
                    "oauth": {
                        "access_token": ***
                        "refresh_token": ***
                        "expires_in": 1620032590.19631
                    }
                },
                "options": {
                    "queue_delay": 1.5,
                    "extended_entity_discovery": false
                },
                "system_options": {
                    "disable_new_entities": false
                },
                "source": "user",
                "connection_class": "cloud_poll",
                "unique_id": null,
                "disabled_by": null
            },

So, in order to include the David's Echo Dot, I do need to REMOVE it from the include list? I'm sorry for not being a technical guru I just want my lights to blink when alarm goes off.

edit2: i tried cutting out the block and rebooting HA, but that didn't do it

                    "include_devices": [
                        "David's Echo Dot"
                    ],

edit3: the sensors appeared after cutting out the "exclude_devices": [], line and restarting HA. I have no understanding why.

hyukishi commented 3 years ago

I'll echo @thexperiments sentiments. This is very counterintuitive and obscure to set up especially if you set up via ui, which is supposed to be the easier way.

Can you offer instructions on how to achieve this when configured via ui? How do I "Remove my allow list" ? I can't see nothing of the like in the ui configuration.

Thanks

edit: I'm getting more confused the more I read the docs. "_NOTE: includedevices only loads devices that have been listed and functions like a deny list." What does that even mean?

the relevant section in core.config_entries:

 {
                "entry_id": "4836092992b048b5a6daed01521cc291",
                "version": 1,
                "domain": "alexa_media",
                "title": "Echo Dot",
                "data": {
                    "debug": false,
                    "email": "s***m",
                    "exclude_devices": [],
                    "include_devices": [
                        "David's Echo Dot"
                    ],
                    "password": "***",
                    "scan_interval": 60,
                    "url": "amazon.co.uk",
                    "oauth": {
                        "access_token": ***
                        "refresh_token": ***
                        "expires_in": 1620032590.19631
                    }
                },
                "options": {
                    "queue_delay": 1.5,
                    "extended_entity_discovery": false
                },
                "system_options": {
                    "disable_new_entities": false
                },
                "source": "user",
                "connection_class": "cloud_poll",
                "unique_id": null,
                "disabled_by": null
            },

So, in order to include the David's Echo Dot, I do need to REMOVE it from the include list? I'm sorry for not being a technical guru I just want my lights to blink when alarm goes off.

edit2: i tried cutting out the block and rebooting HA, but that didn't do it

                    "include_devices": [
                        "David's Echo Dot"
                    ],

edit3: the sensors appeared after cutting out the "exclude_devices": [], line and restarting HA. I have no understanding why.

Thank you for your edited note at the bottom. My timers haven't shown up accurately for over a week and deleting that excluded devices line from that file worked.

@alandtse please add the configuration changes for included and excluded devices to the UI Integrations config.

hugalafutro commented 3 years ago

@hyukishi I was using alexa_media_player for almost a year and I have never seen the entities, they never existed on my system. I happened upon the fact such entities are supposed to be created only while browsing HA blueprints and seeing automations based on alexa timer going off which is something I've wanted since forever.

alandtse commented 3 years ago

Remove and readd the integration if you need to change the setting. Messing with .storage files may cause HA to not start.