Echo Devices (Alexa) as Media Player - Testers Needed

you didn’t mention it but there are three files total that you have to copy to the new alexa_media folder. did you copy all of those files to that location?

I did not. However after doing that, restarting the host and adding the alexa_media to my config I get the same error when I do a config check. I think I’m going to start over from the top when I have more time. I’m obviously missing something as no one else is having an issue with this.

Has anything changed with how volume is handled? I have an automation that remembers the previous volume level when I do a TTS and temporarily turns up the volume and then back down to previous level.
I am getting the following error:

Error while executing automation automation.set_living_room_dot_volume_storage. Invalid data for call_service at pos 1: expected float for dictionary value @ data[‘value’]
Connection lost. Reconnecting…

This is what is causing it:

entity_id: input_number.living_room_dot_volume_storage
value: "{{states.media_player.living_room_dot.attributes.volume_level  }}"

I am guessing in standby it doesn’t have a volume level and that is the problem. I have tried to change it to:

entity_id: input_number.living_room_dot_volume_storage
value: "{{states.media_player.living_room_dot.attributes.volume_level | float }}"

But that gives me this error:

Error rendering data template: UndefinedError: 'mappingproxy object' has no 
attribute 'volume_level'

Sorry i have found the solution for all my questions about play music and tunein radio over automations with alexa -> https://github.com/keatontaylor/alexa_media_player/wiki#play-music

try changing the template to:

value_template: "{{ state_attr('media_player.living_room_dot', 'volume_level') | float }}"

Could you share your automation. I’m looking for something similar to store the brightness and color value of a bulb before I use it to alarm me about sth.

see: Use Light to show some alarm and than go back to last state

finity, that actually threw the same error, but your example lead me to change it to:

value: "{{states('media_player.living_room_dot.attributes.volume_level') | float }}"

Which actually seems to work.

probably should’ve mentioned its part of a data template:

data_template:
  entity_id: input_number.living_room_dot_volume_storage
  value: "{{states('media_player.living_room_dot.attributes.volume_level') | float }}"

h4nc:

- alias: 'set_john_echo_volume_storage'
  trigger:
    platform: state
    entity_id: media_player.john_s_echo
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.johns_echo_volume_storage
      value: "{{states('media_player.john_s_echo.attributes.volume_level') | float }}"
       
- alias: 'set_bedroom_spot_volume_storage'
  trigger:
    platform: state
    entity_id: media_player.bedroom_spot
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.bedroom_spot_volume_storage
      value: "{{states('media_player.bedroom_spot.attributes.volume_level') | float }}"
     
- alias: 'set_living_room_dot_volume_storage'
  trigger:
    platform: state
    entity_id: media_player.living_room_dot
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.living_room_dot_volume_storage
      value: "{{states('media_player.living_room_dot.attributes.volume_level') | float }}"

 - alias: 'Take picture when Door Bell Pressed'
  trigger:
    platform: state
    entity_id: sensor.vision_zd2102_eu_door_window_sensor_access_control_6
    to: '23'
  action:
    - service: automation.turn_off
      entity_id: automation.set_john_echo_volume_storage, automation.set_bedroom_spot_volume_storage, automation.set_living_room_dot_volume_storage
    - service: media_player.media_pause
      entity_id: media_player.john_s_echo, media_player.living_room_dot, media_player.bedroom_spot
    - service: media_player.volume_set
      data:
        entity_id: media_player.john_s_echo, media_player.living_room_dot, media_player.bedroom_spot
        volume_level: "0.7"
    - service: media_player.alexa_tts
      entity_id: media_player.john_s_echo, media_player.living_room_dot, media_player.bedroom_spot
      data:
        message: "Ding Dong. Ding Dong. Somebody is at the front door"
    - service: camera.snapshot
      data_template:
        entity_id: camera.ip_cam_2
        filename: "www/snapshots/front_door_camera_{{ trigger.to_state.last_changed }}.jpg"
    - delay: '00:00:05'
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.john_s_echo
        volume_level: "{{ states('input_number.johns_echo_volume_storage') }}" 
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.bedroom_spot
        volume_level: "{{ states('input_number.bedroom_spot_volume_storage') }}" 
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.living_room_dot
        volume_level: "{{ states('input_number.living_room_dot_volume_storage') }}" 
    - service: notify.ios_iphone
      data_template:
        message: 'Someone has pressed the door bell at {{now().strftime("%H:%M %d-%m-%y")}} '
        data:
          attachment:
            content-type: jpeg
            url: "http://192.168.1.110:8123/local/snapshots/front_door_camera_{{ trigger.to_state.last_changed|urlencode }}.jpg"
          entity_id: camera.ip_cam_2
    - service: notify.ios_karens_iphone
      data_template:
        message: 'Someone has pressed the door bell at {{now().strftime("%H:%M %d-%m-%y")}} '
        data:
          attachment:
            content-type: jpeg
            url: "http://192.168.1.110:8123/local/snapshots/front_door_camera_{{ trigger.to_state.last_changed|urlencode }}.jpg"
          entity_id: camera.ip_cam_2
    - service: automation.turn_on
      entity_id: automation.set_john_echo_volume_storage, automation.set_bedroom_spot_volume_storage, automation.set_living_room_dot_volume_storage
    - service: media_player.media_play
      data_template:
        entity_id: >
           media_player.dummy
           {% if is_state('input_boolean.johns_echo_playing_boolean', 'on') %}
           ,media_player.john_s_echo
           {% endif %}
           {% if is_state('input_boolean.living_room_dot_playing_boolean', 'on') %}
           ,media_player.living_room_dot
           {% endif %}
           {% if is_state('input_boolean.bedroom_spot_playing_boolean', 'on') %}
           ,media_player.bedroom_spot
           {% endif %}
1 Like

Remove the > and make sure your indentation is correct.

Okay the playpack from Amazon Music works now very well and i have now virtual dogs :wink: they bark if the motion sensor at my door register any motion.

####
# Türbewegung bellende Hunde
####
- id: doorbird_motion_dog
  alias: Doorbird Bewegung Hund
  trigger:
    platform: event
    event_type: doorbird_haustuere_motion
  action:
     service: media_player.play_media
     data:
        entity_id: media_player.kuchenradio
        media_content_id: Hundebellen.-.2.große.Hunde.bellen.bei.Türklingel,.bellender.Hund
        media_content_type: AMAZON_MUSIC

Now i would transfer the knowledge to my alarm clock with the media content type TUNEIN but it dosn’t work…

# Wecker Wohnzimmer        
- alias: "Wecker Wohnzimmer"
  trigger:
    platform: template
value_template: "{{ states('sensor.time') == (states.input_datetime.wakeup_time_wohnzimmer.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
  condition:
  - condition: state
    entity_id: input_boolean.wakeup_enabled_wohnzimmer
    state: 'on'
  - condition: or # One of the conditions below must be true
    conditions:
      - condition: state # Will be true when the switch is 'on'
        entity_id: input_boolean.wakeup_weekend_wohnzimmer
        state: 'on'
      - condition: time # Will be true on weekdays
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
  action:
  - service: light.turn_on
    data:
      entity_id: light.wohnzimmer_sofa, light.wohnzimmer_fenster, light.wohnzimmer_links, light.wohnzimmer_rechts
      transition: 600 # Transition time in seconds
      brightness: 255
  - service: media_player.volume_set
    data:
        entity_id: media_player.radio_wohnzimmer
        volume_level: 1.0
  - service: media_player.play_media
    data:
        entity_id: media_player.radio_wohnzimmer
        media_content_id: NDR.zwei
        media_content_type: TUNEIN
  - delay: 0:30:0
  - service: switch.turn_on
    entity_id: switch.wohnzimmer_decke

… the result ist that the lights are going on but the echo don’t play the radio station over tune in

there are any one here with an idea about this problem?

I am getting an error as well. I am trying to get the file system correct.
Testing configuration at /config

Failed config
  General Errors: 
    - Component not found: alexa_media
Successful config (partial)```


alexa_media:
  accounts:
    - email: secret
    - password: secret
    - url: amazon.com

My file structure is

HASSIO\config\custom_components\alexa_media
with
init.py
const.py
media_player.py

Am I missing something?

filename has to be

underscorex2 init underscorex2 .py
Can’t write that

try it this way instead:

alexa_media:
  accounts:
    - email: [email protected]
      password: XXXXXX
      url: amazon.com

Thanks It should work on 0.88.2 correct? I understand .89 is having issues?
I tried it that way as well.

I think I’m just missing something simple, and probably not related to this plugin.

My error is: ModuleNotFoundError: No module named ‘alexapy’

I see help that says “You’re missing the dependency installation step” but I don’t see such a step in the instructions here (https://github.com/keatontaylor/alexa_media_player/wiki/Configuration#install-dependencies).

I see things like “I forgot to update docker”, which I don’t know how to do, and “pip” which is a command that doesn’t work when I ssh (using the SSH server add-on). I’m running hassio on a raspberry pi.

Any idea what I’m missing? Thanks

The following assumes you are running HassOs on your Raspberry Pi. There are several ways to install Hassio on that device. You may need to do this every time you update Home Assistant because that docker container is replaced with a new one, That is part of how Hassio works.

ssh in to hassio.

At the login prompt use the username root and any password you may have set. If it does not prompt for a password, that is OK.

I get a prompt “hassio >”. Type login. I just get a “#” prompt.

type docker exec -it homeassistant /bin/bash

I get a “bash-4.4#” prompt.

type pip3 install alexapy

After that finishes installing you can type exit a couple of times to logout.

Thanks. It’s actually Hass.io running on the pi. When I install the ssh add-in I get a “core-ssh” prompt. There’s a “hassio” command I can use, but I’m not sure what commands I would use to get the dependencies installed. I’ve been looking around and apparently Hass.io is a “locked down” version. Funny thing is this extension was working in my setup until I upgraded to 88 and the 1.1.0 version.

I’m just trying to translate the comments here into what will work for my Hass.io version. The comments seem to lean towards some other way to run Home Assistant (like HassOS?)

Am I out of luck with this latest version?

OK, what do you get if you type login at the core-ssh prompt?

What port are you using for ssh? I suspect port 2222. Try port 22 and see if you can login as the user pi.

The default password, if it has not been changed, is raspberry

const.py
__init__.py
media_player.py

(note the init py file has TWO underscores before the init and TWO underscores after the init

2 Likes

The > was from me using block code instead of preformatted text when doing this post. Those > are not in my config. FWIW I got it working by downloading the alexa_media folder as a zip file instead of copying the raw files from Github and pasting it in my alexa_media folder.