I am a ST noob and need help adding an unsupported device.
I have developed a Garage door monitor using an Arduino and Ethernet shield.
I can get the state of the garage door (via a contact sensor) by accessing the web server running on the Arduino.
The Arduino is also capable acting as web client.
Here is where I need the community’s help. I don’t know what I need to create in ST (device handler, virtual device, Smart App, etc) to get the garage door status on the dashboard.
Here is what I looking to achieve:
The garage door monitor updates the ST (via a web request) on a state change (door open/closed)
ST shows the garage door status and have the ability to send a web request to the garage door monitor to open/close
There are a couple of different ways to do this, and hopefully other community members will chime in.
One of the simplest ways would be to create a virtual switch which represents the Arduino. Then its status would show up in the SmartThings app.
So now you’ve got a virtual switch and you want to create bidirectional communication.
For anything complicated, see the developer docs at the link at the top right of this page.
For just a simple on/off, you can use the free IFTTT maker channel as a “man in the middle.”
You have your device send to the IFTTT maker channel as the “if” in an IFTTT recipe and use turning on the virtual switch in the smartthings channel as the “that.” Set up a separate recipe for the off.
You can then do exactly the same thing in the opposite direction: have turning on the virtual switch in the smartthings channel then send something via the maker channel as the that. And again you would need two recipes, one for on and one for off.
The big question with IFTTT is always how much lag Will there be? At my house it’s a pretty consistent eight seconds, which works for most of my use cases, but it varies from person to person and some people have a lot more lag.
The IFTTT maker channel method probably isn’t what you want to do in the long term, as there are more direct methods, but at least it would give you a proof of concept and some initial functionality while you’re looking into the other methods.
And eventually you would want to write your own custom device type handler for the virtual switch so that you could have the appropriate labels (open/close instead of on/off), add some capabilities, etc.
I believe you’d need to create a web services smartapp in order to push the status to SmartThings.
A hubAction DTH would send a GET/POST request to the webserver and then parse the response. I am currently doing this with a Raspberry Pi, though I am sending commands to it rather than updating the status.
I am stuck on getting the hubAction DTH to parse the response.
I’ve set my device network id to equal the hex version of the IP:PORT (c0a80104:22b8) of the device that I created based on the DTH.
The device is making the GET call, but I do not see that parse() is even being executed.
The only thing that I have in parse() for now is “log.debug xxx” and I am not seeing it come through the live logger.
Am I supposed to be setting the device network id of the device the same as the IP address of the web server that I am sending a GET request to?
@CSC, I tried the code that you provided, but I still can not get the DTH to run the parse statement. Here is the output from the live logging:
4:05:34 PM: debug GET /GetLeft HTTP/1.1
User-Agent: Linux UPnP/1.0 SmartThings
4:05:34 PM: debug The method is GET
4:05:34 PM: debug The Header is [HOST:192.168.1.4:8888, Content-Type:application/x-www-form-urlencoded]
4:05:34 PM: debug path is: /GetLeft
4:05:34 PM: debug The device id configured is: C0A80104:22B8
4:05:34 PM: debug ---ON COMMAND--- /GetLeft
I set the DNI to the hex value of the server that I am doing a GET on as per other discussions.
I was working on the same Garage project a while back and I made it work without virtual switches, IFTTT etc.
You can find my code here:
Works perfectly for me for many months now.
Direct communication ST - Arduino.
Arduino pushes events to ST.
ST can poll/refresh if needed.
Can detect if Arduino is offline - Will show Unknown state in ST.
I also attached temperature sensor to Arduino to know temperature in the garage. You can cut that part out.
Also I didn’t want plain REST APIs to open my garage and was experimenting with SHA256 encrypted password and it turned out pretty good.
Few notes on very important settings:
in Device Handler settings you have to input Arduino IP address, Port as well as MAC address. MAC address must be all uppercase with no columns. e.g. DEADBEEFFEED
You must have static IP address for your ST hub and hardcode that IP address in Arduino code for it to be able to PUSH to ST hub:
// Smartthings hub information
IPAddress hubIp(192,168,0,50); // smartthings hub ip
const unsigned int hubPort = 39500; // smartthings hub port