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

Re: TP-Link Smart Plug

Post by Flyingsubs »

Also this happened too

23:42:16 Traceback (most recent call last) (0.5.0-rc2):
23:42:16 File "C:\Program Files (x86)\EventGhost\eg\Classes\MainFrame\LogCtrl.py", line 243, in OnGetItemTextWithTime
23:42:16 indent * self.indent +
23:42:16 PyAssertionError: C++ assertion "m_menuDepth > 0" failed at ..\..\src\msw\toplevel.cpp(1544) in wxTopLevelWindowMSW::DoSendMenuOpenCloseEvent(): No open menus?
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: TP-Link Smart Plug

Post by Flyingsubs »

I also get this error on start up if this is helpful.. I think its from a different plugin that i can probably disable.

23:39:30 Error reading help file C:\Program Files (x86)\EventGhost\plugins\EGAppControl\LogMonitor.html, error=Invalid mode ('rtb')
23:39:30 Traceback (most recent call last) (0.5.0-rc2):
23:39:30 File "C:\Program Files (x86)\EventGhost\plugins\EGAppControl\__init__.py", line 82, in GetFileAsStr
23:39:30 f = codecs.open(filepath, mode="rt", encoding="latin_1", buffering=-1)
23:39:30 File "codecs.pyc", line 896, in open
23:39:30 ValueError: Invalid mode ('rtb')
23:39:30 Error compiling script.
23:39:30 Traceback (most recent call last):
23:39:30 SyntaxError: invalid syntax (21, line 9)
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: TP-Link Smart Plug

Post by Flyingsubs »

Sorry for all the posts, but upgrading to the latest version of EG broke my EG App Control: pluggin. Anyway to fix that as well. Sorry! Thanks for the help man!
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 »

Flyingsubs wrote:ok! followed your instructions sir. What do you think?
I didn't see this before I am such a dumb dumb.

it's right there in my face.. look at the directories the error is coming from.. Not from EG by from a Python install you have and ion that python install you also have pyHS100 installed in it..

One of the cool new features of EG 0.5 is that if you do have Python installed it will include any packages/libraries you have installed into EG so you can access them from EG as well... There seems to be a little issue with it trying to load the wrong one. And I would like for this to be able to run for you without the need to have python installed... But either way it's really not a biggie.. instead of uncompressing that zip file into your EventGhost/lib27/site-packages folder you would need to uncompress it into your C:\Python27\Lib\site-packages\ folder.. careful that is a capital L in the Lib. You will have to do the following no matter what direction you want to go. I am going to need you to remove some things.

you need to delete these directories if you have them
pyhs100-0.2.4.2-py2.7.egg
pyHS100
pyHS100-0.2.4.2.dist-info

click-6.7.0-py2.7.egg
click
click-6.7.dist-info

click_datetime-0.2.0-py2.7.egg
click_datetime
click_datetime-0.2.dist-info

next you will see a file by the name of easy-install.pth open it with notepad or some text editor other then Word or Wordpad
if you see any of these entries i need you to remove them then save and close
./pyhs100-0.2.4.2-py2.7.egg
./click-6.7.0-py2.7.egg
./click_datetime-0.2.0-py2.7.egg

then go ahead and uncompress that zip file i attached in the previous post. only choose one location. either C:\Python27\Lib\site-packages\ or C:\Program Files(x86)\EventGhost\lib27\site-packages\

then it should work just fine for you.. Now I am going to address you other issues in another post
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 »

Flyingsubs wrote:Also this happened too

23:42:16 Traceback (most recent call last) (0.5.0-rc2):
23:42:16 File "C:\Program Files (x86)\EventGhost\eg\Classes\MainFrame\LogCtrl.py", line 243, in OnGetItemTextWithTime
23:42:16 indent * self.indent +
23:42:16 PyAssertionError: C++ assertion "m_menuDepth > 0" failed at ..\..\src\msw\toplevel.cpp(1544) in wxTopLevelWindowMSW::DoSendMenuOpenCloseEvent(): No open menus?
click on the view menu at the top of EG and enable and disable the Indent log as well as the Timestamps. see if that cures the issue
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 »

Flyingsubs wrote:I also get this error on start up if this is helpful.. I think its from a different plugin that i can probably disable.

23:39:30 Error reading help file C:\Program Files (x86)\EventGhost\plugins\EGAppControl\LogMonitor.html, error=Invalid mode ('rtb')
23:39:30 Traceback (most recent call last) (0.5.0-rc2):
23:39:30 File "C:\Program Files (x86)\EventGhost\plugins\EGAppControl\__init__.py", line 82, in GetFileAsStr
23:39:30 f = codecs.open(filepath, mode="rt", encoding="latin_1", buffering=-1)
23:39:30 File "codecs.pyc", line 896, in open
23:39:30 ValueError: Invalid mode ('rtb')
23:39:30 Error compiling script.
23:39:30 Traceback (most recent call last):
23:39:30 SyntaxError: invalid syntax (21, line 9)

