Skip to content

Conversation

@DesertRatUa
Copy link

Proposed change

Additional information

Device diagnostics

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works
  • Device diagnostics data has been attached

@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.29%. Comparing base (bf73aa9) to head (ad4e265).
⚠️ Report is 5 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #4520      +/-   ##
==========================================
+ Coverage   92.24%   92.29%   +0.04%     
==========================================
  Files         369      371       +2     
  Lines       12094    12168      +74     
==========================================
+ Hits        11156    11230      +74     
  Misses        938      938              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DesertRatUa
Copy link
Author

#4489

@seanmahrt
Copy link

It looks like it's sort of working, but it seems the temp probe scaling is off. It may be a factor of 2 but I cannot tell for sure. I'm going to put it in a different location and check.

zha-01JES93Y4NY89NXK3P04DYJNK0-_TZE284_hodyryli TS0601-0a2f9ff57075b050d6b4c6364ca08d3c (1).json

@seanmahrt
Copy link

I put it out in the garage, and the two temperature lines still have the same shape, but it's not off by a factor of two. next step is put the probe in the freezer to confirm it's reading two different temperatures.

@DesertRatUa
Copy link
Author

On my device, probe temperature and general temperature are different:
image
And device was able to receive the actual time

@seanmahrt
Copy link

On my device, probe temperature and general temperature are different: image And device was able to receive the actual time

yeah, time worked OK. will know better here shortly with the two probes.

Would there be anything weird that I'm in Fahrenheit on the ZigBee device/home assistant? I would assume under the hood everything would be metric.

image

current temps on device are 14.4F and 52.1F

@seanmahrt
Copy link

seanmahrt commented Nov 30, 2025

found this: Koenkk/zigbee2mqtt#29627

looks like maybe the external probe temp needs some massaging?

            if (dpValue.datatype === 2) { // VALUE type (4-byte integer)
                if (dp === 38) {
                    // For external temperature, use signed 16-bit from last 2 bytes
                    // This supports both positive and negative temperatures
                    const uint16 = data.readUInt16BE(data.length - 2);
                    value = uint16 > 32767 ? uint16 - 65536 : uint16;

@seanmahrt
Copy link

looking more into that other PR, there was some general tidbits that seems less specific to internal/external probe:

          let value;
            // temperature
            if (dpValue.datatype === 2) {
                // Reads the data as an unsigned big-endian 32-bit integer (Negative numbers will be wrong, eg. 429496724.6)
                // value = data.readUInt32BE(0);
                // Reads the data as a signed big-endian 32-bit integer (Negative numbers will be correct)
                value = data.readInt32BE(0);
            } else if (dpValue.datatype === 4) {
                value = data[0];
            } else {
                value = data[0];
            }
            
            switch (dp) {
                // temperature
                case 1:
                    result.temperature = value / 10;
                    break;
                // humidity
                case 2:
                    result.humidity = value;
                    break;
                // battery_state
                case 3:
                    result.battery_state = value;
                    result.battery = value === 0 ? 10 : (value === 1 ? 50 : 100);
                    result.battery_low = value === 0;
                    break;
                // time_format
                case 17:
                    result.time_format = value ? '12h' : '24h';
                    break;
                // temperature_external
                case 38:
                    result.temperature_external = value / 10;
                    break;

@seanmahrt
Copy link

reading through your code, maybe you're already attempting to read it as 32bit signed. do we need to confirm big endian? ('m a python/quirk noobie)

@seanmahrt
Copy link

temps have stabilized:
image

on the display: 8.6F for the probe, 52.1 for the sensor, 57% humidity

@seanmahrt
Copy link

SOLVED: sorry about the long posts. change the /100 -> /10 for the external sensor and it looks good.

dp_id=38,
attribute_name="temperature_external",
type=t.int32s,
converter=lambda x: x / 100, # Divide by 100 to get correct temperature

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you set this to /10 it seems to work

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my device /10 is provided a temperature of 510.0 °C
What is very strange, cause in ZB2MQTT is also /10.
And the only visible reason is the Chinese random in the device firmware.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my device /10 is provided a temperature of 510.0 °C What is very strange, cause in ZB2MQTT is also /10. And the only visible reason is the Chinese random in the device firmware.

:)

@DesertRatUa
Copy link
Author

On my device, probe temperature and general temperature are different: image And device was able to receive the actual time

yeah, time worked OK. will know better here shortly with the two probes.

Would there be anything weird that I'm in Fahrenheit on the ZigBee device/home assistant? I would assume under the hood everything would be metric.
image

current temps on device are 14.4F and 52.1F

I was trying to switch my device to F, and got the same values. So looks like, under the hood, it's still metric and uses UI conversion.

@DesertRatUa
Copy link
Author

result.time_format = value ? '12h' : '24h';

I'm also trying to get DP17 for the time format, but my device never sends it.

@DesertRatUa
Copy link
Author

After reboot (change of batteries), my device started sending probe temperature in the same way as @seanmahrt, so I changed multiplayer to 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tuya Request/PR regarding a Tuya device

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants