Page 1 of 1

Python Plugin: WEMO

Posted: Wednesday 29 May 2019 12:20
by itguy78
I wrote a python plugin for my own use to control WEMO devices around the house (WEMO on/off switches and WEMO Link LED lights).

Anyone is welcome to use/try it and provide any feedback.
I only have WEMO Link LED lights and a WEMO Mini Switch but I am pretty sure this will work with most WEMO devices for on/off status and control.
The main thing that I found annoying with other options is to not require setting up IP addresses/port settings for each device (and have to manually update them when anything changed), so this plugin automatically detects/redetects WEMO devices on the network and adds them with the name given in the WEMO app.

For Downloads/Install steps/Source see this link:
https://github.com/guino/Domoticz-WEMO

Re: Python Plugin: WEMO

Posted: Tuesday 27 August 2019 0:14
by dthompson
I loaded your plugin today, but i'm getting a lot of errors. I followed your instructions on the github website. When i added the Hardware "WEMO" and enabled the plugin, i get the following errors in Domoticz:

2019-08-26 18:05:06.523 Error: (BasePlug) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Domoticz-WEMO/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload:/usr/local/lib/python3.5/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.5/dist-packages'.
2019-08-26 18:05:06.523 Error: (WemoLights) Module Import failed, exception: 'ImportError'
2019-08-26 18:05:06.523 Error: (WemoLights) Module Import failed: ' Name: httplib2'
2019-08-26 18:05:06.523 Error: (WemoLights) Error Line details not available.
2019-08-26 18:06:07.765 Error: WemoLights hardware (8) thread seems to have ended unexpectedly
2019-08-26 18:06:21.768 Error: WemoLights hardware (8) thread seems to have ended unexpectedly
2019-08-26 18:06:35.771 Error: WemoLights hardware (8) thread seems to have ended unexpectedly
2019-08-26 18:06:49.774 Error: WemoLights hardware (8) thread seems to have ended unexpectedly

I'm running on a Raspberry PI 2 B. Domoticz 4.10717

Thanks for your plugin and your help!
Darryl

Re: Python Plugin: WEMO

Posted: Tuesday 27 August 2019 1:58
by Dnpwwo
@dthompson,

Just a word of warning: Your plugin will crash Domoticz sometimes during either shutdown or if the 'Update' button is pressed on the Hardware page. This is documented here: https://www.domoticz.com/wiki/Developin ... k_details:. You need to add some code into your onStop to make sure that your extra thread isn't running when the plugin stops. There is an example that shows how to do this.

Alternatively you can do SSDP discovery using native connectivity and not use a thread at all as shown in this example: https://github.com/domoticz/domoticz/bl ... scovery.py

Re: Python Plugin: WEMO

Posted: Tuesday 27 August 2019 2:28
by dthompson
@dnpwwo,

I didn't write the plugin. I found it on the forum and am trying to get it to work. Thanks for the heads up tho. Hopefully, itguy78 will see our responses and address these issues.

Darryl

Re: Python Plugin: WEMO

Posted: Tuesday 27 August 2019 13:53
by itguy78
@dthompson

You're getting an error because you're missing the python library httplib2 -- how to install it depends on your OS, on debian/armbian you can do:
sudo apt-get install python3-httplib2 on many other systems you can try pip install httplib2 or just google how to install the library on your OS (I thought this library came installed with python by default)

I have never had any issue stopping/restarting the plugin with the current code -- I just tried it and didn't have any issues:

2019-08-27 07:46:57.446 Status: (Wemo) Stopping threads.
2019-08-27 07:46:57.453 Status: (Wemo) Stopped.
2019-08-27 07:46:57.454 Status: (Wemo) Started.
2019-08-27 07:46:59.613 (Wemo) WEMO plugin started

I understand there's possibility for crashing python (sometimes) so I will update the code when I have a chance.

Re: Python Plugin: WEMO

Posted: Tuesday 03 September 2019 2:14
by dthompson
@ITGUY78

Thank you for your help! Its working great now!

Darryl

Re: Python Plugin: WEMO

Posted: Friday 19 June 2020 21:14
by itguy78
Dnpwwo wrote: Tuesday 27 August 2019 1:58 @dthompson,

Just a word of warning: Your plugin will crash Domoticz sometimes during either shutdown or if the 'Update' button is pressed on the Hardware page. This is documented here: https://www.domoticz.com/wiki/Developin ... k_details:. You need to add some code into your onStop to make sure that your extra thread isn't running when the plugin stops. There is an example that shows how to do this.

Alternatively you can do SSDP discovery using native connectivity and not use a thread at all as shown in this example: https://github.com/domoticz/domoticz/bl ... scovery.py
I wrote this plugin a little over a year ago and never had issues with it crashing -- that said: there's no parallel thread running 'the whole time' in this plugin, so that's probably why the issue never happened with me. I reviewed the information and added a prevention in the onStop so that in the off-chance the thread is running right when the update button or shutdown runs it will wait for the thread to finish (which it always does within 2s) avoiding any potential crash situation. Plugin is updated in the original site.