vinodsr / node-red-contrib-tuya-smart-device

a node-red module for managing tuya smart devices
https://flows.nodered.org/node/node-red-contrib-tuya-smart-device
MIT License
47 stars 15 forks source link

An unusual response - 2 #129

Open msillano opened 1 year ago

msillano commented 1 year ago

This time the anomalous response is again provided by a gateway, but this time a BLE gateway (model ZXGWS-04).

The format is as follows:

payload:{
    deviceId: "123456789",
    deviceName: "BLE MESH(SIG)Gateway",
    data: {
        reqType: "subdev_online_stat_report",
        data: {
             offline: [ "987654321"]
    }}}

It is a new format, which differs from the previous one (see ISSUE#117).


Workaround:

A 'function node' acts like a filter:

if (typeof msg.payload.data.reqType  != "undefined") {
     msg.payload.data['dps'] = {
          [msg.payload.data.reqType]:msg.payload.data.data
           }  }
return msg;

producing a standard output message:

msg.payload:{     
       deviceId: "123456789",
       deviceName: "BLE MESH(SIG)Gateway",
       data: {
            "dps":{
                "subdev_online_stat_report": {
                       offline: [ "987654321"],
                       ...
                       }
            }}}

that uses the ad-hoc "subdev_online_stat_report" DP, having as value an object.

stale[bot] commented 11 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.