[Released] Virtual HTTP Switch/Button Creator

dth_virtual
smartapp_misc

#1

As I need to create multiple virtual switch manually for my DIY universal IR project & link them to SmartThings & Echo.

I decided to follow the earlier examples below & come out with a version of HTTP Switch Creator.
tguerena and surge919 - URI Switch
Eric Roberts (baldeagle072) - Virtual switch creator
JZ - TVDevice

You need to install both device handler & smart app. Once install, you can create virtual http switch/button on the fly :wink:

HTTP Button handler (v1.1 - corrected the button behavior and more like momentary switch):

HTTP Button Creator:


Make a "dumb" fan "smart" using cheapo ESP8266 board controllable via ST (universal IR remote)
CoRE http local request help
ESP8266 Temperature Monitoring in Smartthings? (Where to start with a new device)
ESP8266 - Device Type and Sub Forum?
Nuki Smartlock
Raspberry Pi + SmartThings + Amazon Echo (Alexa) + Harmony Hub + Harmony API server + HTTP Button Creator
Help getting started with ST (custom Arduino+Ethernet device: how to connect it to ST?)
SimpliSafe Alarm Integration (cloud to cloud)
[WIP] Roomba Control with RooWiFi
Quick And Dirty - Send TTS Notifications *TO* Amazon Alexa Units
(Brian) #2

Looks like it uses hubaction, so I’m guessing this works locally and not through cloud? Which is pretty awesome if so.


#3

Yes, for local devices, like the Nodemcu, Rasp Pi & LAN devices with http endpoint.

It also work with cloud IP.


#4

Updated to make it a button instead of a switch, to better represent the state status of http device when sending IR.


(James) #5

Thank you for this. Is it / would it be possible to have multiple http calls with small waits in between linked to one button?

Best wishes.


(Mark De Vane) #6

So… I have been spending way too much time trying to get Virtual URI Switch working, and I stumbled upon this SmartApp and decided to give it a try.

Unfortunately, the results are the same – your app does not appear to work for me either. What is weird is that when I send a POST command via Postman (Mac app), the command works like a champ and devices turn on and off appropriately, and more importantly, thru Wireshark, I can see all the IP/HTTP traffic to and from my IP device and the REST client. All is good.

But neither your app and URI Virtual Switch will work, and more importantly I see absolutely no IP/HTTP traffic in Wireshark. Digging into forum, I found several threads that imply that ST is blacklisting local devices and stopping all non-whitelisted IP traffic. My tests tend to agree with those comments, so I am rapidly coming to the conclusion that I will not be able to control my IP devices with ST.

Any thoughts from your end why Wireshark sees no traffic on the LAN? In your app’s case, more work would need to be done for it to work, since I have no way to include the body payload command currently, but I still would expect to see traffic, even if that command is invalid or not structured properly. I am confused on this one.


#7

I would ask your question in the developer section of the forum. People there should know the most about it.

https://community.smartthings.com/c/developers/writing-device-types


#8

Is your sever on local network and in the same network as Smartthings hub?


(Mark De Vane) #9

Yes - that’s what so weird. I am struggling to understand how you and others are communicating between your ST hubs and other devices internal to the lan segment. If so, how/why is there no IP traffic emanating from the ST hub using either SmartApp?

But to confirm, you are having no problem with you app working and communicating with non-registered devices. Is that correct? If so, then I have a different issue I need to run down.

Thanks for your response.


#10

Just tested by pressing my virtual button to turn on my tv via nodemcu :wink:

Take noted that I am using GET command and never tested the POST


(Mark De Vane) #11

Thanks for the feedback. the fact that it works, gives me some comfort that it is possible to get this working. Unfortunately the UPB gateway I use only supports HTTP/POST and direct IP packets, not GET, so that is making the integration a little more difficult. Both you and Troy have operational GET solutions, but no love for POST in anything of the apps/device handlers that I have found so far.

I am not a developer, so I will ask you - how difficult would it be to add code to support BODY key-pairs, which are used by POST command?

I am also looking into a gateway from a different manufacturer, but no word from their developers re: API details. At this point, though, I am stumped unless you can think of anything else.


(Paul Champagne) #12

Thank you for this CSC.

It works well for me.

Any chance this could be expanded to create a dimmer?

I saw your posts in the automated blind topic and while this works really well to open/close the blinds, it would be even better to be able to stop them at any point in between.


#13

Let me find a time to test out the post, it should work. If you have a local web server, try to post to it and and check the http header to see if it receive any parameter


(Vineet) #14

