Rhasspy 2.4.x to 2.5 migration strategy

Continuing the discussion from Training issue with Rhasspy 2.5: string index out of range:
@kaykoch
Hello Kay,

thank you for these node-red examples. I tried to import them, either directly via copy/past or via .json file. Both ways don’t work due to syntax errors:

From my perspective it’s a mess that I have to create new scripts, just to be able to use Rhasspy 2.5 in the same manner as I used 2.4.x before.

As I already mentioned in my previous post: In 2.4.x there were also these topics available: rhasspy/intent/#, which existed in parallel to hermes/intent/#.

The big advantage of these rhasspy/intents was, that the exactly contained the relevant information of the topic as it is shown under the command line of the Rhasspy home screen:

This allowed for standardised, slim and easy programming of scripts, while the current hermes/intent string appears much more complicated to me:

{“input”: “true Brot auf die bring.0.fe193da6-c03d-4828-b74f-5818d6ee1006 .saveItem”, “intent”: {“intentName”: “SetShoppingList”, “confidenceScore”: 1.0}, “siteId”: “Satellite1”, “id”: “c172d143-da6c-4891-bebc-f3e0342c0c48”, “slots”: [{“entity”: “synonyms_change_command”, “value”: {“kind”: “Unknown”, “value”: “true”}, “slotName”: “command”, “rawValue”: “setze”, “confidence”: 1.0, “range”: {“start”: 0, “end”: 4, “rawStart”: 0, “rawEnd”: 5}}, {“entity”: “shopping_item”, “value”: {“kind”: “Unknown”, “value”: “Brot”}, “slotName”: “value”, “rawValue”: “brot”, “confidence”: 1.0, “range”: {“start”: 5, “end”: 9, “rawStart”: 6, “rawEnd”: 10}}, {“entity”: “device_name_shoppinglist”, “value”: {“kind”: “Unknown”, “value”: “bring.0.fe193da6-c03d-4828-b74f-5818d6ee1006”}, “slotName”: “device”, “rawValue”: “haushaltsliste”, “confidence”: 1.0, “range”: {“start”: 18, “end”: 62, “rawStart”: 19, “rawEnd”: 33}}, {“entity”: “state”, “value”: {“kind”: “Unknown”, “value”: “.saveItem”}, “slotName”: “state”, “rawValue”: “”, “confidence”: 1.0, “range”: {“start”: 63, “end”: 72, “rawStart”: 34, “rawEnd”: 33}}], “sessionId”: “c172d143-da6c-4891-bebc-f3e0342c0c48”, “customData”: null, “asrTokens”: [[{“value”: “true”, “confidence”: 1.0, “rangeStart”: 0, “rangeEnd”: 4, “time”: null}, {“value”: “Brot”, “confidence”: 1.0, “rangeStart”: 5, “rangeEnd”: 9, “time”: null}, {“value”: “auf”, “confidence”: 1.0, “rangeStart”: 10, “rangeEnd”: 13, “time”: null}, {“value”: “die”, “confidence”: 1.0, “rangeStart”: 14, “rangeEnd”: 17, “time”: null}, {“value”: “bring.0.fe193da6-c03d-4828-b74f-5818d6ee1006”, “confidence”: 1.0, “rangeStart”: 18, “rangeEnd”: 62, “time”: null}, {“value”: “.saveItem”, “confidence”: 1.0, “rangeStart”: 63, “rangeEnd”: 72, “time”: null}]], “asrConfidence”: null, “rawInput”: “setze brot auf die haushaltsliste”, “wakewordId”: null}

I understand that Rhasspy 2.5 brings a lot of benefits and advantages. However, by means of smooth and user friendly migration I cannot believe that forcing the users to rewrite all their scripts is the desired migration strategy.

So do you know, if there are currently still some features missing? Will the MQTT data structure remain as it is or will it be extended with rhasspy/intent… as in 2.4.x again?

Kay, maybe you have heard something about this / maybe you are the wrong addressee for these question. So I put @synthesiam in the loop. Please advise me, how to proceed: Re-writing scripts or waiting for rhasspy/intents? Thanks a lot.

Best
Thomas

1 Like

You were right. I made a fault. I needed to format the code as “preformated code”. Now you can test it.

Here is my javascript code to use the slots values:

// takes the siteId as room. Will be overwritten, when room-slot exist
var slots = {"room":msg.payload.siteId}

// write all slot names as own variable
for (var i in msg.payload.slots){
    slots[msg.payload.slots[i].slotName] = msg.payload.slots[i].value.value
}
msg.slots = slots
    
return msg

mqtt_example_4

Hi Kay,

thank you for changing your nodered files. I was able to import them, which allowed me to analyze what your scripts are doing in detail. I thus found that your version 3 is currently the most important one for me. It does exactly what my Java scripts are doing as well, i.e. to extract the slots for further operation. Of course I could use nodered to trigger my devices again. However I would prefer to modify my Java scripts since this seems less work to me, although I have less experience with Javascript than with nodered :slightly_frowning_face:

Could you please have a look at my script? From my perspective just two lines need to be adapted to connect to my new MQTT broker and to address the slots in the JSON string. I have tried a lot in the meantime, unfortunately with no success.

//Script to control lights, dimmers and blinds
//var intentResult = $(‘mqtt.0.hermes.intent.Change*’); // worked formerly
var intentResult = $(‘192.168.13.155:1338/hermes/intent/Change*’);
//var intentResult = $(’/hermes/intent/Change*’); // already tested in vain
var intentArray = [];
for(var i = 0; i < intentResult.length; i++)
{
log(intentResult[i]);
intentArray.push(intentResult[i]);
}
on({id: intentArray, change: “any”}, function (obj) {
log(obj.newState.val);
// let intentObject = JSON.parse(obj.newState.val); // worked formerly
let intentObject = JSON.parse(msg.payload.slots);
if(intentObject.hasOwnProperty(‘device’))
{
var deviceID = intentObject.device;
var state = intentObject.state;
var value = intentObject.value;
if(deviceID.includes(“milight”))
{
log(deviceID +".state" + value);
setState(deviceID + “.state”, JSON.parse(value));
}
else
{
log(deviceID + state + value);
setState(deviceID + state, JSON.parse(value));
}
}
});

Do you have any clue what needs to be done here?

PS: I am currently working on a server allowing people who helped me to download a pint of beer or whine :wink:

Thank you for your help
Thomas