Release WeMo Toggle
#1
WeMo Toggle can be used to toggle a Belkin WeMo Switch. The IP address of the WeMo Switch is required and it is recommended to assign the WeMo Switch a static IP via DHCP reservation on your router.

Download the add-on zip and install the add-on through Kodi settings. After the add-on has been installed, input the IP address of the WeMo Switch and enable desired settings. The add-on will determine the port being used by the WeMo Switch after the settings have been saved.

Required: WeMo Switch, WeMo Insight Switch, or WeMo Light Switch

Options:
  • Turn switch off when a video starts or resumes
  • Turn switch on when a video stops, ends, or is paused
  • Enable off/on events for movies and/or tv shows
  • Enable off/on events between certain hours
  • Toggle the switch by mapping
    Code:
    Skin.SetString(wemoToggle, 0)
    to a key in keyboard.xml
  • Enable notifications when the switch is turned off/on

Platforms: all

Tested on: WeMo Light Switch using Kodi on Android, OSX, OpenELEC, and Windows

changelog:
Quote:
  • added option to toggle multiple switches under Misc category - 192.168.1.2;192.168.1.3;192.168.1.4
  • added better handling for detecting movies and television shows
  • bugfixes
  • refactored code base
  • new icon
Added Misc category to settings
  • option to delay service start in seconds
  • option to turn switch on at startup
  • option to turn switch off at shutdown
  • option to always turn switch off when media starts
Download: service.wemo.toggle.zip
Old Download: service.wemo.toggle.zip

Thanks to: cj2902, Sylv, yuvalt, sphere, and zag
Reply
#2
Works like a charm. Smile
So now I'm one big step closer to "finishing" my htpc build.
Thx!
Reply
#3
Having 1 small problem with the addon though ...

When I power up the HTPC the addon always says if can't find the Wemo switch and will jump straight into the config screen.
Seams like it's always "detecting" the port for the Wemo, even though I've set that to what it should be in the config screen.

So I end up with having the addon working, but with the config screen open when I power up my HTPC.

Enabled log for the addon, where does this log place it self?
Any idea how I can stop this config screen to pop up at power up, should the addon be delayed?
Reply
#4
(2015-01-24, 15:57)Verderer Wrote: Having 1 small problem with the addon though ...

When I power up the HTPC the addon always says if can't find the Wemo switch and will jump straight into the config screen.
Seams like it's always "detecting" the port for the Wemo, even though I've set that to what it should be in the config screen.

So I end up with having the addon working, but with the config screen open when I power up my HTPC.

Enabled log for the addon, where does this log place it self?
Any idea how I can stop this config screen to pop up at power up, should the addon be delayed?

According to some posts I have read online the port for the WeMo switches can change. If the add-on is unable to check the status of the switch it will reset the port and attempt to connect on a different port. If it is still unable to connect on a different port it is possible the IP address changed so it opens the config screen.

If your WeMo Switch is assigned a static IP but the config screen appears when you power up the HTPC there might be a delay with your HTPC connecting to the network. If this is the case then I can add a delay before the add-on checks the status of the switch.

It will print information to the kodi.log file. The add-on will print messages in this format:
Code:
WeMo Toggle - [MESSAGE]

