alandtse / alexa_media_player

This is a custom component to allow control of Amazon Alexa devices in Home Assistant using the unofficial Alexa API.
Apache License 2.0
1.49k stars 286 forks source link

All is configured ok yet no TTS/Announce works #292

Closed silviudc closed 5 years ago

silviudc commented 5 years ago

Describe the bug

I have installed the custom component from the HASSIO community tab and everything seems to be configured correctly yet none of my echo dots ever say anything

To Reproduce

Tested with: Service notify.alexa_media

Service Data (JSON, optional)

{
"message":"testing",
"data":{"type":"announce", "method":"all"},
"target":"Kitchen Dot"
}

And this is being logged:

2019-08-18 18:33:13 DEBUG (SyncWorker_0) [custom_components.alexa_media.notify] Message: testing, kwargs: {'target': ['Kitchen Dot'], 'data': {'type': 'announce', 'method': 'all'}}
2019-08-18 18:33:13 DEBUG (SyncWorker_0) [custom_components.alexa_media.notify] Testing item: Kitchen Dot against (<Entity Kitchen Dot: standby>, Kitchen Dot, G************539, media_player.kitchen_dot)
2019-08-18 18:33:13 DEBUG (SyncWorker_0) [custom_components.alexa_media.notify] Converting: Kitchen Dot to (entities): <Entity Kitchen Dot: standby>
2019-08-18 18:33:13 DEBUG (SyncWorker_0) [custom_components.alexa_media.notify] Testing item: Kitchen Dot against (<Entity Home Cinema Dot: standby>, Home Cinema Dot, G************0S8, media_player.home_cinema_dot)
2019-08-18 18:33:13 DEBUG (SyncWorker_0) [custom_components.alexa_media.notify] Testing item: <Entity Kitchen Dot: standby> against (<Entity Kitchen Dot: standby>, Kitchen Dot, G************539, media_player.kitchen_dot)
2019-08-18 18:33:13 DEBUG (SyncWorker_0) [custom_components.alexa_media.notify] Converting: <Entity Kitchen Dot: standby> to (serialnumbers): G090LF1174621539
2019-08-18 18:33:13 DEBUG (SyncWorker_0) [custom_components.alexa_media.notify] Testing item: <Entity Kitchen Dot: standby> against (<Entity Home Cinema Dot: standby>, Home Cinema Dot, G************0S8, media_player.home_cinema_dot)
2019-08-18 18:33:13 DEBUG (SyncWorker_0) [custom_components.alexa_media.notify] Announce targets: ['G************539'] entities: [<Entity Kitchen Dot: standby>]
2019-08-18 18:33:13 DEBUG (SyncWorker_0) [custom_components.alexa_media.notify] s*****1@eircom.net: Announce by <Entity Kitchen Dot: standby> to targets: ['G************539']: testing
2019-08-18 18:33:13 DEBUG (SyncWorker_0) [alexapy.alexaapi] Running sequence: AlexaAnnouncement data: {"behaviorId": "PREVIEW", "sequenceJson": "{\"@type\": \"com.amazon.alexa.behaviors.model.Sequence\", \"startNode\": {\"@type\": \"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\", \"type\": \"AlexaAnnouncement\", \"operationPayload\": {\"deviceType\": \"A3S5BH2HU6VAYF\", \"deviceSerialNumber\": \"G090LFxxxxxxxxx\", \"locale\": \"en-gb\", \"customerId\": \"xxxxxxxx\", \"expireAfter\": \"PT5S\", \"content\": [{\"locale\": \"en-gb\", \"display\": {\"title\": \"Home Assistant\", \"body\": \"testing\"}, \"speak\": {\"type\": \"text\", \"value\": \"testing\"}}], \"target\": {\"customerId\": \"xxxxxxxxxxxxx\", \"devices\": [{\"deviceSerialNumber\": \"G090LFxxxxxxxxxx\", \"deviceTypeId\": \"A3S5BH2HU6VAYF\"}]}}}}", "status": "ENABLED"}`

This is the configuration.yaml entry: `notify:

alexa_media: accounts:

Expected behavior Announcement coming from the Echo dot

Screenshots If applicable, add screenshots to help explain your problem.

System details

Additional context Add any other context about the problem here.

alandtse commented 5 years ago

