[SOLVED] How to send message bus commands via the websocket listening port?

Hello again,

My main objective in adopting MyCroft across the home is to provide a customised, on-prem voice control method for use with my home automation platform (HomeSeer in my case).

One key requirement of this is to be able to perform text-to-speech audio announcements that are triggered from home automation events. Examples include announcing when the letterbox has been opened, or that the washing machine has finished it’s cycle.

Using the mycroft-cli-client I can of course issue commands like “speak ” and have mycroft say some text out loud. The warning that appears when first starting the cli client indicates it should be possible to send these same commands to the mycroft message bus remotely.

Can someone provide me some instructions and examples on the correct way to do this? I don’t know much about webhooks :frowning:

I’m hoping this can be done using curl, possibly by delivering the command as a payload in a HTTP GET or POST? Using curl would easily allow me to integrate it into scripts called by the home automation server.

I’d like to be able to perform “speak ”, for use in dynamic messages. As well as play a mp3/wav file that is stored on a network share, for those events where the content of the message doesn’t change.

Thank you all for any help.

- Michael.

Have you seen this? https://community.openconversational.ai/t/testing-and-feedback-for-mesh-skill-mycroft-to-mycroft-communicator
I think it can help you to achieve what you want, or at least, some of them. I’m using HomeAssistant, not HomeSeer, but I guess HomeSeer will use mqtt so mycroft can subscribe to the same topics as the home automation.

1 Like

Ergh, so that original title and message content should read “websocket” and not “web hook” of course :confounded: Don’t mind me, I have a 6 week old infant at home so not firing on all cylinders…

@malevolent, that looks very interesting, thank you for pointing it out. I will circle back to that in the future as it seems like a much more robust broadcast system.

For now, I have found my “one liner”, using the websocat project from github:

It has a stand alone .exe that can be called in a batch file. Here’s the one liner I used:

echo {"type": "speak", "data": {"utterance": "hello world"}, "context": {}} | c:\users\michael\downloads\websocat_win64.exe -1 ws://192.168.10.9:8181/core

The first half of that is the message to be delivered onto the message bus. All messages specify a type. Depending on the message type additional data may be sent, in this case the phrase to be spoken (utterance). “Context” is optional data and can include information such as where the message originated from.

That message is then piped to websocat for delivery.
The -1 tells websocat to deliver a single message then disconnect.
The ws://192.168.10.9:8181/core is the websocket address of the picroft. If you’re trying to recreate this then obviously you would replace the ip address with the address or hostname of your own device.

See here for full documentation of available message types:

https://mycroft-ai.gitbook.io/docs/mycroft-technologies/mycroft-core/message-types

The possibilities of this are looking fantastic. Some examples of what you could do in home automation using this:

Pause music playing through your mycroft when the doorbell rings.
Put mycroft to sleep each night on a schedule and wake it up in the morning, without saying a word to it.
Use something like an amazon dash button or a z-wave remote to have mycroft start listening without the need of a wake word. Star Trek lapel comm anyone?

Thank you Mycroft team, I freaking love this project.

2 Likes

Those are some great ideas. I am working to use the mqtt skill to have mycroft anounce some actionable items in my home assistant. Eg. @10pm home assistant lets Mycroft know i left the garage door open then Mycroft tells me. Once a week home assistant via mycroft tells me to take the garbage out. Good luck and keep us informed on your progress.

1 Like