Hi,
I discovered this nice project of yours and was playing around with it to see if I could control my thermostats. Doing so I noticed that the two's complement conversion for sensor values is wrong for negative numbers. Probably not a huge issue as most sensors will report positive numbers, but the whole function can be fixed by using Python's built-in conversion (int.from_bytes).
Hi, I discovered this nice project of yours and was playing around with it to see if I could control my thermostats. Doing so I noticed that the two's complement conversion for sensor values is wrong for negative numbers. Probably not a huge issue as most sensors will report positive numbers, but the whole function can be fixed by using Python's built-in conversion (
int.from_bytes
).Example with 1585:
Example with -1585:
Using one bit for the sign, 64207 is too large to be represented in two bytes.