I have searched for this EGAppControl plugin and I cannot locate the plugin to take a look. It is not on the forum and doesn't turn up in a google search. point me where to get it and I will take a look at it
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 »

Oh use this zip file instead. I forgot to add a . on an import. I am sorry about that
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 »

kgschlosser wrote:
Flyingsubs wrote:ok! followed your instructions sir. What do you think?
I didn't see this before I am such a dumb dumb.

it's right there in my face.. look at the directories the error is coming from.. Not from EG by from a Python install you have and ion that python install you also have pyHS100 installed in it..

One of the cool new features of EG 0.5 is that if you do have Python installed it will include any packages/libraries you have installed into EG so you can access them from EG as well... There seems to be a little issue with it trying to load the wrong one. And I would like for this to be able to run for you without the need to have python installed... But either way it's really not a biggie.. instead of uncompressing that zip file into your EventGhost/lib27/site-packages folder you would need to uncompress it into your C:\Python27\Lib\site-packages\ folder.. careful that is a capital L in the Lib. You will have to do the following no matter what direction you want to go. I am going to need you to remove some things.

you need to delete these directories if you have them
pyhs100-0.2.4.2-py2.7.egg
pyHS100
pyHS100-0.2.4.2.dist-info

click-6.7.0-py2.7.egg
click
click-6.7.dist-info

click_datetime-0.2.0-py2.7.egg
click_datetime
click_datetime-0.2.dist-info

next you will see a file by the name of easy-install.pth open it with notepad or some text editor other then Word or Wordpad
if you see any of these entries i need you to remove them then save and close
./pyhs100-0.2.4.2-py2.7.egg
./click-6.7.0-py2.7.egg
./click_datetime-0.2.0-py2.7.egg

then go ahead and uncompress that zip file i attached in the previous post. only choose one location. either C:\Python27\Lib\site-packages\ or C:\Program Files(x86)\EventGhost\lib27\site-packages\

then it should work just fine for you.. Now I am going to address you other issues in another post

Ok I removed all the files in my eventghost lib27 folder. I added the zip that you posted in your latest post to my C:\Python27\Lib\site-packages\

I have python installed. I don't have the additional files that you requested me to delete. Thank you for taking the time to walk through this.

For the broken plugin, i'll look where I found it. Its very nifty, takes the log messages on the left and you can manipulate them as events

Flyingsubs
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: TP-Link Smart Plug

Post by Flyingsubs »

Oh found the directory you were talking about!!


It worked!!

11:23:24 Python Script
11:23:34 Found device: {u'ip': '10.0.0.202',
11:23:34 u'port': 9999,
11:23:34 u'sys_info': {u'emeter': {u'err_code': -1,
11:23:34 u'err_msg': u'module not support'},
11:23:34 u'system': {u'get_sysinfo': {u'active_mode': u'schedule',
11:23:34 u'alias': u'Den Light',
11:23:34 u'dev_name': u'Wi-Fi Smart Plug',
11:23:34 u'deviceId': u'',
11:23:34 u'err_code': 0,
11:23:34 u'feature': u'TIM',
11:23:34 u'fwId': u'',
11:23:34 u'hwId': u'',
11:23:34 u'hw_ver': u'1.0',
11:23:34 u'icon_hash': u'',
11:23:34 u'latitude':
11:23:34 u'led_off': 0,
11:23:34 u'longitude':
11:23:34 u'mac': u'
11:23:34 u'model': u'HS100(US)',
11:23:34 u'oemId': u'',
11:23:34 u'on_time': 0,
11:23:34 u'relay_state': 0,
11:23:34 u'rssi': -71,
11:23:34 u'sw_ver': u'1.1.1 Build 160725 Rel.163650',
11:23:34 u'type': u'IOT.SMARTPLUGSWITCH',
11:23:34 u'updating': 0}}}}


Had to edit some of the data. Turns out it has my location!! haha
Last edited by Flyingsubs on Fri Apr 28, 2017 3:37 pm, edited 1 time in total.
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: TP-Link Smart Plug

Post by Flyingsubs »

I guess the question is now how do i pass data to this script? This is awesome, was the error from me playing around with this script before eventghost?


I attached the pluggin that use to work for the previous eventghost. I think i got this plugin when i was messing around with x10 devices and the motion sensor. When i use the webserver i can have this plugin find this HTTP.MLIGHTS.off and produce the same command but EG can see what it produces.


I have this event HTTP.MLIGHTS.on and this Macro that isn't firing.


Thank you so much for taking the time to help me out. This is really awesome of you. I hope to be able to do what you do someday. Where did you learn this?
Attachments
EG.png
EGAppControl.zip
(234.62 KiB) Downloaded 81 times
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 »

I changed some things in the plugin give this a try and see if it works
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 »

the plugin has already been updated to work with eg 0.5

viewtopic.php?f=9&t=3881

I did the same modification as what has already been done.. so I know it works fine
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 »

Sorry but now i'm getting this error!

17:02:55 Error compiling script.
17:02:55 Traceback (most recent call last):
17:02:55 SyntaxError: invalid syntax (21, line 9)
17:02:55 Traceback (most recent call last) (0.5.0-rc2):
17:02:55 File "wx\_core.pyc", line 16766, in <lambda>
17:02:55 File "C:\Program Files (x86)\EventGhost\eg\Core.py", line 218, in Notify
17:02:55 listener(value)
17:02:55 File "C:\Program Files (x86)\EventGhost\eg\Classes\MainFrame\TreeCtrl.py", line 806, in OnNodeSelected
17:02:55 childNode = parent.childs[pos]
17:02:55 AttributeError: 'NoneType' object has no attribute 'childs'

and I seem to have lost the pluggin information that i had before. Maybe i can copy from an Eventghost back up.


Also from my original question, do we know how to interact with the script? IE toggle the light switch on? Also if i wanted to add more lights what modifications would i need to make? Not sure if you have the answers, but you got the script working!! Thank you so much for that, you are awesome!
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: TP-Link Smart Plug

Post by Flyingsubs »

Flyingsubs wrote:Oh found the directory you were talking about!!


It worked!!

11:23:24 Python Script
11:23:34 Found device: {u'ip': '10.0.0.202',
11:23:34 u'port': 9999,
11:23:34 u'sys_info': {u'emeter': {u'err_code': -1,
11:23:34 u'err_msg': u'module not support'},
11:23:34 u'system': {u'get_sysinfo': {u'active_mode': u'schedule',
11:23:34 u'alias': u'Den Light',
11:23:34 u'dev_name': u'Wi-Fi Smart Plug',
11:23:34 u'deviceId': u'',
11:23:34 u'err_code': 0,
11:23:34 u'feature': u'TIM',
11:23:34 u'fwId': u'',
11:23:34 u'hwId': u'',
11:23:34 u'hw_ver': u'1.0',
11:23:34 u'icon_hash': u'',
11:23:34 u'latitude':
11:23:34 u'led_off': 0,
11:23:34 u'longitude':
11:23:34 u'mac': u'
11:23:34 u'model': u'HS100(US)',
11:23:34 u'oemId': u'',
11:23:34 u'on_time': 0,
11:23:34 u'relay_state': 0,
11:23:34 u'rssi': -71,
11:23:34 u'sw_ver': u'1.1.1 Build 160725 Rel.163650',
11:23:34 u'type': u'IOT.SMARTPLUGSWITCH',
11:23:34 u'updating': 0}}}}


Had to edit some of the data. Turns out it has my location!! haha

Not sure you saw this post! So awesome! I also double posted. Seems like we are getting closer!

So i tried playing around with it but couldn't get this to work from their website. I was looking at the read me here: https://github.com/GadgetReactor/pyHS100

seems like they have extra parts that are missing. In my case i should use the IP address that i got from the discover part that you built. ('10.0.0.202')

from pyHS100 import SmartPlug, SmartBulb
from pprint import pformat as pf
plug = SmartPlug("192.168.250.186")

Seems like two pyton files are missing, i tried adding them to my python site packages folder, but that didn't fix it. I am getting this error while playing around with it.

from pyHS100 import SmartPlug, SmartBulb
from pprint import pformat as pf
#help(SmartPlug)
p = SmartPlug("10.0.0.202")

11:53:59 Traceback (most recent call last):
11:53:59 Python script "22", line 6, in <module>
11:53:59 p = SmartPlug("10.0.0.202")
11:53:59 File "C:\Python27\Lib\site-packages\pyHS100\pyHS100.py", line 653, in __init__
11:53:59 SmartDevice.__init__(self, ip_address, protocol)
11:53:59 File "C:\Python27\Lib\site-packages\pyHS100\pyHS100.py", line 50, in __init__
11:53:59 socket.inet_pton(socket.AF_INET, ip_address)
11:53:59 AttributeError: 'module' object has no attribute 'inet_pton'


print("Current state: %s" % plug.state)
plug.turn_off()
plug.turn_on()
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.. see if this work for you... just double click on it after you download it.
If you like the work I have been doing then feel free to Image
Post Reply