Zwavejs2mqtt: [feat] Add some kind of transaction id to API responses

Created on 19 Jan 2021  路  8Comments  路  Source: zwave-js/zwavejs2mqtt

Is your feature request related to a problem? Please describe.
When issuing getNodes or similar over MQTT, it can take a long time to get a response. Likewise, when issuing many commands over MQTT, like setValue or getAssociations, it can be tricky to seperate requests from responses, since the responses all look alike. At least for those with arguments, one can compare the arguments to verify it's what we wanted..

Describe the solution you'd like
Add another value to requests, which is optional, and merely echoed back on responses. Like transaction, id or token.

Sent:

zwavejs2mqtt/_CLIENTS/ZWAVE_GATEWAY-HomeMQTT/api/getAssociations/set
{"args":[10,20],"token":"abc"}

Response:

zwavejs2mqtt/_CLIENTS/ZWAVE_GATEWAY-HomeMQTT/api/getAssociations
{"args":[10,20],"token":"abc","data":{..some data..}}

This way a client can create their own identifier and match up responses.

Describe alternatives you've considered
I'm currently comparing arguments, but comparing json objects is cumbersome, at least in .NET.

Additional context
N/A

enhancement

All 8 comments

Absolutely! Nice idea :)

@LordMike Ready :rocket:

Wouldn't this still require me to compare json objects? :)

@LordMike If you add an id to the request message, you will find the same id in the response payload origin.id

Oh.. You're right.

馃憤

That means args are duplicated :D ... origin.args & args

Yep was to keep back compatibility but I could remove it

Yep was to keep back compatibility but I could remove it

Entirely up to you. I'm satisfied :)

Was this page helpful?
0 / 5 - 0 ratings