Snippet from kodi.log with the information the add-on will print with Log enabled:
Code:
15:11:19 T:5660  NOTICE: -->Python Interpreter Initialized<--
15:11:19 T:6904  NOTICE: WeMo Toggle - Finding port
15:11:19 T:6904  NOTICE: WeMo Toggle - Trying: 192.168.1.18:49152
15:11:19 T:6936  NOTICE: Thread JobWorker start, auto delete: true
15:11:19 T:6048  NOTICE: Webserver: Starting...
15:11:19 T:6048  NOTICE: WebServer: Started the webserver
15:11:19 T:6048  NOTICE: ES: Starting event server
15:11:19 T:1672  NOTICE: Thread EventServer start, auto delete: false
15:11:19 T:1672  NOTICE: ES: Starting UDP Event server on 0.0.0.0:9777
15:11:19 T:1672  NOTICE: UDP: Listening on port 9777
15:11:19 T:6632  NOTICE: Thread TCPServer start, auto delete: false
15:11:22 T:6904  NOTICE: WeMo Toggle - ERROR - 192.168.1.18:49152 - <urlopen error timed out>
15:11:22 T:6904  NOTICE: WeMo Toggle - Trying: 192.168.1.18:49153
15:11:25 T:6904  NOTICE: WeMo Toggle - ERROR - 192.168.1.18:49153 - <urlopen error timed out>
15:11:25 T:6904  NOTICE: WeMo Toggle - Trying: 192.168.1.18:49154
15:11:28 T:6904  NOTICE: WeMo Toggle - ERROR - 192.168.1.18:49154 - <urlopen error timed out>
15:11:28 T:6904  NOTICE: WeMo Toggle - Trying: 192.168.1.18:49155
15:11:31 T:6904  NOTICE: WeMo Toggle - ERROR - 192.168.1.18:49155 - <urlopen error timed out>
15:11:31 T:6904  NOTICE: WeMo Toggle - ERROR - Please make sure the IP address is correct
15:13:15 T:6904  NOTICE: Previous line repeats 3 times.
15:13:15 T:6904  NOTICE: WeMo Toggle - Finding port
15:13:15 T:6904  NOTICE: WeMo Toggle - Trying: 192.168.12.18:49152
15:13:16 T:6904  NOTICE: WeMo Toggle - ERROR - 192.168.12.18:49152 - <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
15:13:16 T:6904  NOTICE: WeMo Toggle - Trying: 192.168.12.18:49153
15:13:19 T:6904  NOTICE: WeMo Toggle - ERROR - 192.168.12.18:49153 - timed out
15:13:19 T:6904  NOTICE: WeMo Toggle - Trying: 192.168.12.18:49154
15:13:19 T:6904  NOTICE: WeMo Toggle - Found: 192.168.12.18:49154
Reply
#5
Ok, so here's the error log I'm getting.

Code:
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - ERROR - 192.168.0.15:49153 - <urlopen error [Errno 101] Network is unreachable>
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - The IP address is incorrect or the port number changed
19:49:21 T:139840530278144  NOTICE: Previous line repeats 1 times.
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - Resetting port number
19:49:21 T:139840530278144  NOTICE: Previous line repeats 1 times.
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - Finding port
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - Trying: 192.168.0.15:49152
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - ERROR - 192.168.0.15:49152 - <urlopen error [Errno 101] Network is unreachable>
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - Trying: 192.168.0.15:49153
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - ERROR - 192.168.0.15:49153 - <urlopen error [Errno 101] Network is unreachable>
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - Trying: 192.168.0.15:49154
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - ERROR - 192.168.0.15:49154 - <urlopen error [Errno 101] Network is unreachable>
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - Trying: 192.168.0.15:49155
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - ERROR - 192.168.0.15:49155 - <urlopen error [Errno 101] Network is unreachable>
19:49:21 T:139840530278144  NOTICE: WeMo Toggle - ERROR - Please make sure the IP address is correct

My Wemo Switch is running on a static ip, so maybe adding a delay would work.
Eager to test it out Smile
Reply
#6
(2015-01-25, 02:53)Verderer Wrote: Ok, so here's the error log I'm getting.

Code:
...

My Wemo Switch is running on a static ip, so maybe adding a delay would work.
Eager to test it out Smile

I have added a 10 second delay before it checks the status of the switch: service.wemo.toggle-sleep_test.zip

Please let me know if this resolves your issue.
Reply
#7
Yes, this does resolve my issue.
Working perfectly now.

And now I have 2 requests for the addon if possible.
1) Add a "set time delay field" in the config screen, so I can set it to f.eks. 5 sec, or 7 sec.
2) Is it possible to auto turn the switch on at startup, and turn off on shutdown?

Cheers Smile
Reply
#8
(2015-01-25, 11:53)Verderer Wrote: Yes, this does resolve my issue.
Working perfectly now.

And now I have 2 requests for the addon if possible.
1) Add a "set time delay field" in the config screen, so I can set it to f.eks. 5 sec, or 7 sec.
2) Is it possible to auto turn the switch on at startup, and turn off on shutdown?

Cheers Smile

Excellent.

I have added the requested settings. Please see below for changes and download.

changelog:
Quote:Added Misc category to settings
  • option to delay service start in seconds
  • option to turn switch on at startup
  • option to turn switch off at shutdown
  • option to always turn switch off when media starts
Download: service.wemo.toggle.zip
Reply
#9
Nice Smile

Though the "turn switch off at shutdown isn't working for me.
And I can't find anything in the log files.

Since I've got another addon that I run at shutdown ... I should probably have a little shutdown script to run both addons.
Reply
#10
(2015-01-26, 23:40)Verderer Wrote: Nice Smile

Though the "turn switch off at shutdown isn't working for me.
And I can't find anything in the log files.

Since I've got another addon that I run at shutdown ... I should probably have a little shutdown script to run both addons.

I will look into it later today or sometime this week to see if I can replicate the issue.

The only thing at the moment that should show up in the log if the add-on is set to turn the switch off at shutdown when Kodi exits is: WeMo Toggle - Switch: Off

Example:
Code:
14:50:49 T:4916  NOTICE: Storing total System Uptime
14:50:49 T:4916  NOTICE: Saving settings
14:50:49 T:4916  NOTICE: stop all
14:50:49 T:4916  NOTICE: stop player
14:50:49 T:4916  NOTICE: ES: Stopping event server
14:50:49 T:6112  NOTICE: ES: UDP Event server stopped
14:50:49 T:4916  NOTICE: stop sap announcement listener
14:50:49 T:4916  NOTICE: clean cached files!
14:50:49 T:4916  NOTICE: unload skin
14:50:51 T:2928  NOTICE: WeMo Toggle - Switch: Off
Reply
#11
Ok, did some more logging and found the "WeMo Toggle - Switch: Off", but I see there is a error right after.

Full log here: http://pastebin.com/n88EVNg3
Reply
#12
(2015-01-27, 01:39)Verderer Wrote: Ok, did some more logging and found the "WeMo Toggle - Switch: Off", but I see there is a error right after.

Full log here: http://pastebin.com/n88EVNg3

Thank you for the log. It appears to be the same issue you were experiencing before we added the delay to the add-on.

Code:
<urlopen error [Errno 101] Network is unreachable>

I just tested it on my Raspberry Pi with OpenELEC 5.0.0 and I am also experiencing the same issue with the shutdown option enabled. However, it is working as intended on Android, Linux (Ubuntu 14.04), OSX, and Windows. It seems to be an issue/feature with how OpenELEC handles network connection(s) when a shutdown is initiated. I do not know if there is anything else I can do to resolve this issue because the add-on sends the command when Kodi requests Abort.

Another person seems to be experiencing a similar issue with their shutdown script.
Reply
#13
this is sweet and works perfectly, but can you update it to add more then one switch? I have 2 wemo switches in my media cabinet for the led lights and one for the celing light. I would love to be able to control multiple devices from kodi.
Reply
#14
(2015-02-22, 06:21)jebise Wrote: this is sweet and works perfectly, but can you update it to add more then one switch? I have 2 wemo switches in my media cabinet for the led lights and one for the celing light. I would love to be able to control multiple devices from kodi.

I have exams this week and next week; but I will consider looking into this request when I have some free time.

If I am able to add this feature the switches would be controlled together by the add-on (i.e. both switches off or both switches on when toggled) and there might be a slight delay.
Reply
#15
I could care less about the delay, but it would be awesome to get both lights to turn on and off with one button/trigger. Also if your able to, release two version i.e one for single setups and one for duel setups. Give the services different names so they act as two separate addons.

This way I can control my celing light as well with the single service as is now and the other addon for dual setups. I sure hope people don't need to control more than 3 devices :p

But thanks for your hard work and good luck on the exams.
Reply



Logout Mark Read Team Forum Stats Members Help
WeMo Toggle0
This forum uses Lukasz Tkacz MyBB addons.