How to connect android phone via websocket with Node-RED to recieve messages

Hi I am currently working on a project for my university and I am not really familiar with Node-RED, and Java Websockets.

Bascily the Project is a voice assistant:

  1. you speak into a Rasspberry PI which runs Rhasspy(voice to text) -> creating intents -> which are send to Node-RED in Json format
  2. Node-RED recieves intents in Json Format. -> send to Android App(jsut display data for now)
  3. I want to get the data on my android Phone.

Right now I have my Rasspberry PI connected with my Node-RED server and I am sending "intents" which contain data in Json format this is working so far. For example I say: " how is the weather " -> I get via an input websocket: Intent: object
name: "weather"
.....
text: "how is the weather"

Now I want to get this data in Json format with my android(running Java and want to use Websockets(OkHttp) ) phone via websockets but I am not sure how to get it are there already any example on how to connect my phone to the Node-RED server and get the Json data?

My idea now:

  1. Run a websocket client on my phone which connects to Node-RED:ws://......:1880
  2. Create "output websocket" in Node-RED which sends payload(Json data) to my android
    --> now jsut display text^^

Excuse my english is not my mother language :smiley:
I appreciate any help and idea :slight_smile: :vulcan_salute:

you could install node-red on the phone using termux app. On my other devices i have automate with a mqtt tasker plugin.

Thank you already :slight_smile:
is there any good guide/example?
:vulcan_salute:

Yes in the getting started section of the documentation link above
https://nodered.org/docs/getting-started/android

What are you going to do with the data once you have it in the phone. Have you considered something like Telegram if you are just trying to get notifications?

Hi, once I get the data on my phone I want to build an URL with the recieved data for REST-API.

For example you ask "what food today in mensa" -> I build URL for example: https......./mensa/today -> and phone will be able to displlay JSON from Rest-API

Are you going to write an Android app for that?

Automate would do all that, no need to install node-red As said you can run a mqtt or http plugin or use google firebase messaging, and receive the data, Automate can display notification, dialogs or you can use Web dialogs and build your own html/javascript page. This would probably be less resource/battery hungry. Automate could also call your rest API

yes, I wrote already an APP hardcoded for Rest-API so far but want to switch it to the correct url with the recieved parameter from Node RED and Tasker so my app is more flexible and I get correct data on display :slight_smile:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.