i8beef / node-red-contrib-castv2

MIT License
22 stars 14 forks source link

Feature Request - Support for incoming msg ? #46

Closed cw-kid closed 3 years ago

cw-kid commented 3 years ago

Hi

I've been using the other node-red-contrib-cast for sending TTS announcements from my home automation system to my Google Home speakers.

Its now broken and no longer works.

I've just installed node-red-contrib-castv2 instead but it appears it doesn't support incoming messages like these ?

image

With node-red-contrib-cast I was able to use dynamic HTTP commands coming from my home automation system for different TTS messages and also was able to specify which Google Home speaker I wanted to target.

image

For example by using a HTTP command like this:

http://NODE-RED-IP:1880/sceneTrigger?message=Alarm%20Carbon%20Monoxide%20Detected&ip=GOOGLE-HOME-IP

I could also specify multiple Google Home IP addresses to have the TTS play out on all of them.

http://NODE-RED-IP:1880/sceneTrigger?message=Alarm%20Carbon%20Monoxide%20Detected&ip=192.168.0.16|192.168.0.19|192.168.0.21|192.168.0.24

This meant I did not have to create a flow in Node Red for each different TTS message text and for each Google Home speaker etc. I just had the one simple flow as seen in the screen shot above and changed the HTTP command URLs on my Home Automation controller that it was sending out.

This is the code used in the Function node:

var IPS = msg.payload.ip.split("|"); for (var i in IPS) { msg.payload = {"message": msg.payload.message, "ip": IPS[i], "volume": msg.payload.volume}; node.send([null, [msg]]); } msg.payload = "ok"; // the response message return [msg];

Can Castv2 do this or support for it be added ?

Many thanks.

i8beef commented 3 years ago

This is not a drop in replacement for the other cast node, it is a reimplementation with a completely different model. You will have to change your incoming message structures to conform to the documented formats on the main page here.

The model is not "open connection, send command, close connection" in this node, it maintains an open always-on connection to the cast targets specified. Each node is an interface to a single connection (but connections are shared, so multiple nodes targeting a single cast device share a connection to it). You cannot control cast target from incoming message, by design, and you will at a minimum require a node-per-cast-target approach. You will have to route your messages to the appropriate node before hand.

You CAN set the TTS phrase in the incoming message though. Check the documentation.

cw-kid commented 3 years ago

Hi

Thanks for the reply and explanation.

With some help from a friend, I've setup this now with CastV2 and my existing HTTP commands my home automation controller is sending out, don't have to be modified in anyway.

I can still dynamically in the HTTP command specify the Text to be spoken out and which Home speakers should say it, by specifying their IP's in the URL etc.

image

Function Code:

var IPS = msg.payload.ip.split("|"); var message =msg.payload.message; for (var i in IPS) { msg.payload = { type: "TTS", text: message, speed: 1, // optional to adjust TTS speed, defaults to 1 language: "en", // optional to set TTS language, default to en title:"", ip: IPS[i] }

node.send([null, [msg]]); } msg.payload = "ok"; // the response message return [msg];

The Switch function is for each IP address of each Home speaker

image

And obviously each blue Castv2 node is connected to each Home speaker by its LAN IP also.

i8beef commented 3 years ago

Cool, glad you got it working. Closing out.

Shannondalebreaux commented 3 years ago

Hi

Thanks for the reply and explanation.

With some help from a friend, I've setup this now with CastV2 and my existing HTTP commands my home automation controller is sending out, don't have to be modified in anyway.

I can still dynamically in the HTTP command specify the Text to be spoken out and which Home speakers should say it, by specifying their IP's in the URL etc.

image

Function Code:

var IPS = msg.payload.ip.split("|"); var message =msg.payload.message; for (var i in IPS) { msg.payload = { type: "TTS", text: message, speed: 1, // optional to adjust TTS speed, defaults to 1 language: "en", // optional to set TTS language, default to en title:"", ip: IPS[i] }

node.send([null, [msg]]); } msg.payload = "ok"; // the response message return [msg];

The Switch function is for each IP address of each Home speaker

image

And obviously each blue Castv2 node is connected to each Home speaker by its LAN IP also.

can you help set a simple tts for my google mini speaker? i am using node red as well, was using the old cast node.

i8beef commented 3 years ago

For future reference, its better to create a new ticket than post unrelated questions on old ones, so we don't spam other watchers on this one with unrelated stuff.

The documentation page here is fairly exhaustive in this regard. You just setup the connection on the node, and then inject a JSON message as specified (A function node is usually good for this).

return {
  payload: {
    type: "TTS",
    test: "Your text"
  }
};

If you need further help, please open a new ticket.

Shannondalebreaux commented 3 years ago

Oh sorry for any inconvenience.thats the part I am getting stuck on the function node as there is many options within the function node to select. Everything has to be perfect or it won't work. So forgive me I am a newbie here. Have a blessed day,Shannon BreauxProverbs 16:7When people's lives please the LORD,even their enemies are at peace withthem. -------- Original message --------From: Michael Hallock notifications@github.com Date: 12/8/20 6:23 PM (GMT-06:00) To: i8beef/node-red-contrib-castv2 node-red-contrib-castv2@noreply.github.com Cc: Shannondalebreaux shannondalebreaux@gmail.com, Comment comment@noreply.github.com Subject: Re: [i8beef/node-red-contrib-castv2] Feature Request - Support for incoming msg ? (#46) For future reference, its better to create a new ticket than post unrelated questions on old ones, so we don't spam other watchers on this one with unrelated stuff. The documentation page here is fairly exhaustive in this regard. You just setup the connection on the node, and then inject a JSON message as specified (A function node is usually good for this). return { payload: { type: "TTS", test: "Your text" } };

If you need further help, please open a new ticket.

—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.

cw-kid commented 3 years ago

Our new flow for Google TTS using the CastV2 node, you can read about it and find the flow code on the Vera forum

https://community.getvera.com/t/using-node-red-for-google-home-tts-announcements-and-other-stuff-ewelink/213790

Shannondalebreaux commented 3 years ago

I am not familiar with the http get part it's says URL all my automation is through Home assistant which have entity names not URL unless i am missing something. Have a blessed day,Shannon BreauxProverbs 16:7When people's lives please the LORD,even their enemies are at peace withthem. -------- Original message --------From: cw-kid notifications@github.com Date: 12/8/20 7:01 PM (GMT-06:00) To: i8beef/node-red-contrib-castv2 node-red-contrib-castv2@noreply.github.com Cc: Shannondalebreaux shannondalebreaux@gmail.com, Comment comment@noreply.github.com Subject: Re: [i8beef/node-red-contrib-castv2] Feature Request - Support for incoming msg ? (#46) Our new flow for Google TTS using the CastV2 node, you can read about it and find the flow code on the Vera forum https://community.getvera.com/t/using-node-red-for-google-home-tts-announcements-and-other-stuff-ewelink/213790

—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.

i8beef commented 3 years ago

@cw-kid 's implementation is completely custom to his or her needs. Again, this is not the correct place to ask generic questions. Please open a new ticket if the documentation isn't clear enough.