[OBSOLETE] Wink Relay - Custom SmartThings Integration

I’ve developed a custom integration for connecting the Wink Relay to SmartThings and would like to share it with the community. With the integration, you can control the light loads (relays) and get instant status updates for the sensors, light loads, and button presses. The integration is all performed over your local network with no additional dependencies on IFTTT, Stringify, or other cloud services.

:stop_sign: This integration was originally written for Groovy and does not work since SmartThings shutdown Groovy in 2023. The source code for the Groovy Device Type Handler (DTH) and SmartApp are open source and available below if anyone from the community wants to take over and port things to an Edge Driver.

Developer Note: I am not personally using Wink Relay devices any more, but the integration remains available for you to use! While I love the form factor, I prefer running a larger wall mounted tablet with the SharpTools.io dashboard now:

image

The integration is comprised of three components:

  • Custom app which runs on the Wink Relay
  • Custom SmartApp for automated device discovery
  • Custom Device Type Handler

image

I would emphasize that this is a beta release - several people have tested it at this point, but there may still be outstanding bugs.

Included Features

I’ve focused primarily on the two-way communication between SmartThings and the Wink Relay. This includes the following features:

  • Instant Status Updates for:
    • Temperature*
    • Humidity*
    • Proximity**
    • Relay 1 and Relay 2
    • Top and Bottom Buttons
  • Control:
    • Relay 1
    • Relay 2
    • Both relays simultaneously
    • Screen backlight
  • Additional Features
    • Disable base Wink Relay app
    • Screen wake on touch
    • Buttons control the relays
    • Buttons can be mapped to other actions

*The temperature and humidity will only post an update to SmartThings if they change by more than 0.5 units each.
**The proximity will only change when it has changed more than 100 units.

Notable Exceptions

Proximity values are currently sent across as the raw value anytime the raw number changes more than 100 units. It’s not clear to me what the unit of measure is for the proximity sensor, so I’ll need to investigate this further before I feel comfortable adding some logic to map it to a motion attribute.

I’ve added a wake-on-motion feature to the STWinkRelay APK which lets you set a proximity threshold for waking the screen. Like many others, I found that the proximity values drifted throughout the day. If anyone figures out a better heuristic for waking the screen, please feel free to share it.

Other Features

This release includes a few additional features which are not exposed in the device tiles, but may be helpful in other SmartApps and Integrations.

Wink Relay Buttons
The status of the Wink Relay buttons are mapped to attribute values in the device handler, but do not display in the device tiles. My thought is some people may want to use the buttons to trigger events in other SmartApps. For example, you might use the buttons to trigger an action in WebCoRE or on other Android devices with SharpTools.

Screen Backlight Control
The screen backlight can be controlled with the screenBacklightOn() and screenBacklightOff() commands. These can be called from other custom SmartApps like WebCoRE or SharpTools.

Installation

High Level Instructions

  1. Open the SmartThings IDE and:
    1. Install the SmartApp
    2. Install the Device Type Handler
    3. Install the Child Device Type Handler
  2. On the Wink Relay (achieve root and install the custom app):
    1. Root your Wink Relay
      Note: See the Rooting Instructions section below for details.

    2. Install the STWinkRelay.apk custom app
      Note: You can either do this by opening the STWinkRelay APK using your web browser (if you still have it) or install via ADB. For the web-browser approach, make sure you have “Unknown Sources” allowed for installation.

      ADB Details

      For the ADB approach:

      1. Download the STWinkRelay.apk to your computer
      2. Open a command prompt / terminal
      3. Change directory to the location where you downloaded the apk
      cd C:\users\{youraccount}\Downloads
      
      1. Run the installation command:
      adb install -r STWinkRelay_1-0-0a.apk
      

      Note: You will either have to have ADB in your path or have ADB accessible in the same directory in which you have the APK downloaded. If you have installation protection enabled from KingRoot, be sure to approve the installation physically on the device before the timer runs out.

    3. Open the custom Wink Relay app at least once
      Note: If you have root management enabled, be sure to approve the permission request on the physical device before the timer runs out.
      Note: There are a number of services which run in the background including device discovery, services for watching the sensors and buttons, and a web server for SmartThings to send commands to the device. These services are set to automatically start when the device is booted, but you may have to open the app once immediately after installing it in order to kick off the services.

  3. On the SmartThings Mobile App:
    1. Navigate to the Automation tab at the bottom of the screen
    2. Navigate to the SmartApps tab at the top of the screen
    3. Scroll down to the bottom of the screen and select “Add a SmartApp”
    4. Scroll down to bottom of the list and select “My Apps”
    5. Find “Wink Relay” and tap to continue.
    6. Wait for the Device Discovery to complete
    7. After selecting your device from the list, select Save to complete the installation of your device

You should now have a working ‘Wink Relay’ device in your Things list! Open the device from your Things list and tap refresh to make sure everything is synced up.

Rooting Instructions

Use the Wink Relay wiki entry on ThingsThatAreSmart.wiki as a reference:
http://thingsthataresmart.wiki/index.php?title=Wink_Relay

:warning: Important: Stop at step 32. You should not need the Root Package Disabler or any adb commands for this project.

