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

Is there any way for this DTH to check state of a device that can respond via HTTP call?

If I run a GET against my projector with a specific string in the URL, it will give me a text string back to tell me the status.

This works for every function of the projector, power, display settings, keystone, etc… Basically everything the remote can do, I can do via HTTP as well. But, since the DTH is only a blind URL grabber, it doesn’t currently poll or update to show me status of whatever is running the HTTP server.

All HTTP requests would be GET commands, even for changing settings.

1 Like

Thanks so much for this, this is a life saver! I’m switching from HomeSeer as much as I love it, just because unfortunately the mobile access isn’t that great so I love how ST is all operated by my phone. I have a bunch of Insteon devices and my DSC alarm which I’m having a ton of trouble getting working with ST (the alarm, not Insteon since it isn’t supported). With this plugin, now I just made a virtual switch for my Insteon devices with a URI and can now turn them on or off from ST like they are a normal device. Only issue is no dimming but hardly an issue.

On the flip side, is there any easy way to receive a URI and control something on ST? So have HomeSeer be the one sending the URI or HTTP call and have ST respond in the reverse?

I believe you already use CoRE, you can do the reverse by creating a DO piston type and calling that from a URL.

Use your CoRE dashboard url address and change the dashboard#/ part with execute/PistonName

Amazing I’ll give that a try later, this will be perfect if it works. :slight_smile:

Hi

I’m trying to edit this device handler to make ST turn off my Phillips Android TV when I leave my home. The problem is that I need to pass a username and a password to the TV.

To turn off TV I need to call this URL https://192.168.1.232:1926/6/input/key/ and send with JSON { “key” : “Standby” }. Since the same URL also turns the TV on, I need to check the powerstate by calling https://192.168.1.232:1926/6/powerstate

Any ideas on what I need to edit?

1 Like

How did you get it to work with DSC alarm?

thanks

I am getting these errors in trying
java.lang.reflect.UndeclaredThrowableException @ line 98

or
java.lang.reflect.UndeclaredThrowableException @ line 66

depending if the device is on or off

Any ideas?

thanks

Any possibility of adding the ability to have the virtual switch updated by a json callback URI? or at least adding another URI which would be polled at a specified time to retrieve device state and supply the value to parse?

My use case is with a Nuki lock, which has a local bridge with a REST API (https://nuki.io/wp-content/uploads/2016/04/Bridge-API-v1.5.pdf), there’s also a web API for cloud to cloud, but I’d prefer to stay local if possible.

You can see on page 9 there’s the ability for the Nuki bridge to report the status after each operation as a JSON load to an endpoint. OR on page 3, there’s a simple http request that could be parsed on a simple polling scheme.

Thanks,

Unfortunately, this device type I’ve created does not. What you’re talking about is the definition of a custom device handler. This is meant to be a little more universal. When you start adding in expected payloads and having those payloads change the status based on their response, that makes the device handler a lot more specific. You can, however, fork this code and use it as the base of your own custom device handler as it’s almost there.

1 Like

Without more information, I’m afraid I can’t help troubleshoot.

These is in my log
1017b50e-9c54-4c21-baad-cc060949e929 11:58:01 PM: debug GET /2?A=4&p=1&x=4832 HTTP/1.1
Accept: /
User-Agent: Linux UPnP/1.0 SmartThings
HOST: Http://192.168.86.197:80

1017b50e-9c54-4c21-baad-cc060949e929 11:58:01 PM: debug Executing OFF
1017b50e-9c54-4c21-baad-cc060949e929 11:57:31 PM: debug GET /2?A=4&p=1&x=4832 HTTP/1.1
Accept: /
User-Agent: Linux UPnP/1.0 SmartThings
HOST: Http://192.168.86.197:80

1017b50e-9c54-4c21-baad-cc060949e929 11:57:31 PM: debug Executing OFF
1017b50e-9c54-4c21-baad-cc060949e929 11:57:25 PM: debug GET /2?A=3&p=1&x=4832 HTTP/1.1

1 Like

And just to add
this is how I set it up
Internal IP — 192.168.0.76

Internal Port (if not 80)

Internal On Path (/blah?q=this) — /2?A=4&p=1&X=1234

Entering the whole string with the IP address normally runs the command on the server, but here does nothing

thanks for any help

I’m new to ST and not a programmer (so be gentle). Do I understand correctly that this would give me the ability to control (say) a switch from a regular browser and custom html page (even when not connected to the same LAN)?
If so, is there a simple/working example I could have a look at? Thanks!

I’m not sure you understand this one correctly. This allows you to control other devices that have a basic url you can query to toggle via smartthings (button or actions). What you’re talking about is exposing Smartthings devices via API. That is doable, but that’s not what this device handler is for.

Troy,

I have the same question as a couple of folks above.
Is it possible to capture a status via URL so that device handler can decide whether to call open or close URL?

I also have a custom made Raspberry Pi garage door opener, but it also has door sensors so I have a real state I can serve via another URL.
Can you provide a way to modify this?

Thanks

Hi there, I am not sure it will answer your question but have a look at my implementation [RELEASE] Honeywell HPA250B Air Puriifier integration (through Raspberry Pi) which polls requests to my Raspberry regarding the status of my air-purifier and then get the answer thanks to a JSON the pi builds and sends back to the DTH. Hope it helps

Hello there @Mark_deVane and @tguerena ,
So i have a USB UPB controller/interface that registers as a simple Human Interface Device / USB Input Device under Windows and a few UPB light switches and lamp modules and appliance modules from my older home automation system that it will be fantastic if i can get them to work with SmartThings.

I already connected all my X10 devices by using a Raspberry Pi and Mochad and following the instructions of other people (I a have a tech background but not a programmer) and i can tell you that they work better than with what they were originally controlled with :slight_smile: i was wondering if i could do the same with the usb UPB interface and the Raspberry Pi in place of your RUC01 but have not idea how and what is required did you solve your UPB issue?? any pointers that might help me??
thank you for your time any help is appreciated.
Denis

Has this stopped working. Had all my URL switches working on internal IP address and now they do not work???

The same URL address works in browser but not in this device anymore

NVM I got it working again

Hello @richland007

I assume your problem is sending commands to UPB using a script - came across a couple of projects in github that look promising

The first one listens on a TCP port so you should be able to send commands to it from outside.

For interfacing with ST I have become a fan of HA-Bridge - GitHub - bwssytems/ha-bridge: Home automation bridge that emulates a Philips Hue light system and can control other systems such as a Vera, Harmony Hub, Nest, MiLight bulbs or any other system that has an http/https/tcp/udp interface. This is a compact impl to run on small format computers. This is impl started from this project https://github.com/armzilla/amazon-echo-ha-bridge.

It is dead simple to install and appears like a hue bridge on the local network, and you can define custom devices, and supports a variety of protocols including http:, tcp, udp etc. as well as command line scripts. As long as you have an internal endpoint for your UPB device, its pretty much point and click and adding a command for your device/controller - you can have a look at my post on using it with mochad and X-10 and google other implementations. The thing I like about this approach is that Hue support is natively built in so no setup is needed in ST beyond discovery. Here is the link to the afore-mentioned post.