Run a script from another computer with mqtt

Hi
I can run a webradio from Another raspberry pi with omxplayer and it works greate.
But now I like to Control the radio with my Hassio and was thinking MQTT have to be a easy way.
So I did add a inject and MQTT node to make a test

1
2
3

and on the remote raspberry I have install Mosquitto and run this command
mosquitto_sub -d -t Radio

I then got this response from Node-Red when I push the injector

Client mosqsub/1688-raspberryp received PUBLISH (d0, q0, r0, m0, 'Radio', ... (0 bytes))

It does response but maybe not like that I was hoping for. I was hoping for just a “ON” so I have to do something strange.
I also trying to make a script and I was going to try to use python 3 and I maybe have a idea how to do that but not sure if I can do that until I have fix the first problem so I can send a ON/OFF command tru mqtt

Your inject node is not configured correctly.

I can tell from its title, “ON:” that you left its payload blank and assigned ON to its topic. That’s why mosquitto_sub received no payload.

ON should be in the payload field

1 Like

Wow it was correct thanks :slight_smile:

Client mosqsub/884-raspberrypi received PUBLISH (d0, q0, r0, m0, 'Radio', ... (2 bytes))
ON

Next step is to use python run run omxplayer.

You might want to look into command line switches:

It makes a swtich in HA the calls a command line command (could be a python script or curl command, etc.

Or you may wish to try a media player that already has home assistant support, like mpd.

1 Like

ohh I Think I going to try that too :slight_smile: