Echo Devices (Alexa) as Media Player - Testers Needed

Would anyone find value if AMP also was a bluetooth device tracker? The API allows it but I’m not sure about the side effects of having it constantly bluetooth scanning. Let me know. If we had anyone who wanted this, I’d probably need people to volunteer to test to make sure it doesn’t break something important. If you have an opinion/willing to test, let me know in GitHub.

3 Likes

First, I successfully added this to hassio and tested the weather forecast service.

I have a couple of nore-red automations but my automations.yaml is completely empty and I have never coded anything.

So this is what I want to achieve:
Alexa plays weather forecast only 1 time whenever somebody enters the kitchen for the first time. Using a xiaomi motion sensor for this.

  - data:
      entity_id: media_player.my_echo
      media_content_id: Alexa.Weather.Play
      media_content_type: sequence
    service: media_player.play_media

How do I trigger this by the motion sensor AND only 1 time per day?

Would appreciate the code. I assume I will need to add it into automations.yaml ? Restart necessary?

You could add a condition to check if the automation has already been triggered that day.

1 Like

Thanks but I don´t even know how to trigger the sensor output first (again just worked with node-red so far) so can´t figure out how to add an condition either :wink:

Would be great if somebody could pinpoint to a code example of triggering something with a sensor + such a condition.

Try something like this:

- alias: "Alexa Weather"
  trigger:
    - platform: state
      entity_id: binary_sensor.kitchen_motion
      to: 'on'
  condition:
    - condition: template
      value_template: >-
        {% set today = as_timestamp(now()) | timestamp_custom("%w", True) | int %}
        {% set lastTriggered = as_timestamp(state_attr("automation.alexa_weather", "last_triggered")) | timestamp_custom("%w", True) | int %}         

        {{ True if today != lastTriggered else False }}
  action:
    - service: media_player.play_media
      data:
        entity_id: media_player.kitch_echo
        media_content_id: Alexa.Weather.Play
        media_content_type: sequence

Or you use a input_boolean as a condition which is reset a midnight:

input_boolean:
  motion_kitchen_triggered_today:
    name: Triggered today
    initial: off

- alias: "Alexa Weather"
  trigger:
    - platform: state
      entity_id: binary_sensor.kitchen_motion
      to: 'on'
  condition:
    - condition: state
      entity_id: input_boolean.motion_kitchen_triggered_today
      state: 'off'
  action:
    - service: media_player.play_media
      data:
        entity_id: media_player.kitch_echo
        media_content_id: Alexa.Weather.Play
        media_content_type: sequence
    - service: input_boolean.turn_on
      entity_id: input_boolean.motion_kitchen_triggered_today

- alias: "Alexa Weather - Reset"
  trigger:
    - platform: time   
      at: "00:00:00"
  action:
    - service: input_boolean.turn_off
      entity_id: input_boolean.motion_kitchen_triggered_today

Hi all,
i Have a vobot device https://getvobot.com/clock
It has alexa and i installed on Home assistant the Play media component and it discover Vobot.

I’d l’ike to use the buttons on vobot for trigger event in home asssitant.
Every switch or state exposed by the component don’t catch any event.
do you know how i can do?

I managed to add manually via the automation editor a simple “if motion, than play weather”. It works also reliably every time somebody enters the kitchen… :smiley:

The boolean is a big issue. I can test both the weather and reset automation successfully but I can´t get it to triggered by motion.

Does this part go into the automations.yaml or config?

input_boolean:
  motion_kitchen_triggered_today:
    name: Triggered today
    initial: off

Getting following error messages in log depending on which of the two actions I trigger in the automation admin while I have it in the configuration.yaml:

2019-11-08 22:39:44 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.alexa_weather_reset. Service not found for call_service at pos 1: Unable to find service input_boolean/turn_off

2019-11-08 22:39:44 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.alexa_weather_reset. Service not found for call_service at pos 1: Unable to find service input_boolean/turn_off

Edit: I btw also don´t see any card in the “Overview” regarding automations. Just see them in the configuration->automation menu.

The input_boolean belongs in the normal config.

Have it in normal config and getting above error messages in log :frowning:

Were you able to resolve this? I seem to have the same problem. How can I tell which version of alexapy I am running if I’m running latest Alexa Media Player integration (version 2.3.4)?

