Adding a library - Yeelight

If you have a question or need help, this is the place to be.
Post Reply
holdestmade
Experienced User
Posts: 138
Joined: Thu Dec 04, 2014 2:44 pm

Adding a library - Yeelight

Post by holdestmade » Mon Jul 24, 2017 7:22 pm

Just bought a Yeelight bulb which has an open API and have found this python library for it:

https://gitlab.com/stavros/python-yeelight/tree/master

is it possible to add to eventghost and if so how easy is it to do ?

Thanks

m19brandon
Experienced User
Posts: 177
Joined: Mon Feb 03, 2014 10:36 pm

Re: Adding a library - Yeelight

Post by m19brandon » Mon Jul 24, 2017 11:58 pm

You would have to write a little code.

The project you pointed too has a Readme that includes a pip install. Once you have it install locally Add the import in your Python script action and u are all set to code.

m19brandon
Experienced User
Posts: 177
Joined: Mon Feb 03, 2014 10:36 pm

Re: Adding a library - Yeelight

Post by m19brandon » Tue Jul 25, 2017 12:00 am

The readme has a usage section to. Very straightforward.

from yeelight import Bulb

bulb = Bulb("192.168.0.5")
bulb.turn_on()

User avatar
kgschlosser
Site Admin
Posts: 4209
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Adding a library - Yeelight

Post by kgschlosser » Tue Jul 25, 2017 4:02 am

you can give this a shot.


uncompress the attached zip into

if you are using EventGhost 0.5: c:\Program Files (x86)\EventGhost\lib27\site-packages
if you are using EventGhost 0.4: c:\Program Files (x86)\EventGhost\lib26\site-packages

and as m19brandon stated
then create a macro with the Python Script action and past the code below into the action make sure you replace ENTER_IP_ADDRESS_HERE with the ip address of your light

Code: Select all

IP_ADDRESS = "ENTER_IP_ADDRESS_HERE"

from yeelight import Bulb

bulb = Bulb(IP_ADDRESS)
bulb.turn_on()
Attachments
yeelight.zip
(34.62 KiB) Downloaded 78 times
If you like the work I have been doing then feel free to Image

holdestmade
Experienced User
Posts: 138
Joined: Thu Dec 04, 2014 2:44 pm

Re: Adding a library - Yeelight

Post by holdestmade » Tue Jul 25, 2017 7:32 am

That works a treat, many thanks.

I had tried to copy the Yeelight folder to site packages but didn't add the enum folder and it was causing an error stating enum not defined or something similar.

I'll give it a thorough test.

Thanks again

holdestmade
Experienced User
Posts: 138
Joined: Thu Dec 04, 2014 2:44 pm

Re: Adding a library - Yeelight

Post by holdestmade » Tue Jul 25, 2017 7:50 am

Tried this on my server that is running 0.4 and it errors (syntax). I have upgraded to 0.5 and works fine.

Is this because it is version 2.7 of python or something else ?

Cheers

m19brandon
Experienced User
Posts: 177
Joined: Mon Feb 03, 2014 10:36 pm

Re: Adding a library - Yeelight

Post by m19brandon » Tue Jul 25, 2017 11:31 am

0.5 is better. The real answer is 0.4 used its a fenced off copy of Python, where 0.5 will used all the shared libraries on your computer.

User avatar
kgschlosser
Site Admin
Posts: 4209
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Adding a library - Yeelight

Post by kgschlosser » Tue Jul 25, 2017 7:08 pm

i believe that either enum or the yeelight plugin might only be compatible with 2.7 and above. for some reason I think it might be enum. that is a copy of what I have on my machine so that is probably what is causing it.

The other thing is that there are lots of additions and upgrades to eg 0.5 with adding the ability to easily add libraries and what have you to EG. one of the things that EG 0.5 does is if you have python 2.7 installed and you install any libraries in that python installation. then EG will go and add all of those libraries to EG as well. all around 0.5 has a lot of improvements/bug fixes most of which are pretty transparent. but occasionally you will run across one of these additions/fixes that will force you to use EG 0.5. and this is one of those cases
If you like the work I have been doing then feel free to Image

Post Reply