JSON response for device is reordering each time

I am calling my hubitat to get the value of a specific device. The order of the JSON changes routinely when I make the call - two examples below. I know that JSON order is not required to be consistent but the system I am reading this into can't handle the changing location of the elements. I am not quite sure why the order is changing in hubitat - is this something I can control? Thanks.

{"id":"1796","name":"Presence - All Home (Virtual)","label":"Presence - All Home (Virtual)","type":"Virtual Values","room":null,"attributes":[{"name":"number","currentValue":100,"dataType":"NUMBER"},{"name":"level","currentValue":100,"dataType":"NUMBER"},{"name":"switch","currentValue":"off","dataType":"ENUM","values":["on","off"]},{"name":"text","currentValue":"2","dataType":"STRING"}],"capabilities":["Actuator","Notification","SwitchLevel",{"attributes":[{"name":"level","dataType":null}]},"Switch",{"attributes":[{"name":"switch","dataType":null}]},"Sensor","SpeechSynthesis"],"commands":["deviceNotification","off","on","setLevel","setNumber","setText","speak"]}

{"id":"1796","name":"Presence - All Home (Virtual)","label":"Presence - All Home (Virtual)","type":"Virtual Values","room":null,"attributes":[{"name":"number","currentValue":100,"dataType":"NUMBER"},{"name":"level","currentValue":100,"dataType":"NUMBER"},{"name":"text","currentValue":"2","dataType":"STRING"},{"name":"switch","currentValue":"off","dataType":"ENUM","values":["on","off"]}],"capabilities":["Actuator","Notification","SwitchLevel",{"attributes":[{"name":"level","dataType":null}]},"Switch",{"attributes":[{"name":"switch","dataType":null}]},"Sensor","SpeechSynthesis"],"commands":["deviceNotification","off","on","setLevel","setNumber","setText","speak"]}

If you parse the json to put it in a map, it won't matter what the order of the text is.

I should have been clearer. I don’t control the other system. It is Dakboard. They read in the json and load it into an array. Each time the elements move around they read it in the same order.

This is not the way they are supposed to do it but there you go. So I was trying to figure out what I could do.

Are you using Maker API to do this? Do you need all of the fields or only some?

I only need one field and I am using maker. I need the string in the text field - "2" in the case above. Is there a way to get only this information? thanks.

Is Maker sending the event to an endpoint? If so you could use an RM rule to send the value in a Get or Post as needed.

1 Like

I am not that experienced with this. I am making the call from the Dakboard system, I plug the call into their interface. I am not that familiar with using RM to do this but if you can point me to some docs I will figure it out. Thanks.

1 Like

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