TTS in MSR?
-
Let me play around with this a bit. You can add the
notify
service to the entity (have you done this?), but I'm not sure about the rest of the parameters. Some are tricky. But I want to get something like this going in my house, so good excuse to figure it out... -
@toggledbits said in TTS in MSR?:
You can add the notify service to the entity (have you done this?)
@toggledbits No, I haven't used the notify service. I might give it a try later this week. If you (or anyone else) figure it out, please share!
-
@fanan Per this topic https://smarthome.community/topic/744/sending-a-service-request-to-home-assistant?_=1638829172919 I couldn't get Alexa tts to work in MSR, but I do have it working in openLuup with the following code that sits inside a simple plugin:
myEchoDevice = "alexa_media_".. myEchoDevice myEchoMessage = table.concat(myEchoMessage) local request_body = json.encode {message = myEchoMessage, data = {["type"] = "announce",method = "all"}} local response_body = {} local theURL = 'http://'..HomeAssistantIP..':'..HomeAssistantPort..'/api/services/notify/'..myEchoDevice r, c, h = http.request { url = theURL, method = "POST", headers = { ["Content-Type"] = "application/json", ["Authorization"] = "Bearer ".. HomeAssistantToken, ["Content-Length"] = request_body:len() }, source = ltn12.source.string(request_body), sink = ltn12.sink.table(response_body) }
The variable "myEchoDevice" is the exact name of the specific echo device (or device group) as presented in the Amazon Alexa app. I typically broadcast to all my devices via a group, intercom style, so I catch the message wherever I am in my home. The variable "HomeAssistantToken" needs to be created in HA. "myEchoMessage "is a lua table in the above code, but you could just as easily capture the message as a string, and then trim the string prior to sending it to the HTTP post request.
-
@fanan OK. So it turns out that this has (much) more to do with the way the Alexa Media Player service works than anything. You can simply use the
call_service
action on the controller's system object to call thenotify.alexa_media
service (or its variants, more on that below). If you do it through the system entity, you don't need to make exceptions in your local configuration to add the service -- you can run a service against any entity from the system entity, and if it's not supported, the (Hass) entity will either ignore it or log an error, but nobody dies, missiles do not launch, gravity still works, the sun continues to rise and set, etc.Above are two different versions of the service call that do about the same thing. I'll work backwards because that's the way I figured it out...
The green-circled "short" version of the service name requires that you specify the
target
in the service data. The service data is a structure as shown (always). Also see the docs for the component for more info about this service and its data. Thetarget
field must be specified when using this short form of the service name, and its value is an array of HomeAssistant entity IDs (not Reactor entity IDs) for the players (Dots and Echos) that will speak the phrase. Thedata
substructure must be given as shown.The red-circled variant uses a longer service name that includes the Amazon device's name. Apparently the component creates a set of aliased services, each with the device name appended to the base service name. I find this annoying, because I have over a dozen Dots/Echos, so and it creates a bunch of data pollution. But, it's there, and it's usable. When you use a "long" service name, you don't need to specify
target
in the data, but it's otherwise the same, as shown. -
@toggledbits Speaking of that, is there a way to easily compose re-usable actions, so I could just pass the arguments (message and device) and call the same function? I'll use for the very same purpose, since I have a couple of endpoints doing notifications/TTS. Thanks!
-
@toggledbits That's great news! My only problem is that my Hass entity don't have any actions... :
I don't know how you activated the x_hass_system.call_service?Do I have to change anything in my reactor.yaml?
- id: hass enabled: true implementation: HassController name: Home Assistant config: source: 'wss://f_______' access_token: "eyJ0eXAi_______________________________________________________________________________________________________________________________2-nLoI369-iYcJf9z_3sviSiWA" # # ignore_cert - If true, suppresses certificate validation when using wss:// (Websocket # with SSL/TLS) and thus allows a self-signed certificate to be used on # the Hass system. #ignore_cert: false # # dump_all_states - This is for troubleshooting. Do not enable unless asked. #dump_all_states: false log_events: false
-
toggledbitsreplied to Fanan on Dec 7, 2021, 1:02 PM last edited by toggledbits Dec 7, 2021, 8:06 AM
@fanan That's not the system entity. It's probably named "Home Assistant" based on your configuration, and you can also filter by the
sys_system
capability. -
@toggledbits Ahh..! I see it now. Thanks! I'm struggeling with the indentation, but I guess it will come around after a few tries...
The best of all is as you so well put it: "...and if it's not supported, the (Hass) entity will either ignore it or log an error, but nobody dies, missiles do not launch, gravity still works, the sun continues to rise and set, etc."
Even Shakespeare him self would be impressed! -
-
-
-
@whyfseeguy said in TTS in MSR?:
What did I do wrong?
Well, you didn't post what the action logged. Did you look?
Off the top of my head looking at it, you've wrapped
data
indata
. I think you just need it to be:{ "entity_id": "media_player.media_room_tv", "message": "hello there" }
-
It is working now with your recipe. I had too many "data" in data field. I was following the examples above and got confused.
-
-
This thread has been super helpful. I have a few questions that are somewhat related:
- Similar to @therealdb 's request. Is there a way to call this from the Alexa entity vs. a "call service" from the controller entity? I tried adding the TTS service but it's still not showing up under the entity. (see below - ignore multiple entries - was trying a few formats of the name)
- In the service call, is there a way to make the announcement at a certain volume? Even better if it could snap back. You can see I'm setting the volume, delaying, and then announcing but was wondering if someone has a more elegant solution.
I realize this isn't all an MSR issue (much more HASS) but thought there are good minds here that may be able to help. Thanks.
-
Here's everything from the entity page:
av_repeat.repeat_mode="unknown" av_repeat.shuffle=null av_transport.album_art=null av_transport.current_album=null av_transport.current_artist=null av_transport.current_title=null av_transport.current_track=null av_transport.state="standby" muting.state=false power_switch.state=true volume.level=0.15 x_hass.domain="media_player" x_hass.entity_id="media_player.office_echo" x_hass.services=["media_player"] x_hass.state="standby" x_hass_attr.available=true x_hass_attr.bluetooth_list=[] x_hass_attr.connected_bluetooth=null x_hass_attr.friendly_name="Office Echo" x_hass_attr.is_volume_muted=false x_hass_attr.last_called=true x_hass_attr.last_called_summary="" x_hass_attr.last_called_timestamp=1660318076357 x_hass_attr.media_content_type="standby" x_hass_attr.media_position_updated_at="2022-08-12T16:05:58.870619+00:00" x_hass_attr.source="Local Speaker" x_hass_attr.source_list=["Local Speaker"] x_hass_attr.supported_features=56253 x_hass_attr.volume_level=0.15 Capabilities: av_repeat, av_transport, media_navigation, muting, power_switch, toggle, volume, x_hass, x_hass_media_player Actions: av_repeat.repeat_all, av_repeat.repeat_off, av_repeat.repeat_one, av_repeat.set_repeat, av_repeat.set_shuffle, av_repeat.shuffle_off, av_repeat.shuffle_on, av_transport.fast_forward, av_transport.pause, av_transport.play, av_transport.rewind, av_transport.stop, media_navigation.next_chapter, media_navigation.next_media, media_navigation.next_track, media_navigation.previous_chapter, media_navigation.previous_media, media_navigation.previous_track, muting.mute, muting.set, muting.toggle, muting.unmute, power_switch.off, power_switch.on, power_switch.set, toggle.toggle, volume.decrease, volume.increase, volume.relative, volume.set, volume.set_db, x_hass_media_player.clear_playlist, x_hass_media_player.join, x_hass_media_player.media_next_track, x_hass_media_player.media_pause, x_hass_media_player.media_play, x_hass_media_player.media_play_pause, x_hass_media_player.media_previous_track, x_hass_media_player.media_seek, x_hass_media_player.media_stop, x_hass_media_player.play_media, x_hass_media_player.repeat_set, x_hass_media_player.select_sound_mode, x_hass_media_player.select_source, x_hass_media_player.shuffle_set, x_hass_media_player.toggle, x_hass_media_player.turn_off, x_hass_media_player.turn_on, x_hass_media_player.unjoin, x_hass_media_player.volume_down, x_hass_media_player.volume_mute, x_hass_media_player.volume_set, x_hass_media_player.volume_up
-
-
-
therealdbreplied to noelab on Nov 2, 2024, 11:25 AM last edited by toggledbits Nov 2, 2024, 11:35 AM
@noelab ciao! I randomize them in Reactor. Just use this:
messages[ floor( random() * len( messages) )
where
messages
is a local variable like this:[ "Bentornato a casa", "Casa, dolce casa!", "Ciao!", ]
-
@therealdb said in TTS in MSR?:
[
"Bentornato a casa",
"Casa, dolce casa!",
"Ciao!",
]Grazie! and thanks to @toggledbits for the new dark theme, also my eyes are happy!
27/33