[BETA RELEASE] URI Switch -- Device Handler for controlling items via HTTP calls

Enis thank you for your reply,
I have a mochad deployment already set up for my X10 devices using a raspberry pi and CM15A i am not using the HA bridge for that purpose i am using the older device type / handler smart app for ST approach.
I also have a HA bridge server running that automates my roomba vacuum cleaner with a Roowifi adapter through Alexa. I have not created any of these approaches i have merely followed steps that others have written LOL
I do have 2 UPB dimmer switches already installed that used to work really well with an older automation system and a usb UPB control interface that registers as a HID but i have no clue of what to look for as far as how the mochad can communicate with the usb UPB interface or how to find the addresses of the UPB devices that need to be controlled.
I guess i am going to do some more research and hopefully with your help or expertise we can get this figured out :slight_smile: do you have any upb switches of your own??
Please continue to point me to the right direction and any help is really appreciated.

By the way judging by your name / member id i think we might be of the same back ground :slight_smile: … maybe apo jo vella?

Thank you again

Unfortunately I learnt about UPB reading your post :slight_smile: If you are not a programmer start with https://github.com/DaAwesomeP/upb-cli/ - its a node based project, if you don’t have node installed on your Pi do that first then follow the instructions on the github page.

Probably not :slight_smile: this is just my online identity -

Thanks for this, I have set up the URI switch and it works great when I use the switch in the smartthings app, however when I use Core or SmartRules for the URI switch the URL request is not sent, the switch does turn on/off but I cant see anything hitting my webserver logs. Any ideas why this is?


That is strange. I have not tried using the CORE to tie in to the URI
switch. Generally speaking, I would think that the switch and the switch’s
triggers would line up to each other 1:1. In other words it sounds like
it’s working right, but maybe the switch isn’t? I’ll have to try with mine
later and see if it works.

Troy Guerena

I hope this thread is still active. I’m trying to use this Device Handler to control my Hunter Douglas blinds. I have a gen 1 hub and it doesn’t have native Alexa or SmartThings integrated. however I’m able to access the APIs through my browser. For example executing closes one of my blinds. I would expect this to work with the URI Switch, but for some reason I can’t get it to work.

Here’s the Log:

7:17:58 PM: info postEventToEndpoint: event successfully posted.

7:17:58 PM: debug Property Change Event switch: off (source: DEVICE)

7:17:58 PM: debug GET /api/scenes?sceneid=7974 HTTP/1.1
Accept: /
User-Agent: Linux UPnP/1.0 SmartThings
Content-Type: application/x-www-form-urlencoded
Content-Length: 4


7:17:58 PM: debug Executing OFF

What am I doing wrong? Seems so simple. Thanks for your help and for the development. This looks like it has a lot of potential.

Can you send a screenshot of the smartthings setup for the URI Handler?

Garry, you may be interested in this:

You are correct…That’s exactly what I needed. Thank you!!

OK, I’m tired, don’t know whats wrong.
When I use a web browser to post:
My device turns on as expected.

When I use URI Switch, nothing happens. Log file shows:

**4:12:46 PM: debug GET /tools?cmd=event%2CTurnOn HTTP/1.1 **
**Accept: / **
User-Agent: Linux UPnP/1.0 SmartThings

What am I missing?

Need a little bit more info to help you. Just judging by your message, looks like the issue might be that doing a POST is working, but doing a GET is not. Maybe a screenshot of your settings in smartthings? And a little info as to what you’re trying to setup?

Thanks for getting back to me so quickly.
Yes, I’m trying to post to the message /tools?cmd=event,TurnOn.
So I set URI settings like this:
External - not set
Internal IP
Internal port - not set
Internal On Path: /tools?cmd=event,TurnOn
Internal Off Path: /tools?cmd=event,TurnOff

I see the default in URI Switch uses GET

I have a wifi relay on the local network at that can be turned on/off in this way. I can get it working using Webcore, but I would prefer something that’s not cloud based.

Have you tried changing the method from GET to POST?

Yea I tried just changing the GET to a POST in your device handler.
It did not work.
Maybe I need to provide extra parameters for the POST?

Generally, with a POST request, a payload is needed. Usually a beater token for auth or some other kind of json payload like {action:“on”} or something. It depends on what the device expects. Usually noted in the API documentation.

So I changed
method: “GET”, to
method: “PUT”, and it WORKED.

Thanks for all your help!

Great! Glad it worked. :slight_smile:

Just set this up to control my blinds and its working great! thank you very much :smiley:

1 Like

Troy, I know this post is a few years old but its the best I could find regarding this topic and I’m hoping you (or someone else) can help point me in the right direction. I’m a newbie at programming and am attempting to use your handler to activate a webapi on my Synology Surveillance System NAS. The url trigger turns on and off “home mode” and I want to tie it to a couple of routines I already have in smartthings. I am running a US customer hub v1.1. My smartthings hub and my NAS are on the same LAN.

My NAS auto-created the following string for me:“Trigger”&version=1&eventId=1&eventName=“This is external event1”&account="{account}"&password="{password}"

I created a switch and assigned it the URI switch parameter. I entered in the following info:

internal IP:
Internal port: 5000
Internal On Path: /webapi/entry.cgi?api=SYNO.SurveillanceStation.ExternalEvent&method=“Trigger”&version=1&eventId=1&eventName=“This is external event1”&account=“automation”&password=“tryThisNow4”
Internal Off Path: same as above

When I test the switch I receive the following log:

7:08:30 PM: debug PUT /webapi/entry.cgi?api=SYNO.SurveillanceStation.ExternalEvent&method=“Trigger”&version=1&eventId=1&eventName=“This is external event1”&account=“automation”&password=“tryThisNow4” HTTP/1.1
Accept: /
User-Agent: Linux UPnP/1.0 SmartThings

By the way…I’m really new at this and am following the trial and error method. I have tried GET, POST, and PUT (based off of my understanding of other posts in this thread). I’m in trial and error mode right now. Anything to help would be appreciated.

Have you tried it without the quotes? Also have you looked for the Synology diskstation integration? It may work better

Also, just came across this for switching homeMode:
GET /webapi/entry.cgi?

from this doc here: https://global.download.synology.com/download/Document/DeveloperGuide/Surveillance_Station_Web_API_v2.7.pdf

Maybe it would help?

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.