Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

[MOVED] TP-Link Smart Plug

If you have a question or need help, this is the place to be.
Post Reply
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

[MOVED] TP-Link Smart Plug

Post by Flyingsubs »

This topic has been moved to the plugins support section

viewtopic.php?f=9&t=9687&p=46213#p46213



Anyone mess around with them for eventghost? I got a python script from some website to make WEMO switches work which is great! The TP-Link device seems to perform a lot better, but I dont have an easy way to control with EG.

There is a python script from a website that i am unable to modify because i do not know how. Any chance someone could help/teach me? Looking to learn more python. :)

https://github.com/GadgetReactor/pyHS100
Last edited by Flyingsubs on Wed May 31, 2017 12:49 am, edited 1 time in total.
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: TP-Link Smart Plug

Post by kgschlosser »

well lets start out with the first step and see if the software you found will even run in EG


go to that github site and download the software as a zip file.

you will only want to decompress the folder named pyHS100 into this directory if you are using EG 0.5 c:\program files (x86)\eventghost\lib27\site-packages and if you are using EG 0.4 c:\program files (x86)\eventghost\lib26\site-packages

then start EG and create a new macro with a Python Script as an action and copy and paste the code below into the PythonScript action. apply and ok the dialog.. then right click the newly created PythonScript and click on execute and see if anything comes up in the log

Code: Select all

from pprint import pformat
from pyHS100 import TPLinkSmartHomeProtocol

for dev in TPLinkSmartHomeProtocol.discover(timeout=10):
    print "Found device: %s" % pformat(dev)
If you like the work I have been doing then feel free to Image
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: TP-Link Smart Plug

Post by Flyingsubs »

Thanks for the quick reply!! So i put the decompressed folder where you told me to. I assume i can keep all the files in that folder?

I recieved an error when performing that action

12:56:47 Traceback (most recent call last):
12:56:47 Python script "22", line 3, in <module>
12:56:47 from pyHS100 import TPLinkSmartHomeProtocol
12:56:47 File "C:\Program Files (x86)\EventGhost\lib26\site-packages\pyHS100\__init__.py", line 2, in <module>
12:56:47 from .smartplug import SmartPlug
12:56:47 File "C:\Program Files (x86)\EventGhost\lib26\site-packages\pyHS100\smartplug.py", line 4, in <module>
12:56:47 from .pyHS100 import SmartDevice
12:56:47 SyntaxError: invalid syntax (pyHS100.py, line 79)


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

Re: TP-Link Smart Plug

Post by kgschlosser »

Yes you keep all the files.

I am thinking that it is coded for Python 3 let me go through the library and convert it over if I can
If you like the work I have been doing then feel free to Image
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: TP-Link Smart Plug

Post by Flyingsubs »

Wow thanks so much! I really want to learn Python since it seems really cool and i'm starting to get more an more technical.
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: TP-Link Smart Plug

Post by Flyingsubs »

is converting a hard task? I assume 3.0 isn't backwards compatible or that eg isn't in 3.0 so it makes it difficult.
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: TP-Link Smart Plug

Post by kgschlosser »

EG uses Python 2.7 32 bit.

And no they are not backwards compatable. Because the error is a syntax error the issue is probably going to be how they did some like creating a dictionary.
If you like the work I have been doing then feel free to Image
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: TP-Link Smart Plug

Post by Flyingsubs »

Hmm, so do you think you can convert it? Or is that really hard? I tried running this script through cmd prompt and I couldn't even get that to work either. I was thinking I could modify the script and have eventghost just run a program. I was hoping running TP-Link commands would be easy. I was able to get a WEMO script working but TP-Link is way more reliable. I wonder if anyone on this forum has gotten it to work.

I really appreciate your help!

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

Re: TP-Link Smart Plug

Post by kgschlosser »

here is what i want you to do...

remove the library from your EG site-packages folder

download the attached file and uncompress all of the contents into the site-packages folder.

give that a shot and see what happens
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: TP-Link Smart Plug

