There are 2 ways of installing:
- Integrating with GitHub
- Copy and paste
- Follow the SmartThings documentation to integrate with GitHub
- Log Into the SmartThings IDE (US Users, UK Users)
- Find the My SmartApps link on the top of the page.
- Find the Settings button at the upper-right corner of your SmartThings IDE page (this will only appear after you have configured with GitHub).
- Clicking this button will open the GitHub Repository Integration page. Enter the information below:
- Owner: r3dey3
- Name: st-wifi-devices
- Branch: master
- Close the GitHub Repository Integration page by clicking the Save button.
- Click the Update from Repo button at the upper-right corner of your SmartThings IDE and select 'st-wifi-devices' from the list.
- In the right-hand column you will see smartapps/r3dey3/simple-lan-device-manager.src/simple-lan-device-manager.groovy, select this using the checkbox. Do not select 'README.md'
- At the bottom-right corner of the Update from Repo page, select Publish using the checkbox and then click Execute Update.
- When done syncing, the new SmartApp should now appear in your IDE.
- The code for the SmartApp can be found in simple-lan-device-manager.groovy
- Select all of the code (typically Ctrl+A) and copy it (typically Ctrl+C)
- Next, log Into the SmartThings IDE (US Users, UK Users)
- Find the My SmartApps link on the top of the page.
- Click on the +New SmartApp in the upper-right corner.
- Select the From Code tab along the top section.
- Paste (typically Ctrl+V) the code you copied into the text box
- Click the Create button in the bottom left corner
- This will bring up another page with the code now formatted within the SmartThings IDE.
- Click the Save button in the upper-right corner
- Finally click-on the Publish button and select For Me at the upper-right corner of the screen.
Discovery is performed using SSDP using a schema of urn:schemas-upnp-org:device:st-wifi-dev
. Once discovered, the returned LOCATION is requested to retrieve the device description.
The device description can be the standard UPNP basic device XML or a JSON dictionary with the same keys as the device element in the XML schema.
When the device is discovered, the friendlyName field is what is presented to the User. If the friendlyName isn't present then the modelName is used. When the user adds the device, the manufacturer is used as the namespace and the deviceModel is used as the name. This allows for easy integration with multiple device types without the user having to change the type themselves.
To handle state pushes:
- The Device Handler must send the device the callback URL. This URL can be obtained using
"http://" + parent.GetCallBackAddress(device.hub) + "/"
- Or, you can use
parent.SUBSRIBE(this, "REMOTE_PATH", device.hub)
to send the HTTPSUBSCRIBE
method to REMOTE_PATH with the callback address in theCALLBACK
header.
- Once the device has the callback URL it can make POST requests which will be passed to the parseResponse method of the device handler. (it also hits the parse method, but you can't update state when that happens)
- The
parseResponse
method takes a single Response Argument. This response is a parsed LAN response (usingparseLanMessage
) with the post data in either resp.json or resp.xml or resp.body.
- The
- To update values in the
parseResponse
method usesendEvent()
In all the helper methods for use by a device handler, the device
parameter should be this
Retrieve a url
POST args to URL. If args is a string it is treated as the body, if it's a map, it will be sent as JSON
Send a SUBSCRIBE HTTP method to URL, with the callback address in the CALLBACK HTTP header. args is any extra data (treated same as POST)