Echo Devices (Alexa) as Media Player - Testers Needed

I’ve had this working now for a couple months but it broke when I updated HA .89. I changed the alexa folder in custom_components to alexa_media, updated the media_player.py file to 1.1.0 and changed my config to

> alexa_media:
>   accounts:
>     - email: !secret alexa_email
>       password: !secret alexa_password
>       url: amazon.com  

When I do a configuration check it says Component not found: alexa_media. What am I missing here?

Did you deleted the old mediaplayer configuration from your configuration.yaml?

Yes I did. I replaced that with the new alexa_media one.

did you restart HA before doing the new configuration.yaml entry so it could pick up the new folder structure?

I have done that too. Running this on a VM and even restarted the host. One thing I haven’t done is restarted HA with the alexa_media added to my config because of what the config check said.

That’s a great thing now i can play and pause the amazon echo playback over automations.yaml. Another question, is it possible or planed that its feasible that we can choose amazon music playlists or tunin radio stations? Thats would be great because than we can use it for alarm clocks automations or if no playlist is choosen we can with automations start playback if a person enter the room or can start indoor alarm sounds if sensors activatet (like buglar alarm).
In pricible it shut be possible with shell scrips to do this (-> https://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html) but my knowlege in programming is not realy good an im where glad if anyone with this knowledge could make this possible in home assistant.

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.