[Tuya ZWT198/ZWT100-BH] Thermostat's local temperature calibration value out of range after some time
What happened?
I have local temperature calibration value set to -0.1 and after some undisclosed time this value changes by itself to 6553.5 and I get an error in logs:
Invalid value for number.termostat_local_temperature_calibration: 6553.5 (range -9.9 - 9.9)
What did you expect to happen?
Value of calibration should stay as set
How to reproduce it (minimal and precise)
No response
Zigbee2MQTT version
2.0.0-2
Adapter firmware version
20230507
Adapter
zStack3x0 Sonoff dongle P
Setup
Hass OS on PI 4
Debug log
Invalid value for number.termostat_local_temperature_calibration: 6553.5 (range -9.9 - 9.9)
Looks like I am no the only one having this issue https://github.com/Koenkk/zigbee2mqtt/issues/24943 and https://github.com/Koenkk/zigbee2mqtt/issues/24758. I open new one cause old ones are stale or closed...
Just like it was mentioned in https://github.com/Koenkk/zigbee2mqtt/issues/24758#issuecomment-2477275989 wrong code is in https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/devices/tuya.ts and https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/lib/tuya.ts
IMHO There is a mistake in this code:
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;
},
},
What is working for me is just:
return v * 10; in to method....
or simply use other converter ie. tuya.valueConverter.divideBy10
@alexsotoaguilera can You check it out?
@alexsotoaguilera can You check it out?
is the change?
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; }, },
for this?
localTempCalibration3: { return v * 10; },
....
in order not to break anything, you could create a new converter that returns ‘return v * 10;’ with a new index ‘localTempCalibration4’.
Like I said. IMHO there is one: tuya.valueConverter.divideBy10
UPDATE. I think I know how those converters should work....more or less like that I guess:
output = from(to(input))
and for input -0.1 output is -0.1 in my app written is typeScript and angular. TO be more precise. to generates value 4294967295 and from(4294967295) is -0.1
So I don't know what the problem is :(
I have exactly the same problem. The value is first set correctly but after a random time it transforms to this big invalid number.
Same problem here
Is there anyway to solve this issue?
still happening, don't stale
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days
still exists
Same problem on another Tuya Device : _TZE204_xnbkhhdr
Model [ZWT198/ZWT100-BH] (https://www.zigbee2mqtt.io/devices/ZWT198_ZWT100-BH.html#tuya-zwt198%252Fzwt100-bh)
Zigbee2MQTT 2.6.0
Logger: homeassistant.components.mqtt.number Source: components/mqtt/number.py:184 Integration: MQTT (documentation, issues) First seen: 1 Aug 2025 at 20:32:26 (34155 occurrences) Last logged in: 00:27:55
Invalid value for number.termostat_local_temperature_calibration: 6553.2 (range -9.9 - 9.9)
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days
Do not stale, please. Not relatives lresolved yet
I replace with this code and it works for me
localTempCalibration4: {
from: (v) => {
if (v > 0x7fff)
v-= 0x10000;
return v / 10;
},
to: (v) => {
if (v > 0)
return v * 10;
if (v < 0)
return v * 10 + 0x100000000;
return v;
},
@chay150 can You open PR with this change?
@chay150 can You open PR with this change?
Sorry, I have no knowledge on git, I don't know how to do it. I modified the code directly on my running zigbee2mqtt in two tuya.js files.
You add localTempCalibration4, but in the original file there are 1,2 and 3, so it makes no sense for the device to use 4.
Are you sure you haven't overwritten an existing one?
{code}
selfTestResult: valueConverterBasic.lookup({checking: 0, success: 1,
failure: 2, others: 3}),
lockUnlock: valueConverterBasic.lookup({LOCK: true, UNLOCK: false}),
localTempCalibration1: {
from: (v: number) => {
// biome-ignore lint/style/noParameterAssign: ignored using
--suppress
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) => {
// biome-ignore lint/style/noParameterAssign: ignored using
--suppress
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;
},
},
{code}
El mié, 29 oct 2025 a las 16:57, chay150 @.***>) escribió:
chay150 left a comment (Koenkk/zigbee2mqtt#26157) https://github.com/Koenkk/zigbee2mqtt/issues/26157#issuecomment-3462424263
@chay150 https://github.com/chay150 can You open PR with this change?
Sorry, I have no knowledge on git, I don't know how to do it. I modified the code directly on my running zigbee2mqtt in two tuya.js files.
— Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/26157#issuecomment-3462424263, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGHGWXFUUSHGPBDDNOCGPV332DPXDAVCNFSM6AAAAABWML3L3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTINRSGQZDIMRWGM . You are receiving this because you were mentioned.Message ID: @.***>
from what I've found the device sent this data in an 16 bits integer so for -1 you get 65535, -2 65534 and so on and the existing function #3 test on an 32 bits integer
Zigbee2mqtt version 2.6.1 commit: d44463a3 zigbee-herdsman-converters version 25.14.0 zigbee-herdsman version 6.0.4
there are 2 tuya.js files :
./node_modules/.pnpm/[email protected]/node_modules/zigbee-herdsman-converters/dist/lib/tuya.js
./node_modules/.pnpm/[email protected]/node_modules/zigbee-herdsman-converters/dist/devices/tuya.js
I added localTempCalibration4 in dist/lib
node_modules/.pnpm/[email protected]/node_modules/zigbee-herdsman-converters/dist/lib# diff tuya.js tuya.save
768,782d767
< localTempCalibration4: {
< from: (v) => {
< // biome-ignore lint/style/noParameterAssign: ignored using `--suppress`
< if (v > 0x7fff)
< v-= 0x10000;
< return v / 10;
< },
< to: (v) => {
< if (v > 0)
< return v * 10;
< if (v < 0)
< return v * 10 + 0x100000000;
< return v;
< },
< },
2533c2518
< //# sourceMappingURL=tuya.js.map
---
> //# sourceMappingURL=tuya.js.map
\ No newline at end of file
and modified the one in dist/devices to call localTempCalibration4
node_modules/.pnpm/[email protected]/node_modules/zigbee-herdsman-converters/dist/devices# diff tuya.js tuya.save
8513,8514c8513
< //[19, "local_temperature_calibration", tuya.valueConverter.localTempCalibration3],
< [19, "local_temperature_calibration", tuya.valueConverter.localTempCalibration4],
---
> [19, "local_temperature_calibration", tuya.valueConverter.localTempCalibration3],
18501c18500
< //# sourceMappingURL=tuya.js.map
---
> //# sourceMappingURL=tuya.js.map
\ No newline at end of file