Does TTS work? Also, if you create a routine in the Alexa app to use announce does that work?

silviudc commented 5 years ago

TTS from HA? Nothing ever gets played when triggered from HA. Yes a routine from the Alexa app works just fine, so does the announce function.

Here is me running notifiy.alexa_media service with both type: tts and type: announce

2019-08-18 23:58:26 DEBUG (SyncWorker_8) [custom_components.alexa_media.notify] Message: testing, kwargs: {'target': ['Kitchen Dot'], 'data': {'type': 'announce'}}
2019-08-18 23:58:26 DEBUG (SyncWorker_8) [custom_components.alexa_media.notify] Testing item: Kitchen Dot against (<Entity Kitchen Dot: paused>, Kitchen Dot, G************539, media_player.xxxxxxx)
2019-08-18 23:58:26 DEBUG (SyncWorker_8) [custom_components.alexa_media.notify] Converting: Kitchen Dot to (entities): <Entity Kitchen Dot: paused>
2019-08-18 23:58:26 DEBUG (SyncWorker_8) [custom_components.alexa_media.notify] Testing item: Kitchen Dot against (<Entity Home Cinema Dot: standby>, Home Cinema Dot, G************0S8, media_player.xxxxxxx)
2019-08-18 23:58:26 DEBUG (SyncWorker_8) [custom_components.alexa_media.notify] Testing item: <Entity Kitchen Dot: paused> against (<Entity Kitchen Dot: paused>, Kitchen Dot, G************539, media_player.xxxxxxx)
2019-08-18 23:58:26 DEBUG (SyncWorker_8) [custom_components.alexa_media.notify] Converting: <Entity Kitchen Dot: paused> to (serialnumbers): xxxxxxx
2019-08-18 23:58:26 DEBUG (SyncWorker_8) [custom_components.alexa_media.notify] Testing item: <Entity Kitchen Dot: paused> against (<Entity Home Cinema Dot: standby>, Home Cinema Dot, G************0S8, media_player.xxxxxxx)
2019-08-18 23:58:26 DEBUG (SyncWorker_8) [custom_components.alexa_media.notify] Announce targets: ['G************539'] entities: [<Entity Kitchen Dot: paused>]
2019-08-18 23:58:26 DEBUG (SyncWorker_8) [custom_components.alexa_media.notify] s*****1@eircom.net: Announce by <Entity Kitchen Dot: paused> to targets: ['G************539']: testing
2019-08-18 23:58:26 DEBUG (SyncWorker_8) [alexapy.alexaapi] Running sequence: AlexaAnnouncement data: {"behaviorId": "PREVIEW", "sequenceJson": "{\"@type\": \"com.amazon.alexa.behaviors.model.Sequence\", \"startNode\": {\"@type\": \"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\", \"type\": \"AlexaAnnouncement\", \"operationPayload\": {\"deviceType\": \"A3S5BH2HU6VAYF\", \"deviceSerialNumber\": \"xxxxxxx\", \"locale\": \"en-gb\", \"customerId\": \"xxxxxxx\", \"expireAfter\": \"PT5S\", \"content\": [{\"locale\": \"en-gb\", \"display\": {\"title\": \"Home Assistant\", \"body\": \"testing\"}, \"speak\": {\"type\": \"text\", \"value\": \"testing\"}}], \"target\": {\"customerId\": \"xxxxxxx\", \"devices\": [{\"deviceSerialNumber\": \"xxxxxxx\", \"deviceTypeId\": \"A3S5BH2HU6VAYF\"}]}}}}", "status": "ENABLED"}
2019-08-18 23:58:47 DEBUG (SyncWorker_3) [custom_components.alexa_media.notify] Message: testing, kwargs: {'target': ['Kitchen Dot'], 'data': {'type': 'tts'}}
2019-08-18 23:58:47 DEBUG (SyncWorker_3) [custom_components.alexa_media.notify] Testing item: Kitchen Dot against (<Entity Kitchen Dot: paused>, Kitchen Dot, G************539, media_player.kitchen_dot)
2019-08-18 23:58:47 DEBUG (SyncWorker_3) [custom_components.alexa_media.notify] Converting: Kitchen Dot to (entities): <Entity Kitchen Dot: paused>
2019-08-18 23:58:47 DEBUG (SyncWorker_3) [custom_components.alexa_media.notify] Testing item: Kitchen Dot against (<Entity Home Cinema Dot: standby>, Home Cinema Dot, G************0S8, media_player.home_cinema)
2019-08-18 23:58:47 DEBUG (SyncWorker_3) [custom_components.alexa_media.notify] Testing item: <Entity Kitchen Dot: paused> against (<Entity Kitchen Dot: paused>, Kitchen Dot, G************539, media_player.xxxxxxx)
2019-08-18 23:58:47 DEBUG (SyncWorker_3) [custom_components.alexa_media.notify] Converting: <Entity Kitchen Dot: paused> to (entities): <Entity Kitchen Dot: paused>
2019-08-18 23:58:47 DEBUG (SyncWorker_3) [custom_components.alexa_media.notify] Testing item: <Entity Kitchen Dot: paused> against (<Entity Home Cinema Dot: standby>, Home Cinema Dot, G************0S8, media_player.xxxxxxx)
2019-08-18 23:58:47 DEBUG (SyncWorker_3) [custom_components.alexa_media.notify] TTS entities: [<Entity Kitchen Dot: paused>]
2019-08-18 23:58:47 DEBUG (SyncWorker_3) [custom_components.alexa_media.notify] TTS by <Entity Kitchen Dot: paused> : testing
2019-08-18 23:58:47 DEBUG (SyncWorker_3) [alexapy.alexaapi] Running sequence: Alexa.Speak data: {"behaviorId": "PREVIEW", "sequenceJson": "{\"@type\": \"com.amazon.alexa.behaviors.model.Sequence\", \"startNode\": {\"@type\": \"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\", \"type\": \"Alexa.Speak\", \"operationPayload\": {\"deviceType\": \"A3S5BH2HU6VAYF\", \"deviceSerialNumber\": \"xxxxxxx\", \"locale\": \"en-gb\", \"customerId\": \"xxxxxxx\", \"textToSpeak\": \"testing\"}}}", "status": "ENABLED"}`
krissen commented 5 years ago

I don’t know if it matters, but I notice you have {'target': ['Kitchen Dot'], 'data': {'type': 'tts'}} without providing method. If I remember correctly, I had to provide method: speak for it to work. So

{
  "message":"testing",
  "data":{"type":"tts", "method":"speak"},
  "target":"Kitchen Dot"
}

Also, I noticed I had some duplicates of targets, so to say. But only one of them worked. Ie., though I have six or so notify.alexa_media_DEVICES listed, half of them are duplicates, and only half of them work — but there is one notify.alexa_media_DEVICE working for each Alexa device I have. Just had to cycle through them to see which was working, for tts, and which was not. 🤷‍♂️

alandtse commented 5 years ago

For the routine in the Alexa App, can you please pull the nodestoExecute data for the working announce?

Are any of the devices shared accounts?

silviudc commented 5 years ago

For the routine in the Alexa App, can you please pull the nodestoExecute data for the working announce?

Are any of the devices shared accounts?

Will try this and report back after I'm back from work later today.

silviudc commented 5 years ago

No, all devices are on the one account. See below for the sequence discovery output from: https://alexa.amazon.co.uk/api/behaviors/automations

[{"@type":"com.amazon.alexa.behaviors.model.Automation","automationId":"amzn1.alexa.behaviors.preconfigured:alarm_dismissed_preconfigured_routine","name":null,"triggers":[{"payload":{"customerId":"xxxxxxx"},"id":null,"type":"Alexa.Trigger.Alarms.NotificationStopped","timeLapse":null}],"sequence":{"@type":"com.amazon.alexa.behaviors.model.Sequence","sequenceId":"amzn1.alexa.sequence.82382a5d-0e89-4c88-beae-ebeae5765f43","startNode":{"@type":"com.amazon.alexa.behaviors.model.SerialNode","name":null,"nodesToExecute":[{"@type":"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode","type":"Alexa.CannedTts.Speak","skillId":null,"operationPayload":{"deviceType":"ALEXA_CURRENT_DEVICE_TYPE","deviceSerialNumber":"ALEXA_CURRENT_DSN","customerId":"xxxxxxx","locale":"ALEXA_CURRENT_LOCALE","cannedTtsStringId":"alexa.cannedtts.speak.curatedtts-category-goodmorning/alexa.cannedtts.speak.curatedtts-random"},"name":null},{"@type":"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode","type":"Alexa.Weather.Play","skillId":null,"operationPayload":{"deviceType":"ALEXA_CURRENT_DEVICE_TYPE","deviceSerialNumber":"ALEXA_CURRENT_DSN","customerId":"xxxxxxx","locale":"ALEXA_CURRENT_LOCALE"},"name":null}]}},"owner":null,"clientAlias":null,"condition":null,"status":"DISABLED","creationTimeEpochMillis":1564093068820,"lastUpdatedTimeEpochMillis":1564093068820},{"@type":"com.amazon.alexa.behaviors.model.Automation","automationId":"amzn1.alexa.behaviors.preconfigured:good_night_custom_utt_trigger","name":null,"triggers":[{"payload":{"customerId":"xxxxxxx","utterance":"good night","locale":"en","marketplaceId":"A1F83G8C2ARO7P"},"id":null,"type":"CustomUtterance","timeLapse":null}],"sequence":{"@type":"com.amazon.alexa.behaviors.model.Sequence","sequenceId":"amzn1.alexa.sequence.94220db6-dc6b-4897-b3d8-5c2a12b9916e","startNode":{"@type":"com.amazon.alexa.behaviors.model.SerialNode","name":null,"nodesToExecute":[{"@type":"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode","type":"Alexa.CannedTts.Speak","skillId":null,"operationPayload":{"deviceType":"ALEXA_CURRENT_DEVICE_TYPE","deviceSerialNumber":"ALEXA_CURRENT_DSN","customerId":"xxxxxxx","locale":"ALEXA_CURRENT_LOCALE","cannedTtsStringId":"alexa.cannedtts.speak.curatedtts-category-goodnight/alexa.cannedtts.speak.curatedtts-random"},"name":null}]}},"owner":null,"clientAlias":null,"condition":null,"status":"DISABLED","creationTimeEpochMillis":1539597508859,"lastUpdatedTimeEpochMillis":1564093068811},{"@type":"com.amazon.alexa.behaviors.model.Automation","automationId":"amzn1.alexa.behaviors.preconfigured:start_my_day_custom_utt_trigger","name":null,"triggers":[{"payload":{"customerId":"xxxxxxx","utterance":"start my day","locale":"en","marketplaceId":"A1F83G8C2ARO7P"},"id":null,"type":"CustomUtterance","timeLapse":null}],"sequence":{"@type":"com.amazon.alexa.behaviors.model.Sequence","sequenceId":"amzn1.alexa.sequence.9fec76b1-9472-412d-a534-e981bb467d00","startNode":{"@type":"com.amazon.alexa.behaviors.model.SerialNode","name":null,"nodesToExecute":[{"@type":"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode","type":"Alexa.GoodMorning.Play","skillId":null,"operationPayload":{"deviceType":"ALEXA_CURRENT_DEVICE_TYPE","deviceSerialNumber":"ALEXA_CURRENT_DSN","customerId":"xxxxxxx","locale":"ALEXA_CURRENT_LOCALE"},"name":null},{"@type":"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode","type":"Alexa.Weather.Play","skillId":null,"operationPayload":{"deviceType":"ALEXA_CURRENT_DEVICE_TYPE","deviceSerialNumber":"ALEXA_CURRENT_DSN","customerId":"xxxxxxx","locale":"ALEXA_CURRENT_LOCALE"},"name":null},{"@type":"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode","type":"Alexa.Traffic.Play","skillId":null,"operationPayload":{"deviceType":"ALEXA_CURRENT_DEVICE_TYPE","deviceSerialNumber":"ALEXA_CURRENT_DSN","customerId":"xxxxxxx","locale":"ALEXA_CURRENT_LOCALE"},"name":null},{"@type":"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode","type":"Alexa.FlashBriefing.Play","skillId":null,"operationPayload":{"deviceType":"ALEXA_CURRENT_DEVICE_TYPE","deviceSerialNumber":"ALEXA_CURRENT_DSN","customerId":"xxxxxxx","locale":"ALEXA_CURRENT_LOCALE"},"name":null}]}},"owner":null,"clientAlias":null,"condition":null,"status":"DISABLED","creationTimeEpochMillis":1512864433846,"lastUpdatedTimeEpochMillis":1564093068816},{"@type":"com.amazon.alexa.behaviors.model.Automation","automationId":"amzn1.alexa.automation.de3e01b8-cace-48b2-9646-92cc2c59fb95","name":null,"triggers":[{"payload":{"customerId":"xxxxxxx","value":"DETECTED","target":"6f4dc940-518a-4ad1-ba13-b3ec72cf6a4f"},"id":"amzn1.alexa.trigger.60c103f6-caa0-4d59-939b-4ac8ed800751","type":"motionSensorDetectionStateTrigger","timeLapse":null}],"sequence":{"@type":"com.amazon.alexa.behaviors.model.Sequence","sequenceId":"amzn1.alexa.sequence.c4dbc929-3c77-4d24-a244-d27b8709d621","startNode":{"@type":"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode","type":"Alexa.Speak","skillId":"amzn1.ask.1p.saysomething","operationPayload":{"customerId":"xxxxxxx","deviceType":"A3S5BH2HU6VAYF","deviceSerialNumber":"xxxxxxx","textToSpeak":"What up","locale":"en-IE"},"name":null}},"owner":null,"clientAlias":null,"condition":null,"status":"DISABLED","creationTimeEpochMillis":1566168856696,"lastUpdatedTimeEpochMillis":1566237693919}]

silviudc commented 5 years ago

I don’t know if it matters, but I notice you have {'target': ['Kitchen Dot'], 'data': {'type': 'tts'}} without providing method. If I remember correctly, I had to provide method: speak for it to work. So

{
  "message":"testing",
  "data":{"type":"tts", "method":"speak"},
  "target":"Kitchen Dot"
}

Also, I noticed I had some duplicates of targets, so to say. But only one of them worked. Ie., though I have six or so notify.alexa_media_DEVICES listed, half of them are duplicates, and only half of them work — but there is one notify.alexa_media_DEVICE working for each Alexa device I have. Just had to cycle through them to see which was working, for tts, and which was not. 🤷‍♂️

So I have these three services that I have tried in Dev Tools using your JSON above and no luck with any combination.

notify.alexa_media notify.alexa_media_kitchen_dot notify.alexa_home_cinema_dot

Should the test service be called on notify.alexa_media or on the others?

krissen commented 5 years ago

Should the test service be called on notify.alexa_media or on the others?

(Yes, on notify.alexa_media. Oh well; was worth a shot.)

silviudc commented 5 years ago

I have it working now, not sure if it made any difference but I have yet again uninstalled the custom component, hooked it up again and I was able to get both an announce and a TTS message out. Also it only works on:

notify.alexa_media_kitchen_dot notify.alexa_media_home_cinema_dot

Not on simply: notify.alexa_media, so how to broadcast to all?

krissen commented 5 years ago

Not on simply: notify.alexa_media, so how to broadcast to all?

If it works on the others, it should work on notify.alexa_media too, as long as you provide targets. In your case, I think it should be something like

{ "message": "Test", "data": { "type": "announce", "method": "speak" }, "target": ["Kitchen Dot", "Home Cinema Dot"] }
silviudc commented 5 years ago

Ok that did it. I do wonder why this script works fine:

alexa_tts_example:
  alias: Alexa TTS Test 1
  sequence:
  - service: notify.alexa_media_kitchen_dot
    data:
      data:
        type: tts
        method: speak
      target: 
        - media_player.kitchen_dot
      message: "This is an example of text-to-speech"

But the multiple targets to notify.alexa_media does not

alexa_tts_example1:
  alias: Alexa TTS Test 2
  sequence:
  - service: notify.alexa_media
    data:
      data:
        type: announce
        method: speak
      target: 
        - media_player.kitchen_dot
        - media_player.home_cinema_dot
      message: "This is an example of text-to-speech"

Bad syntax?

krissen commented 5 years ago

Have you tried changing your three target lines into target: [”Kitchen dot”, ”Home Cinema dot”] in the notify.alexa_media automation?

silviudc commented 5 years ago

Have you tried changing your three target lines into target: [”Kitchen dot”, ”Home Cinema dot”] in the notify.alexa_media automation?

Awesome, that did it, thanks a lot guys!

Herb-IV commented 2 years ago

is it possible just to change the type: tts to announce if its a group?? Example alexa_tts_example: alias: Alexa TTS Test 1 sequence: