Output speech to Alexa based on state

I’d like to to this also, I’m guessing the ‘media_player.alexa_tts’ is a some assistant component? Do you have a link?

Here’s my hokey morning alarm. You may find this useful:

- alias: 'Good Morning Richard'
  initial_state: true
  trigger:
  - at: '07:00:00'
    platform: time
  condition: []
  action:
# Light on dim
  - service: light.turn_on
    data:
      brightness: '80'
      entity_id: light.bedroom
# Moring greeting
  - service: media_player.volume_set
    data:
      entity_id: media_player.406_bedroom_echo_dot
      volume_level: 0.6
  - delay: '00:02'
  - service: media_player.play_media
    data:
      entity_id: media_player.406_bedroom_echo_dot
      media_content_id: Alexa.GoodMorning.Play
      media_content_type: sequence
# Weather report
  - delay: '00:02'
  - service: media_player.play_media
    data:
      entity_id: media_player.406_bedroom_echo_dot
      media_content_id: Alexa.Weather.Play
      media_content_type: sequence
# Coffee yet?
  - delay: '00:05'
  - service: notify.alexa_media
    data:
      target: media_player.406_bedroom_echo_dot
      message: Do you have your coffee yet?
      data:
        type: tts
2 Likes

Or this one to announce and take a picture when the tool shed door is opened:

- alias: 'Tool Shed Door Open'
  initial_state: true
  trigger:
  - entity_id: binary_sensor.tool_shed_opened
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - service: notify.alexa_media
    data:
      target: media_player.406_kitchen_echo
      message: The tool shed door has been opened
      data:
        type: tts
  - data:
      entity_id: camera.406_north
      filename: /config/camera_snapshots/opened {{ entity_id.entity_id }}_{{ now().strftime('%Y-%m-%d
        %H.%M.%S') }}.jpg
    service: camera.snapshot

I managed it by installing the Alexa Media Player add on and then refreshing Node Red.

After that I was apple to call media_player.alexa_tts via a service call as @cyberumb15 illustrated above.

Turns out it was pretty easy!

Thanks, this is just the sort of thing i’m trying to implement!

Thanks very much for the link, I’ll have to try the media player addon.

I did try and get an Alexa remote working directly in NodeRED with this node:

but I could never get it to Authenticate my amazon account, but it is an early version

EDIT After installing the components and python module alexapy it seems to be working, very nice.

Right now I’ve got simple reminder that notifies me when homeassistant has booted up after tinkering with the config, you can use

  trigger:
    platform: homeassistant
    event: start

as the trigger, once I get some more creative uses I’ll have to add them :slight_smile:

[{"id":"78d5451.c65f8bc","type":"switch","z":"40ebc6d9.fa1168","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":200,"wires":[["9edcaab4.b8e6f8","447adc98.23e524","d6941896.b81638","7c6bba4c.ef8d64","79edea42.8a4884","b72d8775.355fa8","201c2f18.3eafb","c7e1b4fe.d48da8"],[]]},{"id":"9edcaab4.b8e6f8","type":"api-call-service","z":"40ebc6d9.fa1168","name":"ON - TV Power","server":"62d7bb2f.196044","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\" switch.sonoff_power\"}","mergecontext":"","x":780,"y":220,"wires":[[]],"outputLabels":["on"]},{"id":"447adc98.23e524","type":"api-call-service","z":"40ebc6d9.fa1168","name":"ON - Sound Bar","server":"62d7bb2f.196044","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\" switch.sound_bar\"}","mergecontext":"","x":780,"y":260,"wires":[[]],"outputLabels":["on"]},{"id":"d6941896.b81638","type":"api-call-service","z":"40ebc6d9.fa1168","name":"TV Blind Down","server":"62d7bb2f.196044","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\" switch.blind_1_down_up\"}","mergecontext":"","x":780,"y":300,"wires":[[]],"outputLabels":["on"]},{"id":"201c2f18.3eafb","type":"api-call-service","z":"40ebc6d9.fa1168","name":"ON - Side lamp","server":"62d7bb2f.196044","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\" switch.living_room_lamp\"}","mergecontext":"","x":780,"y":140,"wires":[[]],"outputLabels":["on"]},{"id":"c7e1b4fe.d48da8","type":"api-call-service","z":"40ebc6d9.fa1168","name":"ON - Side lamp 2","server":"62d7bb2f.196044","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\" switch.living_room_side_lamp\"}","mergecontext":"","x":790,"y":100,"wires":[[]],"outputLabels":["on"]},{"id":"8fc4f623.11e1c8","type":"api-call-service","z":"40ebc6d9.fa1168","name":"alexa voice","server":"62d7bb2f.196044","service_domain":"media_player","service":"alexa_tts","data":"{\"entity_id\":\"media_player.annaka_s_echo_dot\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1050,"y":180,"wires":[[]]},{"id":"e8c928c6.370878","type":"comment","z":"40ebc6d9.fa1168","name":"Alexa turn movie time on","info":"","x":230,"y":140,"wires":[]},{"id":"7c6bba4c.ef8d64","type":"api-call-service","z":"40ebc6d9.fa1168","name":"Dinning room lamp","server":"62d7bb2f.196044","service_domain":"switch","service":"turn_off","data":"{\"entity_id\":\" switch.dinning_room\"}","mergecontext":"","x":790,"y":340,"wires":[[]],"outputLabels":["on"]},{"id":"4a1c5462.8047ac","type":"alexa-local","z":"40ebc6d9.fa1168","devicename":"movie time","inputtrigger":false,"x":190,"y":200,"wires":[["78d5451.c65f8bc"]]},{"id":"79edea42.8a4884","type":"api-call-service","z":"40ebc6d9.fa1168","name":"Computer lamp","server":"62d7bb2f.196044","service_domain":"switch","service":"turn_off","data":"{\"entity_id\":\" switch.computer_lamp\"}","mergecontext":"","x":780,"y":380,"wires":[[]],"outputLabels":["on"]},{"id":"b72d8775.355fa8","type":"function","z":"40ebc6d9.fa1168","name":"Alexa random messages","func":"msg.payload = {};\nmsg.payload.data = {};\nmsg.payload.data.entity_id = {};\nmsg.payload.data.message ={};\n\nvar myArray = [\n  \"The entertainment system has been primed, and is ready to go... Enjoy yourself, and don't forget the snacks \",\n  \"hey sunshine, go put your feet up and watch a good movie\",\n  \"Marmalade will hold the fort, you go and enjoy yourself\",\n  \"See ya soon\",\n  \"Go on then bugger off, I'll sit and mumble to myself\",\n  \"The entertainment system is all set up, go have fun\"\n];\n\nvar randomItem = myArray[Math.floor(Math.random()*myArray.length)];\n\nmsg.payload.data.entity_id = \"media_player.annaka_s_echo_dot\";\nmsg.payload.data.message = randomItem;\n\n\nreturn msg;\n","outputs":1,"noerr":0,"x":810,"y":180,"wires":[["8fc4f623.11e1c8"]]},{"id":"62d7bb2f.196044","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

Using Alexa to set up my movie room and say some randomn quotes as she does so.

I just setup my morning greeting as @Dixey posted up above, I really like it. My questions is: Is there any other routines that can be triggered like Alexa.GoodMorning.Play? I wouldn’t mind triggering some other types of notifications throughout the day. Is there a list?

media.content.id: Alexa.Weather.Play - for the local weather forecast
media.content.id: Alexa.Calendar.PlayToday - for today’s dreaded appointments if you use google calendar
media.content.id: Alexa.Calendar.PlayTomorrow - for the dreaded tomorrow appointments
media.content.id: Alexa.ImHome.Play - to have her greet you
media.content.id: Alexa.FunFact.Play - for a silly little piece of trivia
media.content.id: Alexa.Joke.Play - for a “Dad joke”
media.content.id: Alexa.FlashBriefing.Play - if you have an Alexa News Flash set up
media.content.id: Alexa.Traffic.Play - you need to set up Alexa with a home and work address for traffic reports
media.content.id: Alexa.GoodNight.Play - just to sweetly tell me good night

Perfect, thanks Dixey, I will implement some of those during this upcoming week.

and to randomly entertain the kiddos:
media.content.id: Alexa.TellStory.Play
media.content.id: Alexa.SingASong.Play

(and change the echo/dot configuration in the kiddo’s room to use English UK for a voice if you want a free British Nanny)

hi,
node red not discovery the service alexa_tts.
there are some solution?

It’s “notify” now. check out the the following link
[Echo Devices (Alexa) as Media Player - Testers Needed]

Some example with node red and Alexa? Cause I don ‘t find the service in node red also I’d i’ve added this component in home assistant

Cover

Garage%20-%20switch

This is in the data because it was cut off in the picture

{"message":"Garage Door Is Opening","data":{"type":"announce"}}
2 Likes

give this error
msg : string[73]

“Call-service API error. Error Message: extra keys not allowed @ data[‘0’]”
i don’t know why

https://pastebin.com/bAbdwbi5

Try to delete double quotations “ and retype double quote " again.

JSON

3 Likes

Just add a switch node before.
Set it to delete the msg.payload

Is this possible using node-red automatons?

I don’t see why not, but I don’t use node-red… yet. I’m considering doing so, so if you experiment and it does work, please report back. :slight_smile: