Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
12.16k stars 1.68k forks source link

Device TS0601 _TZE204_xnbkhhdr temperature calibration changes over time #24758

Open alexsotoaguilera opened 4 days ago

alexsotoaguilera commented 4 days ago

What happened?

First I set local_temperature_calibration to -1,7

"local_temperature_calibration": -1.7,

After a while, reports another value.

"local_temperature_calibration": 6551.9,

What did you expect to happen?

local_temperature_calibration do not changes over time

How to reproduce it (minimal and precise)

No response

Zigbee2MQTT version

1.41.0 commit: cc31cea

Adapter firmware version

7.4.4 [GA]

Adapter

ZBDongle-E

Setup

plain on intel NUC

Debug log

No response

alexsotoaguilera commented 3 days ago

This problem spam HomeAssistant log with messages:

2024-11-13 10:26:17.322 ERROR (MainThread) [homeassistant.components.mqtt.number] Invalid value for number.0xa4c13886f0588a04_local_temperature_calibration: 6550.9 (range -9.9 - 9.9) 2024-11-13 10:26:17.473 ERROR (MainThread) [homeassistant.components.mqtt.number] Invalid value for number.0xa4c13886f0588a04_local_temperature_calibration: 6550.9 (range -9.9 - 9.9) 2024-11-13 10:26:18.652 ERROR (MainThread) [homeassistant.components.mqtt.number] Invalid value for number.0xa4c13886f0588a04_local_temperature_calibration: 6550.9 (range -9.9 - 9.9) 2024-11-13 10:27:12.903 ERROR (MainThread) [homeassistant.components.mqtt.number] Invalid value for number.0xa4c13886f0588a04_local_temperature_calibration: 6550.9 (range -9.9 - 9.9) 2024-11-13 10:27:13.052 ERROR (MainThread) [homeassistant.components.mqtt.number] Invalid value for number.0xa4c13886f0588a04_local_temperature_calibration: 6550.9 (range -9.9 - 9.9)

To avoid the problem I add this conf for the device:

'0xa4c13886f0588a04': friendly_name: Thermostat - Dining Room filtered_attributes:

And disabled the entity in homeassistant.

alexsotoaguilera commented 2 days ago

I am investigating the code but I still don't quite understand how it is structured. I found my device definition in ‘https://github.com/Liionboy/zigbee-herdsman-converters/blob/master/src/devices/tuya.ts’ and the driver definition of the value in ‘https://github.com/Liionboy/zigbee-herdsman-converters/blob/master/src/lib/tuya.ts’.

----> devices/tuya.ts [19, 'local_temperature_calibration', tuya.valueConverter.localTempCalibration3],

----> src/lib/tuya.ts

localTempCalibration1: {
    from: (v: number) => {
        if (v > 55) v -= 0x100000000;
        return v / 10;
    },
    to: (v: number) => {
        if (v > 0) return v * 10;
        if (v < 0) return v * 10 + 0x100000000;
        return v;
    },
},
localTempCalibration2: {
    from: (v: number) => v,
    to: (v: number) => {
        if (v < 0) return v + 0x100000000;
        return v;
    },
},

localTempCalibration3: {
    from: (v: number) => {
        if (v > 0x7fffffff) v -= 0x100000000;
        return v / 10;
    },
    to: (v: number) => {
        if (v > 0) return v * 10;
        if (v < 0) return v * 10 + 0x100000000;
        return v;
    },
},

I will play with these values to see if I can get it to behave as expected.

alexsotoaguilera commented 2 days ago

It does not work with any of the 3 available converters. It is as if the value I set initially modifies the local temperature correctly, but the value reported in local_temperature_calibration changes over time and is incorrect.

local_temperature: 21,3 (with the initial offset "-1,7" correctly applied) local_temperature_calibration: -429490177.7, (the offset "-1,7" is transformed in this number)

:(