Post by kgschlosser »

this does load properly in EG. 0.5-rc2.

so importing the module into a python script does work. I have no means to test the thing to make sure it works beyond just importing it so that is what you will do.. uncompress that file and run that python script again
If you like the work I have been doing then feel free to Image
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: TP-Link Smart Plug

Post by Flyingsubs »

I ran it and got this error


19:07:54 Traceback (most recent call last):
19:07:54 Python script "20", line 2, in <module>
19:07:54 from pyHS100 import TPLinkSmartHomeProtocol
19:07:54 File "C:\Program Files (x86)\EventGhost\lib26\site-packages\pyHS100\__init__.py", line 4, in <module>
19:07:54 from pyHS100.pyHS100 import SmartBulb, SmartPlug, TPLinkSmartHomeProtocol, SmartPlugException
19:07:54 SyntaxError: invalid syntax (pyHS100.py, line 240)


This is very exciting! Thank you for your continued help! I am running EG .04.1r1722. Does that matter?
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: TP-Link Smart Plug

Post by kgschlosser »

upgrade to EG 0.5 rc2

make sure you backup your EventGhost folder in c:\Program Files (x86) first.. do a simple copy and paste of the whole EG folder. And in the path bar at the top of Windows Explorer (File Explorer) type in %appdata% and press enter and copy the EventGhost folder in there as well. because the program files folder and the one in app data have the same name I would make a folder on my desktop called EG Backup and in that folder make a new folder called Config put the program files EventGhost folder into the EG Backup folder and put the EventGhost folder from the %appdata% into the EG Backup\Config folder. then you can do the installation.. this is just incase something goes wierd. we haven't had any recent issues of this but if it does happen I don't want you to lose anything.


you can get the latest release here
https://github.com/EventGhost/EventGhos ... v0.5.0-rc2
If you like the work I have been doing then feel free to Image
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: TP-Link Smart Plug

Post by Flyingsubs »

Succefully updated and backed up eventghost. I moved the files you sent me into the lib27 instead of the lib26 folder. This is now the error i am receiving. Thanks!

21:12:35 Traceback (most recent call last):
21:12:35 Python script "20", line 2, in <module>
21:12:35 from pyHS100 import TPLinkSmartHomeProtocol
21:12:35 File "C:\Python27\Lib\site-packages\pyhs100-0.2.4.2-py2.7.egg\pyHS100\__init__.py", line 2, in <module>
21:12:35 from .smartplug import SmartPlug
21:12:35 File "C:\Python27\Lib\site-packages\pyhs100-0.2.4.2-py2.7.egg\pyHS100\smartplug.py", line 4, in <module>
21:12:35 from .pyHS100 import SmartDevice
21:12:35 SyntaxError: invalid syntax (pyHS100.py, line 65)
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: TP-Link Smart Plug

Post by kgschlosser »

ok whoever coded that had one strange way of doing imports

So i corrected it.. You will need to delete the pyHS100 folder ffrom the lib27/site-packages folder

uncompress the attached zip into the lib27/site-packages folder if prompted to overwrite go ahead and do so
If you like the work I have been doing then feel free to Image
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: TP-Link Smart Plug

Post by Flyingsubs »

ok! followed your instructions sir. What do you think?


23:39:47 Traceback (most recent call last):
23:39:47 Python script "20", line 2, in <module>
23:39:47 from pyHS100 import TPLinkSmartHomeProtocol
23:39:47 File "C:\Python27\Lib\site-packages\pyhs100-0.2.4.2-py2.7.egg\pyHS100\__init__.py", line 2, in <module>
23:39:47 from .smartplug import SmartPlug
23:39:47 File "C:\Python27\Lib\site-packages\pyhs100-0.2.4.2-py2.7.egg\pyHS100\smartplug.py", line 4, in <module>
23:39:47 from .pyHS100 import SmartDevice
23:39:47 SyntaxError: invalid syntax (pyHS100.py, line 65)
Post Reply