Extension: URL Toggle Device

Posted on
Fri Jun 10, 2016 6:16 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Extension: URL Toggle Device

Because I have no life (and my wife is out of town and I have nothing better to do without her) I just added a new extension to Device Extensions called a URL Toggle Device. This basically allows you to create an On/Off/Toggle device that simply executes a URL for you on each command.

It just so happened that last night I was checking my cameras and noticed that the I/R was on for one of my cameras and it was close enough to glass to make seeing the image impossible, so I decided I would write something to easily take care of that for me but generic enough I could use it on a number of my web-enabled devices around the house.

Screenshot & Details

Screen Shot 2016-06-10 at 5.57.27 PM.png
New URL Toggle Device
Screen Shot 2016-06-10 at 5.57.27 PM.png (63.74 KiB) Viewed 5756 times


  • Turn on URL: The URL to execute when an On command is received
  • Turn off URL: The URL to execute when an Off command is received
  • Toggle URL: The URL to execute when a Toggle command is received. If this is left blank then the plugin will internally just execute whatever command is the opposite of the current device state (i.e., if it is currently in an On state it will send an Off command). Because these commands are sent in the blind with no feedback from the receiver, a toggle command might perform the opposite action than what you expect - if this happens there is an action to force it to an off state (without sending an Off command) so you can reset it

Full documentation, release notes and the download link can be found on the main Device Extensions topic

IndigoPluginDownload.png
IndigoPluginDownload.png (14.88 KiB) Viewed 5729 times

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Fri Jun 10, 2016 6:27 pm
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: New Extension: URL Toggle Device

oooh, baby, this is super useful when combined with the Maker channel of IFTTT! Saves the need to write a shell script to make something happen.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Fri Jun 10, 2016 6:45 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: New Extension: URL Toggle Device

Sweet, glad you have a use for this thing that took me all of 5 minutes to add to Device Extensions :).

If people like this and want me to expand it I may port it out to a plugin of its own with more options. I'm already thinking of having some conditional statements for the data chunks returned from the call but that increases the time to develop exponentially. There are probably benefits to enabling other device actions like brightness, that could be tied to a number of other URLs for IFTTT or things like it.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Sat Jun 11, 2016 8:50 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: New Extension: URL Toggle Device

Different Computers wrote:
Saves the need to write a shell script to make something happen.


Not that this device addition isn't useful (it is), but you don't need a shell script, just a simple 2 line Python script:

Code: Select all
import urllib
urllib.urlopen("http://host.com/path/to/whatever")


This is one of the major reasons we use Python as our primary scripting language (as opposed to AppleScript).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Jun 11, 2016 9:29 pm
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: New Extension: URL Toggle Device

Everything is simple once you know how to do it. :wink:

Thanks for the tip though.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Sat Jun 11, 2016 9:43 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: New Extension: URL Toggle Device

And those are the exact two lines of code I use as well, the point of the program is to have it act as a toggle device for whatever your needs might be ;)

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Sun Jun 12, 2016 9:41 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: New Extension: URL Toggle Device

Colorado4Wheeler wrote:
And those are the exact two lines of code I use as well, the point of the program is to have it act as a toggle device for whatever your needs might be ;)


Exactly, which is why I said it was useful. Just couldn't resist the teachable moment... :)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Jun 12, 2016 9:51 am
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: New Extension: URL Toggle Device

I do appreciate teachable moments.

I'm not entirely following on the toggle intent, but I thought I'd report after a lot of head scratching issues yesterday, today everything is working perfectly with sending URLs to the Maker channel that then make my ST hub turn on and off my zigbee lights. So I'm going to point at the eternal flakiness of the ST hub as the reason why it didn't work right immediately.

While the python code is great, and I may be able to use it going forward in future stuff, the ability to have my non-Hue zigbee lights appear as devices in Indigo is really great.

Now if there was just some way short of spinning up another Apache server to get the IFTTT Maker channel to talk straight to Indigo! That would let my remaining zigbee door sensors become useful. Also, I could use the generally reliable ST presence sensing for my wife and I.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Sun Jun 12, 2016 10:16 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: New Extension: URL Toggle Device

Different Computers wrote:
I'm not entirely following on the toggle intent

So you don't have to "turn on" or "turn off" only. For me my IR command button on my control pages is a single button, if I want to toggle IR on and off then I can use that. For schedules I have it set to "turn on" at dark and "turn off" at light. It just gives the same functionality to THIS device as other Indigo devices have.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Sun Jun 12, 2016 10:22 am
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: New Extension: URL Toggle Device

Gotcha! I can see the need for that. It was my initial use of this to send a necessarily specific on OR off to Maker that had me not following.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Sun Jun 12, 2016 10:45 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: New Extension: URL Toggle Device

Sometimes I get too bogged down in geek-speak and probably don't convey the meaning clearly, that's why my documentation on plugins tends to be so verbose :).

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Sun Jun 26, 2016 8:54 am
neilk offline
Posts: 714
Joined: Jul 13, 2015
Location: Reading, UK

Re: New Extension: URL Toggle Device

Hi,
Tried adding an URL extension today with the following URL (currently run in an external script)

https://192.168.1.20/cgi-bin/CGIProxy.f ... pwd=mypass

But get the following in the log file

EPS - Device Extensions Error Error in plugin execution ExecuteAction:

Traceback (most recent call last):
File "plugin.py", line 502, in actionControlDimmerRelay
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 126, in urlopen
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 391, in open
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 409, in _open
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 369, in _call_chain
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 1189, in https_open
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 1156, in do_open
URLError: <urlopen error [Errno 8] _ssl.c:493: EOF occurred in violation of protocol>

It is a foscam R2 Pan and tile camera

I found some old references to the same issue with older python versions, but https is a bit of a dark art for me.

Thanks,
Neil

Posted on
Sun Jun 26, 2016 8:58 am
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: New Extension: URL Toggle Device

Are you able to access the camera via your browser without using SSL?

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Mon Jun 27, 2016 2:34 am
neilk offline
Posts: 714
Joined: Jul 13, 2015
Location: Reading, UK

Re: New Extension: URL Toggle Device

The documentation on the camera is more than a little sparse, no obvious settings on the camera to allow it. It is not really a big deal as it I have it working with external scripts and curl but I thought your device approach was much more elegant. I am also playing with the other extensions so many thanks for this.

I will keep digging, but good to know if anyone else has a similar issue.

Neil

Posted on
Mon Jun 27, 2016 5:39 am
PeteVis offline
Posts: 180
Joined: Jun 19, 2015

Re: New Extension: URL Toggle Device

This would be a super useful plugin if you could make it a little more flexible...

i.e. I have a dLink camera that I can set IR commands, but the dlink requires authentication that is not passed via the url, so I need to use this script to make it work :
Code: Select all
import urllib2, base64

request = urllib2.Request("http://10.0.1.50/eng/admin/adv_audiovideo.cgi")

base64string = base64.encodestring('%s:%s' % ('username', 'password')).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)   
result = urllib2.urlopen(request,'irMode=3')

Who is online

Users browsing this forum: No registered users and 1 guest