Decoding status
Vicepredator opened this issue · comments
Hello,
how can i decode the response of the get_status function?
The response of get_status are bytes.
If you see something like this:
<bound method MagicHomeApi.get_status of <magichome.MagicHomeApi object at 0x0204EB70>>
It's because you used controller1.get_status instead of controller1.get_status()
I'm using get_status() but I can't understand what I receive back, is there a way to understand the bytes sequence?
Same here. I'm using also get_status() but don´t know what bytes sequence this is?
Any Idea?
Yeah. Check out my Hubitat drivers' parse functions to determine what the different bytes are until I can transition and test this properly. I need to update this library to determine the device type that's sent back, and parse information as Power/FX/RGB/CCT properly.
I've wrote these 2 basic functions to the MagicHomeApi class for the RGB devices i'm using (device_type 0) : https://aliexpress.com/item/4001094549543.html ; Variant 4PIN RGB
is_on() returns true if the device is on.
get_color() returns the color in HTML format (#ff0000 for red)
Untested with any other device type so YMMV
def get_color(self):
_bytes = bin(int(self.get_status().hex(),16))[50:74]
_hex = hex(int(_bytes,2)).split('x')
while(len(_hex[1])!=6) :
_hex[1] = '0'+_hex[1]
return '#'+_hex[1]
def is_on(self):
return bin(int(self.get_status().hex(),16))[98:102] == '1111'