Skip to content

Commit

Permalink
Air Conditioning Companion: Fix some conversion issues (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi authored Jan 5, 2019
1 parent 4e61fa0 commit 2564753
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions miio/airconditioningcompanion.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,32 +144,32 @@ def air_condition_brand(self) -> int:
"""
Brand of the air conditioner.
Known brand ids (int) are 0182, 0097, 0037, 0202, 02782, 0197, 0192.
Known brand ids are 0x0182, 0x0097, 0x0037, 0x0202, 0x02782, 0x0197, 0x0192.
"""
return int(self.air_condition_model[2:4].hex())
return int(self.air_condition_model[2:4].hex(), 16)

@property
def air_condition_remote(self) -> int:
"""
Known remote ids (int):
Known remote ids:
80111111, 80111112 (brand: 182)
80222221 (brand: 97)
80333331 (brand: 37)
80444441 (brand: 202)
80555551 (brand: 2782)
80777771 (brand: 197)
80666661 (brand: 192)
0x80111111, 0x80111112 (brand: 0x0182)
0x80222221 (brand: 0x0097)
0x80333331 (brand: 0x0037)
0x80444441 (brand: 0x0202)
0x80555551 (brand: 0x2782)
0x80777771 (brand: 0x0197)
0x80666661 (brand: 0x0192)
"""
return int(self.air_condition_model[4:8].hex())
return int(self.air_condition_model[4:8].hex(), 16)

@property
def state_format(self) -> int:
"""
Version number of the state format.
Known values (int) are: 01, 02, 03
Known values are: 1, 2, 3
"""
return int(self.air_condition_model[8])

Expand Down
8 changes: 4 additions & 4 deletions miio/tests/test_airconditioningcompanion.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ def test_status(self):
bytes.fromhex('010500978022222102')
assert self.state().model_format == 1
assert self.state().device_type == 5
assert self.state().air_condition_brand == 97
assert self.state().air_condition_remote == 80222221
assert self.state().air_condition_brand == int('0097', 16)
assert self.state().air_condition_remote == int('80222221', 16)
assert self.state().state_format == 2
assert self.state().air_condition_configuration == '020119A2'
assert self.state().target_temperature == 25
Expand Down Expand Up @@ -287,8 +287,8 @@ def test_status(self):
bytes.fromhex('010507950000257301')
assert self.state().model_format == 1
assert self.state().device_type == 5
assert self.state().air_condition_brand == 795
assert self.state().air_condition_remote == 2573
assert self.state().air_condition_brand == int('0795', 16)
assert self.state().air_condition_remote == int('00002573', 16)
assert self.state().state_format == 1
assert self.state().air_condition_configuration == '10011601'
assert self.state().target_temperature == 22
Expand Down

0 comments on commit 2564753

Please sign in to comment.