drndos / mikettle

Xiaomi Mi Kettle Bluetooth Library
MIT License
54 stars 23 forks source link

strange value (non-hex) in DEBUG parse data #8

Open thymjan opened 4 years ago

thymjan commented 4 years ago

Output from demo.py

...
DEBUG:mikettle.mikettle:Parse data: b'\x00\xff\x00\x00PJ\x01\x00\x00\x01\x18\x00'
DEBUG:mikettle.mikettle:data parsed {'action': 'idle', 'mode': 'none', 'set temperature': 80, 'current temperature': 74, 'keep warm type': 'cool down', 'keep warm time': 0}
...

In the fourth byte-data there are non-hex characters. Must be the data for the temperature, is it?

    def _parse_data(self, data):
        """Parses the byte array returned by the sensor."""
        res = dict()
        res[MI_ACTION] = MI_ACTION_MAP[int(data[0])]
        res[MI_MODE] = MI_MODE_MAP[int(data[1])]
        res[MI_SET_TEMPERATURE] = int(data[4])
        res[MI_CURRENT_TEMPERATURE] = int(data[5])
        res[MI_KW_TYPE] = MI_KW_TYPE_MAP[int(data[6])]
        res[MI_KW_TIME] = MiKettle.bytes_to_int(data[7:8])
        return res