Skip to content

error in computing room_temp_adj #232

@uspass

Description

@uspass

I reckon there's an error in computing room_temp_adj, line 645 and following.

data['room_temp_adj'] = ((payload[13] << 8) + payload[14])/2.0

Suppose stored adj is negative, that is, for example
payload[13] =0xFF
payload[14] = 0xFA

Thus
adj = 0xFFFA

You divide it by 2.0, and obviously the result is always less than 0x7FFF = 32767.
When the stored adj is positive it is always less than 0x7FFF = 32767

Consequently the next line:

if data['room_temp_adj'] > 32767:

will always produce False and the next line

data['room_temp_adj'] = 32767 - data['room_temp_adj']

will never happen.

A correct version of the code would be:

data['room_temp_adj']  = (_response[13] << 8) + _response[14]
if data['room_temp_adj']  > 0x7FFF:
    data['room_temp_adj']  =data['room_temp_adj']  - 0x10000
data['room_temp_adj']  = data['room_temp_adj']  / 2.0

cheers,
us

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions