Echo Devices (Alexa) as Media Player - Testers Needed

multiline templates require a “>”.

like this:

data_template:
  target: >
    {% if now().strftime("%H%M")|int > 0759 and now().strftime("%H%M")|int < 2100 %}
      media_player.alexa_1, media_player.alexa_2, media_player.alexa_3
    {% else %}
      media_player.alexa_1, media_player.alexa_2
    {% endif %}
  data:
    type: tts
  message: "speech example"

By the way: From my point of view the component works perfect and should be a standard integration
There ist nothing to test instead of new features when provided

In the end: great work and very stable!!

I had this working but decided to change the name of one of my echo devices on Amazon from ‘Bedroom’ to ‘My Bedroom’.
I restarted HA but it still shows up as media_player_bedroom not media_player_my_bedroom.
Is there something else I need to edit?

Templates always return strings, it is not possible to have a template return a list. This means it will just return something like “media_player.alexa_1, media_player.alexa_2, media_player.alexa_3” which the component will most likely interpret as a single item rather than a list.

To do what you want, it may be best to create some groups in Home Assistant which contain the different sets of devices, and use the group names in your template.

Alternatively, if you already have multi-room audio groups containing those devices, you can use those (whether this works this may depend on the notification method you are using).

My apologies if this has been asked and answered already. I have no problems enabling Alexa Guard mode using this component. When I do, the button I press in lovelace changes color to show the status of whether Alexa Guard has been enabled or disabled.

However if Alexa Guard is enabled or disabled by saying to the Amazon echo, “I’m leaving”, or disabled by saying “I’m home”, the state for Alexa Guard doesn’t change in Home Assistant.

Is there a way for the state of my entity, alarm_control_panel.alexa_guard_18020, to become “disarmed” if Alexa Guard is disarmed using Alexa? If not, anyone know a “work around”?

That sounds like a bug. Can you open an issue please and provide some logs for alexapy while testing this use case?

The websocket method should automatically detect the change since it will always check the guard state on any voice command. What may have happened is the websocket got disconnected so it’s relying on the polling mechanism which could take a few minutes to update.

1 Like

Is adding the following to configuration.yaml sufficient to create logs for alexapy?

logger:
  logs:
    alexapy: debug

Or should I enable the other log entries too?

EDIT:

Issue created with log entries added here:

https://github.com/keatontaylor/alexa_media_player/issues/256

Since upgrading the Alexa Media Player component to 1.3.1, I’m seeing a lot of errors in my HA Log:

2019-07-15 21:07:59 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/alexa/state_report.py", line 47, in async_entity_state_listener
    alexa_changed_entity)
  File "/usr/src/app/homeassistant/components/alexa/state_report.py", line 92, in async_send_changereport_message
    allow_redirects=True)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 371, in _request
    url = URL(str_or_url)
  File "/usr/local/lib/python3.7/site-packages/yarl/__init__.py", line 151, in __new__
    raise TypeError("Constructor parameter should be str")
TypeError: Constructor parameter should be str

I’m running 0.95.4 Hass.
Anyone else experiencing this?

This error is not the custom component from this thread. This is the built in component that ships with HA.

Hi all,

I install the component thru HAC and added the information in my config file, got the captcha, enter the info and did the restart of HA, but prompted again with the captcha and kept repeating the process.

Afterwards I tried to login the Alexa App and noticed now its was not working. Removed it from the config file, restarted HA and the app starting working again. I noticed I received several Amazon Authentication emails with codes.

Any suggestion on how to get it working?

HA 0.95.4
installed thru HAC

I’m having a problem getting this going, I’ve cloned the repo using git & then symlinked the repo’s custom_components/alexa_media to HA’s custom_components directory and added the config required to configuration.yaml. I’m using symlinks so that updates in future will be easier.

When HA starts I get an error in the log: Setup failed for alexa_media: Integration not found.

Here’s the config I added:

alexa_media:
  accounts:
    - email: !secret amazon_username
      password: !secret amazon_password
      url: amazon.com

Any ideas?

I did similar and found the easiest way to fix it was (assuming you are running hassos and can ssh into the box):

  • to go into the /config/.storage directory
  • delete files core.entity_registry and core.restore_state
  • reboot and let HA recreate your entity registries
1 Like

Not at all relevant to the current conversation, but has anyone got alexa to ask a question and wait for a response.
something like the temperature hitting a threshold, then asking if id like the heating on and waiting for a yes or no response before taking action

Hi,

Is there a way to implement this for non-hassio users?

Thanks,
Regards,
Dieter

Anyone know with the new notify domain how to do this with an api call? I was using the alexa tts for api calls of from outside of HA for other things that I wanted to do TTS. But now its broken. Thanks. :slight_smile:

Yes, it’s a custom component so you can just install it like any other custom component. Or install HACS (home assistant community store) and you can more easily install it/update.

Try without the symlinks. If you’re using any virtualization symlinks may not be followed. I can’t tell based off your config whether you are.

Wiki

It seems it doesn’t work on Sonos One type devices. I tried it on a Beam and I can’t get it to work either. It’s odd that the Beam shows up as an alexa media player but sending audio to it yields crickets.

Can someone here please confirm your Alexa Guard experience is the same as mine as described below:

Say to Alexa, "I’m Leaving"
Alexapy log get guard_state response value = “Armed_Stay”
HA Alexa Guard Entity = “disarmed”

Say to Alexa, "I’m Home"
Alexapy log get guard_state response value = “Armed_Away”
HA Alexa Guard Entity = “disarmed”

Manually ENABLE Guard from with Home Assistant using this component
Alexapy log get guard_state response value = “Armed_Away”
HA Alexa Guard Entity = “armed_away”

Manually DISABLE Guard from with Home Assistant using this component
Alexapy log get guard_state response value = “Armed_Stay”
HA Alexa Guard Entity = “disarmed”

So only if I manually enable/disable does my Alexa Guard entity show the correct state. It looks like the response received from Alexa when vocally enabling or disabling Guard is exactly opposite of what it should be.

Can someone confirm with their setup? You can enable alexapy logging to your HA log by adding the following to configuration yaml:

logger:
  default: info
  logs:
    alexapy: debug

Just to recap what seems to be the root of the problem:
When I enable Guard by voice, the guard_state_response is Armed_Stay
but when I enable Guard using this component, the guard_state_response is Armed_Away.

1 Like

Hi all, ive been trying to get this component to function for the last few days.

It just does not respond to any commands for some reason. (it does show the state correctly so i can see whats playing on what echo device).

But my echos just do not respond to any of my service calls… i cant find any errors in the log either.