Tips and Tricks:

  • You may want to factory reset your Wink Relay before proceeding with the rooting / installation steps (see the section immediately below)
    How to Factory Reset
    1. While holding top right switch (physical button) on Relay, press soft reset button underneath faceplate
    2. Continue holding top right button until “System recovery” screen appears
    3. Press bottom switch twice, or until “wipe data/factory reset…” is highlighted
    4. Press top switch once to select “wipe data/factory reset…” option
    5. Screen will display message - “Confirm wipe of all user data? THIS CAN NOT BE UNDONE”
    6. Using bottom switch, navigate down until “Yes - - delete all user data” is selected
    7. “Wiping data… Formatting /data…” screen will appear, followed by original “System recovery” screen
    8. Press top switch to select “Reboot system now” option. “ERROR” may appear on screen, this is normal.
    9. Relay will reboot, and should eventually load main Relay home screen. If home screen does not load, Relay may require one more soft-reset (press button under faceplate).
  • You may have to install an old version of Assistive Touch - the Wink Relay is running an old version of Android, so newer versions might not work.
  • Many people have chosen to use Firefox instead of Chrome (again, you may have to use an older version of the software)
  • In the section about Setting up the Wink Software, this part might not be absolutely required.
    • We’ll see if the updates stay available when Wink starts requiring a paid subscription.
    • It’s unclear what’s included in the updates, but I believe at least one of the updates changes the default screen resolution
  • Some users have noted that the KingRoot website is no longer available, but you can install KingRoot directly from APK Pure

:information_source: If anyone wants to update the Things That Are Smart Wiki entry, please go ahead and do so! The original wiki entry author posted in this thread that they are supportive of that decision.

Upgrading from Older Versions (<1.0)

How to Upgrade from Old Versions

From the Wink Relay:

  1. Open the existing STWinkRelay app
  2. Tap the Settings icon in the top-right corner
  3. Tap General > Update
  4. Tap the Get Update button

It will try to download and install the update, but won’t be able to complete it

  1. Navigate back to your homescreen and open the app drawer
  2. Long-press on the existing STWinkRelay app and uninstall it
  3. Open the Downloads app
  4. Select the STWinkRelay_1-0-0a file that should be in the downloads folder already
  5. Open the new STWinkRelay app and enjoy!

Alternatively, you can download things manually via a web browser on the Wink Relay (or install via ADB). Instructions are available at http://wink.boshdirect.com

25 Likes

Placeholder…

I may actually have to pull the trigger on this device now that you have something so straightforward set-up.

Thanks for putting all this work in.

3 Likes

I’ve tried this on 2 separate Relays now, and neither of them is being found during the Discovery? The app has been launched once on the relay and the services are running on it. @joshua_lyon is there something else I could be doing wrong that would cause this? Thanks!

1 Like

I have also tried it but the SmartApp coulding find the Wink Relays

1 Like

same here tried it but device cannot be discovered

1 Like

Thanks for the feedback guys. I’ll debug the discovery process again and figure out what’s going on. Might be a bug introduced in the final packaging step.

1 Like

Thanks! Excited for this and appreciate your work on it!

1 Like

Can you provide logs from SmartThings of what’s happening during the discovery process? I completely removed all traces of the SmartApp, Device Handler, and custom STWinkRelay app from my setup and went through the instructions from the post above reinstalling everything and the discovery completed successfully within 10-30 seconds. Maybe the logs will have some clues as to what’s different with your setup(s).

From the SmartApp side, you should see something like the following… from the bottom up, the device discovery starts, your device responds to the initial SSDP request, the SmartApp grabs the XML file and validates the device, then on the next loop the device is presented to the user (eg. it’s in the shortlist and verified).

9:10:25 PM: debug Devices at start of ssdpHandler: [uuid:2f9e00f8cbd2b6d8:[model:CustomWinkRelayApp, ssdpUSN:uuid:2f9e00f8cbd2b6d8, verified:true, networkAddress:C0A80150, name:Wink Relay}}, ssdpNTS:null, serialNumber:Serial Number Missing, deviceAddress:1F90, mac:B479A71AD946, devicetype:04, hub:568201e4-43f7-4ada-923e-c3a246d69a96, ssdpPath:/device.xml, ssdpTerm:urn:sharptools-io:device:WinkRelay:1, stringCount:04]]
9:10:25 PM: debug [devicetype:04, mac:B479A71AD946, networkAddress:C0A80150, deviceAddress:1F90, stringCount:04, ssdpPath:/device.xml, ssdpUSN:uuid:2f9e00f8cbd2b6d8, ssdpTerm:urn:sharptools-io:device:WinkRelay:1, ssdpNTS:null, hub:568201e4-43f7-4ada-923e-c3a246d69a96]
9:10:25 PM: debug Found device in our short list: uuid:2f9e00f8cbd2b6d8
9:10:25 PM: debug Got HTTP response for uuid:2f9e00f8cbd2b6d8
9:10:24 PM: debug Checking value for B479A71AD946 at 192.168.1.80:8080/device.xml
9:10:24 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
9:10:24 PM: debug Running device discovery (page)...
9:10:19 PM: debug Adding uuid:2f9e00f8cbd2b6d8 to devices short list
9:10:19 PM: debug Devices at start of ssdpHandler: [:]
9:10:19 PM: debug [devicetype:04, mac:B479A71AD946, networkAddress:C0A80150, deviceAddress:1F90, stringCount:04, ssdpPath:/device.xml, ssdpUSN:uuid:2f9e00f8cbd2b6d8, ssdpTerm:urn:sharptools-io:device:WinkRelay:1, ssdpNTS:null, hub:568201e4-43f7-4ada-923e-c3a246d69a96]
9:10:19 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
9:10:19 PM: debug Running device discovery (page)...

