Websocket closing on restarting rhasspy - Issue with NodeRed?

Hello there, while playing around with NodeRed, i just realized that whenever the rhasspy base is restarted the websocket connection stops working.
Meaning, I do not get any intents anymore.

The only way to reconnect seems to be deleting the whole websocket connection within NodeRed and readding it. A simple redeploy of the node doesn’t work.

Is this a known issue? Is this a problem with NodeRed?
Any workarounds maybe?

+1 here too.
I’m having the same issue.

as an alternative, im now just listening to the MQTT stream directly… this also works after a rhasspy restart

Ah, that seems promising! Thanks for the tip. I’ll give it a try. :+1:

When using the mqtt method, the message unfortunately looks completely different. All of the slots are hidden in an array which makes it very difficult to work with it.

After a lot of trial and error, I have finally created a small subflow that takes the slots from the arrays , as well as some other important messages and outputs an easy to use message with the following message objects:

siteid
intent
slot (every slot as a single object)

Hope this will help somebody.

[{"id":"e969ca04.f2c998","type":"subflow","name":"RHASSPY MQTT to MSG ","info":"","category":"","in":[{"x":260,"y":140,"wires":[{"id":"b79a846.aa77978"}]}],"out":[{"x":1100,"y":140,"wires":[{"id":"7321138.7f86cec","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"c0ca8e07.b0c62","type":"split","z":"e969ca04.f2c998","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":550,"y":140,"wires":[["c9362005.41911"]]},{"id":"b79a846.aa77978","type":"change","z":"e969ca04.f2c998","name":"","rules":[{"t":"move","p":"payload.intent.intentName","pt":"msg","to":"intent","tot":"msg"},{"t":"move","p":"payload.siteId","pt":"msg","to":"siteId","tot":"msg"},{"t":"move","p":"payload.slots","pt":"msg","to":"payload","tot":"msg"},{"t":"delete","p":"_topic","pt":"msg"},{"t":"delete","p":"_msgid","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"qos","pt":"msg"},{"t":"delete","p":"retain","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":140,"wires":[["c0ca8e07.b0c62"]]},{"id":"c9362005.41911","type":"function","z":"e969ca04.f2c998","name":"","func":"let value = msg.payload.value.value\nlet name = msg.payload.slotName\nmsg[name] = value\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":680,"y":140,"wires":[["55c7232f.bbcdcc"]]},{"id":"55c7232f.bbcdcc","type":"join","z":"e969ca04.f2c998","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":"false","timeout":"","count":"","reduceRight":false,"x":810,"y":140,"wires":[["7321138.7f86cec"]]},{"id":"7321138.7f86cec","type":"change","z":"e969ca04.f2c998","name":"","rules":[{"t":"delete","p":"_msgid","pt":"msg"},{"t":"delete","p":"retain","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":140,"wires":[[]]},{"id":"1d2db197.e3d51e","type":"subflow:e969ca04.f2c998","z":"2435a2d8.f9527e","name":"","x":410,"y":1940,"wires":[["9d01c48.b495738"]]}]

I’m also using nodered. And I know this Problem. I’m using a single function with following code:

var slots = {"room":msg.payload.siteId}
for (var i in msg.payload.slots){
    slots[msg.payload.slots[i].slotName] = msg.payload.slots[i].value.value
}
msg.slots = slots

return msg

this creates : msg.slots with all the slots and its values.
The first line takes the siteID (mine are room names) as msg.slots.room if I do not ask for a specific room:
“mach das licht an” (switch on the light ) becomes in room “wohnzimmer”:

slots: object
    room: "wohnzimmer"
    device: "licht"
    state: "true"

Just put this code in a function directly after the “mqtt in”-node

Version 2 with nothing else than the important stuff and forEach:

var slots = {"room":msg.payload.siteId}

msg.payload.slots.forEach(function(slot) {
    slots[slot.slotName] = slot.value.value
});

return {
    "topic":msg.topic,
    "intentName": msg.payload.intent.intentName,
    "siteId": msg.payload.siteId,
    "slots": slots
}
1 Like