Echo Devices (Alexa) as Media Player - Testers Needed

@keatontaylor Feature request:

Add exclude/include entities option.

I know this is a little edge case but I’m in an Amazon Household with parents who are in another property.(sharing Prime)
Unfortunately the way Amazon handles that is to merge all devices together. So after getting this component working, I have all my parents devices in my HA which isn’t really desirable.

Perfect solution to be able to exclude devices.

Thanks for considering it.

1 Like

This was added in the latest version. Sorry I haven’t posted here about the “release”

1 Like

Is there a change log or release info for the new version somewhere? Sorry I’m struggling to find one.

Hope @keatontaylor doesn’t mind me replying on their behalf. You can use the GitHub history which seems be be pretty well documented and hopefully you can work out what you need from that. Looks like you just need to specify the device name (i presume as listed in the Alexa app) with exclude_devices in the media_player entry of your configuration.yaml. Have a look at: https://github.com/keatontaylor/custom_components/commits/master/media_player/alexa.py

Any clues on the syntax @keatontaylor?

Just a little testing:

- platform: alexa
  email: [email protected]
  password: secret
  url: amazon.com
  exclude_devices:
    - media_player.remcos_alexa_apps
    - media_player.this_device
    - media_player.this_device_2

Does not work.

  exclude_devices:
    - remcos_alexa_apps
    - this_device
    - this_device_2

And

exclude_devices: media_player.remcos_alexa_apps

Also does not work.

1 Like

This code was added by someone other than me to exclude devices. The code looks like it excludes based on the name of your echo in the Alexa app. Can someone give that a try?

Hi Justin,

This looks great! I also plan on connecting a dot to whole house audio and this type of setup looks like it would work well. Could you share your card that calls this flow? I have my head around Node-RED a bit, but haven’t figured out how to connect cards to it other than calling flows via URLs.

Thanks!

FYI, a media_content_type of SIRIUSXM (if you have the skill setup) will also work when playing music.

{
“media_content_id”: “The Blend”,
“media_content_type”: “SIRIUSXM”,
“entity_id”: “media_player.kitchen”
}

This is a great addition and I’m glad I found it! Thank you for all your hard work, Keaton!

1 Like

It’s based off the Alexa name and case sensitive. Specifically, it’s looking for the “accountName” attribute in the json from here (choose url for region).

{"devices":[{"accountName":"Kitchen"},  . . . {"accountName":"Stairs"}, . . .

I haven’t tested it but it should be:

exclude_devices:
  - Kitchen
  - Stairs

Or perhaps do it in quotes if you have spaces, etc.

The code is from @nuttytree. Do you have a working config to share?

2 Likes

The code only would stop the excluded devices from being discovered or updated. If you already have the devices (check your entity registry), it would appear but never update. Are the excluded devices showing music updates?

UPDATE: I actually tested it and was able to exclude devices without deleting from the entity registry.

- platform: alexa
  email: email
  password: password
  url: amazon.com
  exclude_devices:
    - "This Device"
    - "Alan's Alexa Apps"
    - Stairs
    - Garage

I’ll update the wiki with this example. @keatontaylor can you please enable anyone being able to edit the wiki so others can help maintain it?

2 Likes

Got it done @alandtse

Thanks.

All, please note many of the common questions are updated on the wiki. Please review and edit to help others.

1 Like

Sorry, that flow may be a little outdated with my current setup now, but here is the related section of my lovelace config. It basically just contains some input_number/select/text entities I created, and I’m also using a custom “mini media player” component for displaying the currently playing song, along with play/pause buttons. Let me know if you need more help.

type: vertical-stack
cards:
- type: entities
entities:
- type: custom:mini-media-player
entity: media_player.justins_echo_dot
name: Home Audio
hide_power: true
hide_mute: true
group: true
scroll_info: true
more_info: false
hide_volume: true
- input_number.home_audio_volume
- input_text.home_audio_tts
- input_text.song_playlist
- input_select.genre

Thanks! I think I now understand how this gets passed to Node-RED; I make up whatever I want after the input and then listen for a change in Node-RED on that.

I’ll play with it tomorrow and see how far I get.

After updating the the last version of the component, i get an infinite series of these errors:

2018-12-25 11:23:25 ERROR (Thread-2) [custom_components.media_player.alexa] An error occured accessing the API: An exception of type JSONDecodeError occurred. Arguments:
('Expecting value: line 1 column 1 (char 0)',)
2018-12-25 11:23:25 ERROR (Thread-2) [custom_components.media_player.alexa] An error occured accessing the API: An exception of type JSONDecodeError occurred. Arguments:
('Expecting value: line 1 column 1 (char 0)',)
2018-12-25 11:23:25 ERROR (Thread-2) [custom_components.media_player.alexa] An error occured accessing the API: An exception of type JSONDecodeError occurred. Arguments:
('Expecting value: line 1 column 1 (char 0)',)
2018-12-25 11:23:36 ERROR (Thread-21) [custom_components.media_player.alexa] An error occured accessing the API: An exception of type JSONDecodeError occurred. Arguments:
('Expecting value: line 1 column 1 (char 0)',)
2018-12-25 11:23:36 ERROR (Thread-21) [custom_components.media_player.alexa] An error occured accessing the API: An exception of type JSONDecodeError occurred. Arguments:
('Expecting value: line 1 column 1 (char 0)',)
2018-12-25 11:23:36 ERROR (Thread-21) [custom_components.media_player.alexa] An error occured accessing the API: An exception of type JSONDecodeError occurred. Arguments:
('Expecting value: line 1 column 1 (char 0)',)

How to get rid of this?
EDIT: Also all the echo media players disappeared…

Traceback (most recent call last):
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/media_player/alexa.py", line 260, in setup_alexa
update_devices()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/util/__init__.py", line 324, in wrapper
result = method(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/util/__init__.py", line 324, in wrapper
result = method(*args, **kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/media_player/alexa.py", line 232, in update_devices
update_devices, url)
  File "/home/homeassistant/.homeassistant/custom_components/media_player/alexa.py", line 302, in __init__
self.refresh(device)
  File "/home/homeassistant/.homeassistant/custom_components/media_player/alexa.py", line 337, in refresh
if 'playerInfo' in self._session:
TypeError: argument of type 'NoneType' is not iterable

How to downgrade to the previous 0.9.5?
EDIT: It’s not an error due to the last release… i downgraded to 0.9.5 but i got same errors…
Has anyone else the same issues?

…just got the same thing - updated HA to 0.84.6 and this has happened since :frowning:

Going to rollback to 0.84.5 and see

EDIT: same thing on 0.84.5 and 0.84.4:

An error occured accessing the API: An exception of type JSONDecodeError occurred. Arguments:

('Expecting value: line 1 column 1 (char 0)',)

Was the outage affecting some of you?

Might be that but all the dots and echos are working fine, just seems to be since i restarted HA (and updated it). I have since downgraded it and still no luck. It seems to log in ok then errors.

_2018-12-25 16:23:33 DEBUG (SyncWorker_2) [custom_components.media_player.alexa] Logged in._

_ 2018-12-25 16:23:33 DEBUG (SyncWorker_2) [custom_components.media_player.alexa] Using cookies to log in_
_ 2018-12-25 16:23:33 DEBUG (SyncWorker_2) [custom_components.media_player.alexa] Log in successful with cookies_
_ 2018-12-25 16:23:33 DEBUG (SyncWorker_2) [custom_components.media_player.alexa] Setting up Alexa devices_
_ 2018-12-25 16:23:37 ERROR (SyncWorker_2) [custom_components.media_player.alexa] An error occured accessing the API: An exception of type JSONDecodeError occurred. Arguments:_
_ (‘Expecting value: line 1 column 1 (char 0)’,)_

Oh and Merry Christmas all :slight_smile:

It seems so…
After restarting all worked again…

1 Like