Need some help, I’ve a NodeMCU ESP8266 setup to control some IR devices using example here:

The code works for me (incl raw data) when using normal web browser. Tried the Virtual switch method, and simple URL works, but not able to add raw data URL to the smartapp which is giving error.

Example of simple URL that works:

http://192.168.1.20:8081/msg?code=80C:RC5:12&pulse=2&repeat=2&pass=pass
80C:RC5:

Example of Raw data URL which is still not working for me:

http://192.168.1.20:8081/json?pass=pass&plain=[{β€œtype”:β€œraw”,β€œdata”:[897,874,900,868,1780,867,899,868,898,869,897,870,897,868,898,868,899,1750,897,870,1779,868,898,89578,918,867,898,869,1781,868,898,867,898,868,898,870,895,871,897,869,896,1751,899,869,1779,869,896],β€œkhz”:38,"pulse":2}]

The above is for the TV power, the AC one is even longer.


#15

You should code the raw file in the nodemcu (I presume that), and trigger using simple URL parameter, check out the nodemcu sample thread


#16

@CSC
CSC,

I stumbled onto this while searching for a long wanted solution and hope you can help. I am pretty sure I can use/repurpose it for my use but for the life of me I can not get it to function. I am going to guess its something I am not setting up correctly.
Some background, I am attempting use this to integrate an Eyezon Envisalink 3 that’s commonly connected to DSC and other alarm panels. It has a local built in server that accepts local http commands to arm/disarm etc
Currently I can use a web browser (or tasker get) and enter β€œhttp://192.168.5.174/2?A=3&p=1&X=0952” and the system will arm.
I have currently setup entered
Device IP address
192.168.5.174
Device port
80
URL Path for ON
/2?A=3&p=1&X=0952
URL Path for off
(I have not entered anything)
Post or Get
Get
Requires user auth? Set to off.

This is what is logged
a3059725-dc8d-42eb-8a70-304ec57fafb3 β€Ž7β€Ž:β€Ž32β€Ž:β€Ž42β€Ž β€ŽPM: debug GET /2?A=3&p=1&X=0952 HTTP/1.1
Accept: /
User-Agent: Linux UPnP/1.0 SmartThings
HOST: 192.168.5.174:80
Content-Type: application/x-www-form-urlencoded

a3059725-dc8d-42eb-8a70-304ec57fafb3 β€Ž7β€Ž:β€Ž32β€Ž:β€Ž42β€Ž β€ŽPM: debug The method is GET

a3059725-dc8d-42eb-8a70-304ec57fafb3 β€Ž7β€Ž:β€Ž32β€Ž:β€Ž42β€Ž β€ŽPM: debug The Header is [HOST:192.168.5.174:80, Content-Type:application/x-www-form-urlencoded]

a3059725-dc8d-42eb-8a70-304ec57fafb3 β€Ž7β€Ž:β€Ž32β€Ž:β€Ž42β€Ž β€ŽPM: debug path is: /2?A=3&p=1&X=0952

a3059725-dc8d-42eb-8a70-304ec57fafb3 β€Ž7β€Ž:β€Ž32β€Ž:β€Ž42β€Ž β€ŽPM: debug The device id configured is: ea5583db-eb51-42fe-a460-351b6c207c63

a3059725-dc8d-42eb-8a70-304ec57fafb3 β€Ž7β€Ž:β€Ž32β€Ž:β€Ž42β€Ž β€ŽPM: debug β€”ON COMMANDβ€” /2?A=3&p=1&X=0952

Any help/insight for a total noob would greatly be appreciated!!

Phil


#17

This is my setup, fyr


#18

Thanks CSC,
I was able to get it running and it works like a champ for this integration without modifications.
I did have to enable authentication and enter the server info instead of the system code.

Hopefully others trying to do this can find it as I did.

Thanks again

Phil


(Mark Povolo) #19

Hi, I also have this working now with DSC alarm, thanks for all the notes here.
Does anyone know the url code for arm away mode. The disarm one works, the arm one however arms only in stay. I cannot figure out how to arm away mode. The ones below are the url I am using where xxxx is DSC passcode

URL Path for ON
/2?A=3&p=1&X=xxxx

URL Path for ON
/2?A=4&p=1&X=xxxx

thanks


#20

Mark,
More than likely its actually going into away mode but you did not trigger an exit sensor,If you just trigger it and do not exit it will arm in stay mode Its the way DSC panels behave… As a test, Arm it and open one of your exit doors and let it arm. Then trigger the exit/disarm and it should show it was it away mode was disarmed.

Phil