Closed hzulla closed 1 year ago
https://github.com/www-ShapeLabs-de/Judo-i-soft-save-plus-to-mqtt-bridge/blob/9ea6f6145c0fc38f97e52bdf989079c6f3950e3e/python/getjudo.py#L214-L215
Hi,
this is an artefact from converting a little endian hex string. It may be more readable to do it this way:
def le_hex_to_int(hexstring): # convert little endian hex to integer return int.from_bytes(bytes.fromhex(hexstring), byteorder='little') # ... total_water.value = float(le_hex_to_int(val[0:8])/1000
and accordingly for the other little endian hex strings used in the code.
Thank you, that's a good idea to use a small function for this. My code has grown from a test where I do this manually. At some point you get used to it and overlook that it can be done more elegantly :-D
https://github.com/www-ShapeLabs-de/Judo-i-soft-save-plus-to-mqtt-bridge/blob/9ea6f6145c0fc38f97e52bdf989079c6f3950e3e/python/getjudo.py#L214-L215
Hi,
this is an artefact from converting a little endian hex string. It may be more readable to do it this way:
and accordingly for the other little endian hex strings used in the code.