Struggle after NR Upgrade

So I did a massive update lastnight to NR 1.0.1<?> to 2.1.3 and I hit a couple of snags.

First was I screwed up and didn't read the on screen messages right and merged my flows with the great digital void. Luckily my habit of keeping a million tabs open meant I had most of my flows still open in an old tab and I was able to export and re-import them without too much trouble (Yay digital clutter).

However it seems that a template node that did work no long does, well not as it did before.
I had a template node acting as a catch all for unrecognized intents from Rhasspy. It got the unrecognized intents and output some text to rhasspy to speak.
After the upgrade it's sending the entire content of the template node code as the text for Rhasspy to speak, this is well, less than ideal.

Here is the template node setup,
Property: msg.payload
Format: Plain text
Output: Parsed JSON

Template:

{
  "data": {
    "intent": {
      "name": "unrecognized",
      "confidence": 0
    }
  },
  "speech": {
    "text": "I'm Sorry I did not understand your request."
  }
}

Here's the export (I'm not sure which is preferred

[{"id":"c7eefe1e0fae44d6","type":"template","z":"e17061c5369e4b2b","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"plain","template":"{\n \"data\": {\n \"intent\": {\n \"name\": \"unrecognized\",\n \"confidence\": 0\n }\n },\n \"speech\": {\n \"text\": \"I'm Sorry I did not understand your request.\"\n }\n}","output":"json","x":450,"y":520,"wires":[["30dcf62f8d4df3f3","a413ae6ef73bb123"]]}]

Connect a debug node to the output and see what it says. As you have configured the template it should show a javascript object containing the attributes you have specified. Is that not what you expect? If not then what do you expect?

You haven't told us what node you are feeding it into so I can't look it up.

@Colin

The node feeding into the template is a switch with this node attached to the last option 'otherwise'.

Before the upgrade when this was triggered the text 'I'm Sorry I didn't understand your request' was sent to the http request node and Rhasspy spoke just those words.

Now it's saying 'left curly bracket, data, colon, right curly bracket, intent, colon, etc'

When something is not working it is important to look at each node output along the way and work out where it is going wrong.

Did you connect a debug node to the template output and see what it gives?

You didn't answer the question as to whether that is what you wanted out of the node.

In addition to answering those questions post the flow for the nodes after the template so we can see what you are doing with it. You only posted the template node previously, and for me it is performing exactly as it should. You did not get the flow posting format quite right, see this post for the best way. How to share code or flow json

@Colin

I guess my issue is my lack of complete understanding. I don't know why it worked before the update, it worked as expected so I didn't dig in to figure out why it worked. Now that it doesn't I'm a bit lost.

This is definately not what I expected from this node. I expected just the 'I'm sorry I didn't....' portion to be spoken by Rhasspy, I don't want the code spoken.
I think the code is being sent as the payload instead of just the "speech" portion???

Here is the flow with triggers to start each node. The 'time text' node is the only one that works as expected. Fingers crossed I get the code posted correctly this time.

[{"id":"a13c99df465dc491","type":"inject","z":"e17061c5369e4b2b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":290,"y":80,"wires":[["c5c2535d4f57eefc"]]},{"id":"ecbbe9645d2a312d","type":"inject","z":"e17061c5369e4b2b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":330,"y":240,"wires":[["649a9c6bbb64afe8","fd21be261c32e191"]]},{"id":"0c4309cf2b5cfed7","type":"inject","z":"e17061c5369e4b2b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":280,"y":580,"wires":[["c7eefe1e0fae44d6"]]},{"id":"c7eefe1e0fae44d6","type":"template","z":"e17061c5369e4b2b","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"plain","template":"{\n  \"data\": {\n    \"intent\": {\n      \"name\": \"unrecognized\",\n      \"confidence\": 0\n    }\n  },\n  \"speech\": {\n    \"text\": \"I'm Sorry I did not understand your request.\"\n  }\n}","output":"json","x":480,"y":500,"wires":[["30dcf62f8d4df3f3","a413ae6ef73bb123"]]},{"id":"fd21be261c32e191","type":"function","z":"e17061c5369e4b2b","name":"Outside Temp prefix","func":"msg.payload = \"It is\" + \"23\" + \"degrees outside\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":360,"wires":[["f3a36540080a5c29"]]},{"id":"649a9c6bbb64afe8","type":"function","z":"e17061c5369e4b2b","name":"House Temp prefix","func":"msg.payload = \"and\" + \"21\" + \"degrees inside\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":320,"wires":[["8fe94ea5cf3f4040"]]},{"id":"c5c2535d4f57eefc","type":"function","z":"e17061c5369e4b2b","name":"time text","func":"var timeString = new Date().toLocaleTimeString([],\n{\n    hour: \"2-digit\", \n    minute: \"2-digit\",\n    hour12: true\n})\n\nreturn {\n    payload: \"It is \" + timeString\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":120,"wires":[["30dcf62f8d4df3f3"]]},{"id":"8fe94ea5cf3f4040","type":"change","z":"e17061c5369e4b2b","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":320,"wires":[["664c2682c5d9273b"]]},{"id":"f3a36540080a5c29","type":"change","z":"e17061c5369e4b2b","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":360,"wires":[["664c2682c5d9273b"]]},{"id":"a413ae6ef73bb123","type":"debug","z":"e17061c5369e4b2b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":750,"y":600,"wires":[]},{"id":"664c2682c5d9273b","type":"join","z":"e17061c5369e4b2b","name":"Output Test","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"bin","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":890,"y":340,"wires":[["30dcf62f8d4df3f3","a413ae6ef73bb123"]]},{"id":"30dcf62f8d4df3f3","type":"http request","z":"e17061c5369e4b2b","name":"text to speech","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.230:12101/api/text-to-speech","tls":"","persist":false,"proxy":"","authType":"basic","senderr":false,"credentials":{},"x":1080,"y":260,"wires":[[]]}]

I think I know what's going on, maybe?

I think the output of the unrecognized and join nodes are Objects instead of payloads.

I changed the join node to 'string' and Rhasspy spoke what I was expecting, although in the wrong order. So still wrong but it's note speaking code anymore.

As for the unrecognized node, not sure how to fix that

Neither do I, I don't see how it ever worked. For the bottom one I think you just want this in the template, with the Output set to Plain Text.
image

For the middle one, first change the topics to A and B rather than 1 and 2, it makes the syntax tricky with numbers, then add a template after the join containing something like
{{payload.A}} {{payload.B}}
again with the output set to plain text, and with the format set to moustache.

@Colin

Changing the template to simply have the string I want to hear worked perfectly.

I'm going to assume there were a few changed made between ver 1 and ver 2 of NR :slight_smile:

The template after the join works, but now my functions that take the temperature output from HomeAssistant and combine it with some text are not working.

Seems
msg.payload = "and " + msg.payload + " degrees inside"; return msg;
returns 'undefined' now. I know the HA nodes are getting the temperatures as they display in the flow under the nodes.

Correction, it's working now except for left over data being passed along.

Feed what is going into the function node into a debug node and check the value is in the payload. Also check the output of the function with a debug node.
If still not working then show us the debug outputs and the complete function contents.

@Colin

I think my issue now is that old cached? payloads are stuck and being passed along with every request.
When I ask for the temperature I'm getting the time, the unrecognized statement, the undefined temperature, and the correct temperature.

Do you mean you are getting additional messages with those values in the payload? If so then they are coming from somewhere, they will not just magically appear in the message stream. Work back up the flow to find where they are coming from.

@Colin
Thanks, for your help, got it all sorted out now

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