If that would potentially allow in house, room based device tracking by tracking which Alexa device a Bluetooth device is nearest to, that would be great and I’d definitely find it useful.

@alandtse could it be that the status reset (form amazon) in the night (echo device change to idle or standby) now not take place? I use the Alexa media Player for automation in combination with motion sensors to play radio with tunein if anyone come in the rooms in the past i must start at the morning with the following

- id: motion-sensor-kueche-radio-on-idle
  alias: Bewegungssensor Küche Radio an
  trigger:
    platform: state
    entity_id: binary_sensor.aeotec_zw100_kueche_sensor
    from: "off"
    to: "on"
  condition:
   condition: and
   conditions:
    - condition: time
      after: '06:30:00'
      before: '21:00:00'
    - condition: or
      conditions:
      - condition: state
        entity_id: media_player.radio_kuche
        state: 'standby'
      - condition: state
        entity_id: media_player.radio_kuche
        state: 'idle'
  action:
    - service: media_player.volume_set
      data: 
        entity_id: media_player.radio_kuche
        volume_level: 0.3
    - service: media_player.play_media
      data:
        entity_id: media_player.radio_kuche
        media_content_id: ndr zwei
        media_content_type: TUNEIN
    - service: media_player.media_play
      entity_id: media_player.radio_kuche

after this i only use the following automation, because if i use the first automation it changes the volume and reload the radiostation on every motion with a short breake. and on the otherside if i would play in de between a other radiostation or a playlist i dont would rechange this to my standart radiostation

#############################################################
# Küche Radio an bei Bewegung wenn pause
#############################################################
- id: motion-sensor-kueche-radio-on-paused
  alias: Bewegungssensor Küche Radio an wenn Pause
  trigger:
    platform: state
    entity_id: binary_sensor.aeotec_zw100_kueche_sensor
    from: "off"
    to: "on"
  condition:
   condition: and
   conditions:
    - condition: time
      after: '06:30:00'
      before: '21:00:00'
    - condition: or
      conditions:
      - condition: state
        entity_id: media_player.radio_kuche
        state: 'paused'
  action:
    - service: media_player.media_play
      entity_id: media_player.radio_kuche

now i see in Homeassistent the following state of the device at the morning

volume_level: 0.3
is_volume_muted: false
media_content_type: music
media_duration: 0
media_position: 5268
media_position_updated_at: '2019-11-09T20:48:23.618688+00:00'
media_title: Freya Ridings - Castles
media_artist: NDR 2
media_album_name: Alle aktuellen Hits und dazu der Sound der 80er
source_list: []
shuffle: false
available: true
last_called: false
friendly_name: Radio Küche
entity_picture: 'https://cdn-profiles.tunein.com/s228737/images/logoq.png?t=154228'
supported_features: 56253

in the mediaplayer lovelace card of mini mediaplayer i see the radiostation picture but i can’t start with play. i only can play if i reload the station.

artwork: cover
entity: media_player.radio_kuche
hide:
  volume: false
shortcuts:
  buttons:
    - data:
        entity_id: media_player.radio_kuche
        media_content_id: ndr zwei
        media_content_type: TUNEIN
      id: media_player.play_media
      name: NDR 2
      type: service
    - data:
        entity_id: media_player.radio_kuche
        media_content_id: ndr info
        media_content_type: TUNEIN
      id: media_player.play_media
      name: NDR Info
      type: service
    - data:
        entity_id: media_player.radio_kuche
        media_content_id: deutschlandfunk
        media_content_type: TUNEIN
      id: media_player.play_media
      name: Deutschlandfunk
      type: service
    - data:
        entity_id: media_player.radio_kuche
        media_content_id: absolute relax
        media_content_type: TUNEIN
      id: media_player.play_media
      name: Absolute Relax
      type: service
    - data:
        entity_id: media_player.radio_kuche
        media_content_id: sunshine live
        media_content_type: TUNEIN
      id: media_player.play_media
      name: Sunshine live
      type: service
    - data:
        entity_id: media_player.radio_kuche
        media_content_id: spiele meine playlist katja
        media_content_type: AMAZON_MUSIC
      id: media_player.play_media
      name: Katja
      type: service
    - data:
        entity_id: media_player.radio_kuche
        media_content_id: spiele meine playlist Daniel
        media_content_type: AMAZON_MUSIC
      id: media_player.play_media
      name: Daniel
      type: service
    - data:
        entity_id: media_player.radio_kuche
        media_content_id: spiele meine playlist Finley
        media_content_type: AMAZON_MUSIC
      id: media_player.play_media
      name: Finley
      type: service
    - data:
        entity_id: media_player.radio_kuche
        media_content_id: spiele meine playlist chillout
        media_content_type: AMAZON_MUSIC
      id: media_player.play_media
      name: Chillout
      type: service
  columns: 3
source: icon
type: 'custom:mini-media-player'

In addition i use following automation to stop automation for 3h if i mute the echo device

#############################################################
# Küche Radio aus und deaktivierung wenn Stumm an
#############################################################
- id: kueche-radio-deactivate-mute-true
  alias: Küche Radio deaktivieren wenn stumm
  trigger:
    platform: state
    entity_id: sensor.media_player_mute_status_radio_kueche
    from: 'False'
    to: 'True'
  action:
    - service: media_player.media_pause
      entity_id: media_player.radio_kuche
    - service: switch.turn_on
      entity_id: switch.radio_kuche_do_not_disturb_switch
    - service: automation.turn_off
      entity_id: automation.bewegungssensor_kuche_radio_an
    - service: automation.turn_off
      entity_id: automation.bewegungssensor_kuche_radio_an_wenn_pause
    - delay: 3:00:00
    - service: automation.turn_on
      entity_id: automation.bewegungssensor_kuche_radio_an
    - service: automation.turn_on
      entity_id: automation.bewegungssensor_kuche_radio_an_wenn_pause

if i unmute the echo device the following automation restarts the play on motion automation.

#############################################################
# Küche Radio aktivierung wenn Stumm aus
#############################################################
- id: kueche-radio-deactivate-mute-false
  alias: Küche Radio aktivieren wenn nicht stumm
  trigger:
    platform: state
    entity_id: sensor.media_player_mute_status_radio_kueche
    from: 'True'
    to: 'False'
  action:
    - service: switch.turn_off
      entity_id: switch.radio_kuche_do_not_disturb_switch
    - service: automation.turn_on
      entity_id: automation.bewegungssensor_kuche_radio_an
    - service: automation.turn_on
      entity_id: automation.bewegungssensor_kuche_radio_an_wenn_pause
1 Like

I have things setup however when I try and send Alexa a TTS command Alexa says that text to speech can only be called by the notify dot alexa media service. Is there something I missed in the setup?

I had a thought, not sure if this is possible. I have a Fire TV Cube on my bedroom TV. Is there any way to send commands to it to control the TV? I’m thinking somewhat similar to the “routines” command but instead just sends commands as you would speak them (like “tune to ESPN”). Is this possible?

1 Like

I have an unusual problem - I’m trying to send ‘push’ notifications to my mobile phone (media_player.matthew_s_alexa_apps) as part of an automation. My partner also has an alexa_media integration and this includes ‘media_player.matthew_s_alexa_apps’ so she is receiving notifications as well! Also, we get two notifications each.
I’ve uninstalled, removed directories, reinstalled through HACS and added Integrations with no luck so far.
Is there any way to separate our accounts? I thought of removing her but I also need to send her notifications as well.

Hi, that’s why alexa is sending notifications to the account and not to a single device. Alexa notifications are raised at any connected device to a certain account.
It’s better to use pushover in order to send detailed notifications to named devices.

Hi,
tonight I encountered a problem with TTS. Before actually saying what Alexa is supposed to say, she now starts every TTS output with “Sprich mir nach” (German for “repeat after me”). This makes TTS essentially useless. Have others encountered the same problem? I’m on the latest version of the custom component.

Hi all, I noticed a strange thing, sending a TTS text to my alexa media player it says something with the name “Simon” and then the message I wrote, maybe an easter egg or an hack of someone?

Yup, same here. Alexa uses the “Simon says” phrase. Something changed on the Amazon side, I guess?
Also, the Alexa alarm control panel is unavailable in HA. Too bad, coz I just spend a few hours synchronizing it to my alarm system last week.