Edit: You should be able to hit the webserver that’s build into the custom STWinkRelay app by going to:
http://your.wink.relay.ip:8080/device.xml

And it should respond with an XML file that’s used as part of the discovery process. This doesn’t necessarily mean that the SSDP part of things is working, but at least means the built-in webserver is working.

(Also, I found a minor bug with the device.xml where your devices will be named Wink Relay}} - I’ve removed the }} for the next build, but want to work through the discovery issues before pushing an update as this only affects the display name)

Confirmed the XML file loads correctly if I bring the IP of the relay up in a browser. Log file seems to just do continuous search without discovering:

157fc83a-a597-476d-beab-70ce39a42a2c 11:41:47 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:47 PM: debug Running device discovery (page)…
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:42 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:42 PM: debug Running device discovery (page)…
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:36 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:36 PM: debug Running device discovery (page)…
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:31 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:31 PM: debug Running device discovery (page)…
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:26 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:26 PM: debug Running device discovery (page)…
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:20 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:20 PM: debug Running device discovery (page)…
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:15 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:15 PM: debug Running device discovery (page)…
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:10 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:10 PM: debug Running device discovery (page)…
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:05 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
157fc83a-a597-476d-beab-70ce39a42a2c 11:41:05 PM: debug Running device discovery (page)…
157fc83a-a597-476d-beab-70ce39a42a2c 11:40:49 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
157fc83a-a597-476d-beab-70ce39a42a2c 11:40:49 PM: debug Running device discovery (page)…
157fc83a-a597-476d-beab-70ce39a42a2c 11:40:48 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
157fc83a-a597-476d-beab-70ce39a42a2c 11:40:44 PM: debug Searching for urn:sharptools-io:device:WinkRelay:1
157fc83a-a597-476d-beab-70ce39a42a2c 11:40:44 PM: debug Running device discovery (page)…

1 Like

XML output from relay:

https://pastebin.com/indSGrDv

1 Like

cannot hit the server from my chrome browser i get connection timed out error
thanks

1 Like

@Pen - excellent - the XML file looks good! Based on your SmartThings logs, it looks like the SSDP requests are being sent, but the reply is never coming in. I’m working on adding some tools to make it easier to review the logs from the Wink Relay device side, but it might take me a bit to put it together. In the mean time, we could pull logs with ADB. Are you familiar with using ADB or pulling logcat logs?

The upside is this means the webserver on your device is working which means you could probably manually create the device and manually enter the MAC address as the Device Network ID to get things working, but I’d like to work with you on troubleshooting the discovery process if you are up for it? It sounds like other people are having similar issues, so it would be be great to find the root cause and fix it.


@Ragai_Meena - what troubleshooting have you tried? Did you open the STWinkRelay custom app at least once as indicated in the instructions above? If so, what was displayed on the screen?The services start upon first reboot of the device or first opening the app. You’ll have to make sure you are in front of the device to approve the root authorization request upon first load as well.

1 Like

Josh thank you so much I was waiting for this app forever I appreciate your great work on it
I did open the app as you instructed and did allow the root access
I only see the buttons for the relays but not the button for refresh values nor the start file watcher button what do I need to do

1 Like

Those additional buttons have been removed in the final version of the app. I’m working on adding some additional logging to the STWinkRelay application so we can see what’s going on. I’ll post the update when it’s ready.

One thing you might double check is that:

  1. The Wink Relay is connected to your WiFi
  2. The computer that you are connected to is on the same network as the Wink Relay (and not restricted from accessing it in anyway)
  3. And double check that you used the correct IP address of your Wink Relay and the URL is formatted correctly. For example, I access my Wink Relay at:
    http://192.168.1.80:8080/device.xml

You might also try rebooting the Wink Relay by tapping the button on the bottom edge of the frame below the screen. Wait for it to boot up and then try accessing the URL again.

1 Like

Just messaged you my logcat log file. Hopefully it has some clues!

2 Likes

i can confirm that I am able to open in webserver the.xml file but only from one winkrelay device
do I need to forward the port on my router?
still no luck with device discovery from the app

1 Like

now I can confirm that I am able to hit the server only when I am on the same wifi that the winkrelay is on, no luck yet to discover the device

1 Like

After rebooting the relay I can also confirm that I’m able to open the xml file but still no luck on the discovery side in ST

2 Likes

I dont know if thats relevant or not but after a few minutes I’m not able to reload the xml anymore

2 Likes