TheAgentK / tuya-mqtt

Nodejs-Script to combine tuyaapi and openhab via mqtt
MIT License
173 stars 80 forks source link

Manually turning on the Tuya device will receive both on and off #9

Closed seedzhoukang closed 5 years ago

seedzhoukang commented 5 years ago

image I'll receive on and off at the same time when I manually turn on the Tuya device, and I'll receive off and off when I turn off the device.

I don't know if I'm the only one with this error, here's the code I found the problem with:

TuyaDevice.onAll('data', function (data) {
    try {
        debugTuya('Data from device ' + this.type + ' :', data);
        var status = data.dps['1'];
        if (this.type == "lightbulb" && status == undefined) {
            status = true;
        }
        publishStatus(this, bmap(status));
        publishDPS(this, data.dps);
    } catch (e) {
        debugError(e);
    }
});

data will receive two times the metadata {"1": true} and {"11": 0}, which will cause the status to produce a undefined

When I judge status as undefined, I do nothing to solve the above problems.

TheAgentK commented 5 years ago

This should be the same error as in error #11

Duplicate of #11