adamkempenich / magichome-python Goto Github PK
View Code? Open in Web Editor NEWMagicHome Wifi protocol for python.
License: MIT License
MagicHome Wifi protocol for python.
License: MIT License
In the readme file, it is writen to use the MagicHomeAPi()
method, which isn't defined. Shouldn't it be the __init__()
method instead?
For __init__(self, device_ip, device_type, keep_alive=True)
, what am I suposed to enter for self
and keep_alive=True
?
UPDATE: Sorry, I never worked with Python before. I found the solution for my problem now
I was able to get everything to work apart turn_on
and turn_off
which aren't working with my RGB-LED-Strip.
I'm able to change the color but not to turn it on or off
I continue to get the socket.error when trying to do anything with the bulb
import MagicHomeApi
bulb = MagicHomeApi.MagicHomeApi('xx.xx.x.xxx',2)
bulb.get_status()
Establishing connection with the device.
Caught exception socket.error : timed out
Traceback (most recent call last):
File "c:\Users\User\Documents\Code\Python\MagicHome\DemoBulb", line 6, in
Caught exception socket.error : [Errno 9] Bad file descriptor
bulb.get_status()
File "c:\Users\User\Documents\Code\Python\MagicHome\MagicHomeApi.py", line 50, in get_status
return self.s.recv(15)
File "C:\Python27\lib\socket.py", line 174, in _dummy
raise error(EBADF, 'Bad file descriptor')
socket.error: [Errno 9] Bad file descriptor
Hello there. I have type 0 lights, normal RGB light strips with the magic home wifi controller. I'm running the API through Visual Studio just as a test as I'm trying to do bigger and better things with it once I get it working. I'm able to turn the lights on and off thanks to a comment from another issue that solved my issue of them not turning off or on (Change to if self.device_type <= 1:). Now I'm running into an issue with the RGB request not working. This is my code:
`import time
from MagicHomeAPI import MagicHomeApi
controller1 = MagicHomeApi('192.168.0.142',0)
controller1.get_status()
controller1.turn_on()
controller1.update_device(0,255,255)
If I check the path of controller1.update_device(0,255,255) in visual studio it returns:
(method) update_device: (r=0, g=0, b=0, white1=None, white2=None) -> None`
I don't even know where to start on this one as I've looked over update_device and I can't see how the variables are not reaching message = [0x31, r, g, b, white1, 0x00, 0x0f]. I would appreciate the help, thank you.
Btw, I'm also using Python 3.8.10, hints the need for changing the self.device_type to <=1:.
When I use the update_device command, my led stripes switch color, but they are just fading. So could you pease change/add the function that it jumps directly to that specific color, just like in jumpColor mode (or however it is called)
I hope I'll get a Reply soon, even if this Api is a bit older...
Greetings Felix
Edit: I would also liike to know if you are working on the "tasks" from the main page or if this project is like more´or less completely dead.
So I cloned the repo, was able to get the connection working between lights.
I have been able to turn the lights on and off. However, I am unable to set the RGB lighting with the color numbers.
I am able to set the white hue from 'soft' to 'cool'.
So what am I doing wrong.
sample code:
from magichome import MagicHomeApi
controller1 = MagicHomeApi('XXX.XXX.XXX.XXX',3,True)
controller1.get_status()
output: b'\x815#a\x01\x01\x00\x00\x00\x00\x07\xf0\x0fB'
controller1.update_device(0,0,255)
result: 'Cool' white light appears.
Any thoughts?
Hello,
how can i decode the response of the get_status function?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.