2019-07-21 11:39:45 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1812398576] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'media_player.downstairs', 'old_state': <state media_player.downstairs=paused; volume_level=0.67, is_volume_muted=False, media_content_type=music, media_duration=316, media_position=159, media_position_updated_at=2019-07-21T11:28:34.621345+02:00, media_title=Liars, media_artist=Gregory Alan Isakov, media_album_name=Gregory Alan Isakov with the Colorado Symphony, source=Local Speaker, source_list=['Local Speaker'], available=True, last_called=True, friendly_name=Downstairs, entity_picture=/api/media_player_proxy/media_player.downstairs?token=25b672eec6706e8d3d385798b61277bf29aec9a20ff518b9855d6a8f75d941e2&cache=9d391667edde4fc2, supported_features=23485 @ 2019-07-21T11:28:23.240802+02:00>, 'new_state': <state media_player.downstairs=playing; volume_level=0.67, is_volume_muted=False, media_content_type=music, media_duration=316, media_position=159, media_position_updated_at=2019-07-21T11:39:45.831217+02:00, media_title=Liars, media_artist=Gregory Alan Isakov, media_album_name=Gregory Alan Isakov with the Colorado Symphony, source=Local Speaker, source_list=['Local Speaker'], available=True, last_called=True, friendly_name=Downstairs, entity_picture=/api/media_player_proxy/media_player.downstairs?token=25b672eec6706e8d3d385798b61277bf29aec9a20ff518b9855d6a8f75d941e2&cache=9d391667edde4fc2, supported_features=23485 @ 2019-07-21T11:39:45.833561+02:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 7, 21, 9, 39, 45, 833719, tzinfo=<UTC>), 'context': {'id': '479fc7d24e4c44abb61b67a745ebfd0d', 'parent_id': None, 'user_id': None}}}
2019-07-21 11:39:45 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1812398576] Sending {'id': 3, 'type': 'event', 'event': <Event state_changed[L]: entity_id=media_player.downstairs, old_state=<state media_player.downstairs=paused; volume_level=0.67, is_volume_muted=False, media_content_type=music, media_duration=316, media_position=159, media_position_updated_at=2019-07-21T11:28:34.621345+02:00, media_title=Liars, media_artist=Gregory Alan Isakov, media_album_name=Gregory Alan Isakov with the Colorado Symphony, source=Local Speaker, source_list=['Local Speaker'], available=True, last_called=True, friendly_name=Downstairs, entity_picture=/api/media_player_proxy/media_player.downstairs?token=25b672eec6706e8d3d385798b61277bf29aec9a20ff518b9855d6a8f75d941e2&cache=9d391667edde4fc2, supported_features=23485 @ 2019-07-21T11:28:23.240802+02:00>, new_state=<state media_player.downstairs=playing; volume_level=0.67, is_volume_muted=False, media_content_type=music, media_duration=316, media_position=159, media_position_updated_at=2019-07-21T11:39:45.831217+02:00, media_title=Liars, media_artist=Gregory Alan Isakov, media_album_name=Gregory Alan Isakov with the Colorado Symphony, source=Local Speaker, source_list=['Local Speaker'], available=True, last_called=True, friendly_name=Downstairs, entity_picture=/api/media_player_proxy/media_player.downstairs?token=25b672eec6706e8d3d385798b61277bf29aec9a20ff518b9855d6a8f75d941e2&cache=9d391667edde4fc2, supported_features=23485 @ 2019-07-21T11:39:45.833561+02:00>>}
2019-07-21 11:39:45 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1778899760] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=media_player.downstairs, old_state=<state media_player.downstairs=paused; volume_level=0.67, is_volume_muted=False, media_content_type=music, media_duration=316, media_position=159, media_position_updated_at=2019-07-21T11:28:34.621345+02:00, media_title=Liars, media_artist=Gregory Alan Isakov, media_album_name=Gregory Alan Isakov with the Colorado Symphony, source=Local Speaker, source_list=['Local Speaker'], available=True, last_called=True, friendly_name=Downstairs, entity_picture=/api/media_player_proxy/media_player.downstairs?token=25b672eec6706e8d3d385798b61277bf29aec9a20ff518b9855d6a8f75d941e2&cache=9d391667edde4fc2, supported_features=23485 @ 2019-07-21T11:28:23.240802+02:00>, new_state=<state media_player.downstairs=playing; volume_level=0.67, is_volume_muted=False, media_content_type=music, media_duration=316, media_position=159, media_position_updated_at=2019-07-21T11:39:45.831217+02:00, media_title=Liars, media_artist=Gregory Alan Isakov, media_album_name=Gregory Alan Isakov with the Colorado Symphony, source=Local Speaker, source_list=['Local Speaker'], available=True, last_called=True, friendly_name=Downstairs, entity_picture=/api/media_player_proxy/media_player.downstairs?token=25b672eec6706e8d3d385798b61277bf29aec9a20ff518b9855d6a8f75d941e2&cache=9d391667edde4fc2, supported_features=23485 @ 2019-07-21T11:39:45.833561+02:00>>}
2019-07-21 11:39:48 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1778899760] Received {'type': 'call_service', 'domain': 'media_player', 'service': 'media_next_track', 'service_data': {'entity_id': 'media_player.downstairs'}, 'id': 23}
2019-07-21 11:39:48 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=media_player, service=media_next_track, service_data=entity_id=media_player.downstairs>
2019-07-21 11:39:48 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1812398576] Sending {'id': 2, 'type': 'event', 'event': {'event_type': 'call_service', 'data': {'domain': 'media_player', 'service': 'media_next_track', 'service_data': {'entity_id': 'media_player.downstairs'}}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2019, 7, 21, 9, 39, 48, 905732, tzinfo=<UTC>), 'context': {'id': '674601fda4e745608a347dff307fea61', 'parent_id': None, 'user_id': 'd925c0117c084737ab092bdd67cc52cc'}}}

Can anyone point me in the right direction?

i have Hassos and installed this component through HACS.
-ive tried different regions (i live in Netherlands) and these are the results:

amazon.com: is the only url that correctly displays the current states of media_players in frontend
amazon.nl: does not display the current state in frontend but in the log it does correctly show the state
changes.

Ive done complete wipe of .pickle and custom component including restarts when switching regions.