JSON always in same sequence possible?

Is there an opportunity to get the JSON in always the same sequence for the same sentence, just in a different way?

As an example:

Sentence A:
“fahre rollade mia garten hoch”

gives the JSON as follows:

{
    "entities": [
        {
            "end": 9,
            "entity": "room_name",
            "raw_end": 9,
            "raw_start": 6,
            "raw_value": "mia",
            "start": 6,
            "value": "mia"
        },
        {
            "end": 16,
            "entity": "location_name",
            "raw_end": 16,
            "raw_start": 10,
            "raw_value": "garten",
            "start": 10,
            "value": "garten"

Sentence B (same meaning, different sequence):
“fahre rollade garten mia hoch”

gives the JSON as follows:

{
    "entities": [
        {
            "end": 12,
            "entity": "location_name",
            "raw_end": 12,
            "raw_start": 6,
            "raw_value": "garten",
            "start": 6,
            "value": "garten"
        },
        {
            "end": 16,
            "entity": "room_name",
            "raw_end": 16,
            "raw_start": 13,
            "raw_value": "mia",
            "start": 13,
            "value": "mia"

Right now I tried it with following form of sentence:

[moveshutter]
[fahre| mache | setze] ($room_name){room_name} ($location_name){location_name} (hoch | runter){updown_name}
[fahre| mache | setze] ($location_name){location_name} ($room_name){room_name} (hoch | runter){updown_name}

I ask this question because I like to proceed with the JSON through MQTT and it would be easier to get it in the same sequence.

Thanks and greetings,
Thomas

Hi Thomas,

I’m not sure why you would want to have a fixed sequence.

I don’t use MQTT, and I’m not sure you get the same information there as when using an HTTP server.

But assuming the json is the same for both and you are just interested in getting the values for room_name & location_name, have a look at the slots section in the json. That’s a lot easier to access.

{
"entities": [{
        "end": 33,
        "entity": "when_day",
        "raw_value": "tomorrow",
        "start": 25,
        "value": "tomorrow"
    }, {
        "end": 44,
        "entity": "location",
        "raw_value": "New York",
        "start": 37,
        "value": "New York"
    }
],
"intent": {
    "confidence": 1.0,
    "name": "GetWeatherForecast"
},
"slots": {
    "when_day": "tomorrow",
    "location": "New York"
}
}

Some parts removed to focus the json on the topic :wink:

Yes same here, this is json not a sequenced data.
Don’t where keeping sequence would help, and it would break lot of stuff as all is based on json event internally.

Well, yes and yes.
My message wasn´t clear expressed.

I don´t like to change the JSON format, I am looking for a better example sentence which give me always the same sequence of slots.
But after rethinking, that could be very difficult and maybe it´s easier to adjust the logic structures after the MQTT payload for the edomi home automatic software

If you have understood the slot concept as defined in the earlier post, it would be as easy as grabbing the correct values from the JSON object. You can achieve by doing just the tags also like “fahre rollade mia{ room_name} garten {garten} hoch” & “fahre rollade garten {garten} mia {room_name} hoch”. In your receiving program, just look for these tags as a slot values.

1 Like

First feed you MQTT message through a JSON node, the output will be a Javascript object.
Feed the output to a Function node.
In that node you can use the objects returned

Yes, I think it will be the easiest solution to modify the logic module (php based) at the other end.
I will think about how to handel that.
THX

euh, that was no reply to my post I think?

well, a little bit.
I will try to change the php code in the logic module (picture) so that I don´t need to do a detour over java. I will try to figure something out.
THX!

Unbenannt