Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative sensor values is not interpreted correctly #11

Open
atliant opened this issue Dec 7, 2023 · 6 comments
Open

Negative sensor values is not interpreted correctly #11

atliant opened this issue Dec 7, 2023 · 6 comments

Comments

@atliant
Copy link

atliant commented Dec 7, 2023

Since the outside temperature went below 0, the outdoor sensor (GT2) started to report temperatures in the ~6550 range insted of the expected negative number.

image

This is also the case for cold fluid "GT11" (and GT10?).

Sensor configuration:

  • platform: rego600
    name: Outdoor GT2
    rego_variable: 0x020A
    value_factor: 0.1
    unit_of_measurement: °C
    state_class: measurement
    accuracy_decimals: 1
@dala318
Copy link
Owner

dala318 commented Dec 8, 2023

Good find!
Could you please provide some log-printouts from ESP while reading these values. Specially if there are HEX-printouts.
I have not had time to test or even compile the linked pull-request but something in that region should fix the issue.

@atliant
Copy link
Author

atliant commented Dec 8, 2023

Should have included that in the first post..

[13:35:04][D][rego:171]: UART bus free to use
[13:35:04][D][rego:188]: Command to send: 810200041200000016
[13:35:04][D][rego:205]: No response yet, sleeping 50ms and retrying
[13:35:04][D][rego:205]: No response yet, sleeping 50ms and retrying
[13:35:04][D][rego:205]: No response yet, sleeping 50ms and retrying
[13:35:04][D][rego:205]: No response yet, sleeping 50ms and retrying
[13:35:04][D][rego:205]: No response yet, sleeping 50ms and retrying
[13:35:04][D][rego:205]: No response yet, sleeping 50ms and retrying
[13:35:04][D][rego:199]: Response received: 01037f7f03
[13:35:04][D][rego:068]: Response decoded to 65535
[13:35:04][D][sensor:094]: 'Cold fluid out GT11': Sending state 6553.50000 °C with 1 decimals of accuracy

@dala318
Copy link
Owner

dala318 commented Dec 11, 2023

I would guess the problem originates here in rego.cpp

    *result = ( (int16_t)*(response+1) << 14 ) | ( (int16_t)*(response+2) << 7 ) | (int16_t)*(response+3);
    ESP_LOGD(TAG, "Response decoded to %u", *result);

Where result is decoded as unsigned int white it should be signed.

  03 (0000 0011) << 14 = C000 (1100 0000 0000 0000)
  7F (0111 1111) << 7  = 4F80 (0011 1111 1000 0000)
  7F (0111 1111)       = 007F (0000 0000 0111 1111)
+ _________________________________________________
                         FFFF (1111 1111 1111 1111) = -1 

@atliant
Copy link
Author

atliant commented Dec 13, 2023

With that fix it looks fine!

image

[09:30:53][D][rego:171]: UART bus free to use
[09:30:53][D][rego:188]: Command to send: 810200040a0000000e
[09:30:53][D][rego:205]: No response yet, sleeping 50ms and retrying
[09:30:53][D][rego:205]: No response yet, sleeping 50ms and retrying
[09:30:53][D][rego:205]: No response yet, sleeping 50ms and retrying
[09:30:53][D][rego:199]: Response received: 01037f6915
[09:30:53][D][rego:068]: Response decoded to 4294967273
[09:30:53][D][sensor:094]: 'Outdoor GT2': Sending state -2.30000 °C with 1 decimals of accuracy

@atliant
Copy link
Author

atliant commented Dec 13, 2023

I just activated the GT3 (hot water) sensor since I haven't had that active before, in #12 it seems that it is interpreted as a negative number:

[09:36:31][D][rego:171]: UART bus free to use
[09:36:31][D][rego:188]: Command to send: 810200040b0000000f
[09:36:31][D][rego:205]: No response yet, sleeping 50ms and retrying
[09:36:31][D][rego:205]: No response yet, sleeping 50ms and retrying
[09:36:31][D][rego:205]: No response yet, sleeping 50ms and retrying
[09:36:32][D][rego:199]: Response received: 01037c1d62
[09:36:32][D][rego:068]: Response decoded to 4294966813
[09:36:32][D][sensor:094]: 'Hot water GT3': Sending state -48.30000 °C with 1 decimals of accuracy

However it is not interpreted correct in master either.

[09:40:09][D][rego:171]: UART bus free to use
[09:40:09][D][rego:188]: Command to send: 810200040b0000000f
[09:40:09][D][rego:205]: No response yet, sleeping 50ms and retrying
[09:40:09][D][rego:205]: No response yet, sleeping 50ms and retrying
[09:40:09][D][rego:205]: No response yet, sleeping 50ms and retrying
[09:40:09][D][rego:199]: Response received: 01037c1d62
[09:40:09][D][rego:068]: Response decoded to 65053
[09:40:09][D][sensor:094]: 'Hot water GT3': Sending state 6505.30029 °C with 1 decimals of accuracy

@dala318
Copy link
Owner

dala318 commented Feb 6, 2024

Looking at the raw readouts from my H66 Husdata device it seem that -48.3 deg is some default value for sensors not available
So may have to add some logic that sets the entities to unavailable or something when this value is received.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants