[BETA] Wink Relay - Custom SmartThings Integration

Thanks for the feedback. Glad to hear that the initial results are positive.

My concern is more with the long-term. Android has a built in memory management feature which attempts to kill apps/services when the device needs to free up memory. My concern is that the STWinkRelay services will all be working as expected and turn the LCD backlight off as expected and then Android could kill the services which would prevent the screen from turning back on. The workaround would be a simple reset with the physical button below the screen (or ADB to relaunch the app). I added in some code to promote the services to be foreground services which would normally make it extremely unlikely that Android would kill the app, but the Wink Relay is a pretty resource constrained device so it wouldn’t surprise me! If the issue does crop up I think the next step would be make the STWinkRelay app a system app.

3 Likes

Using this app, can I make the bottom button, which is not connected to any load, trigger a ST routine or device? If so, how?

Yes, the button events are always sent over to SmartThings even if you don’t have them controlling a load.

You can use any of the SmartThings rule engines to use the button presses to trigger Routines, control devices, etc. For example, you could use webCoRE to monitor the topButton and/or bottonButton attributes and react to those.

I’m not at home to test, but something like the following would probably work:

Note that the bottomButton and topButton attributes work like a momentary switch. While the button is pressed down, the value will be on and as soon as you let go of the button the value will change back to off.

image

Sounds like this will be the kick in the butt I need to finally get webCoRE setup and working. I’m planning on setting up the top button to control all the smart bulbs and a led strip in my den

1 Like

Awesome! Let me know how it works.

We can update the TTAS Wiki entry for the Wink Relay to include your current instructions here…
Replacing everything after step 32 with this integration would likely make things infinitely easier to use and bring the document into the present.

I wrote the article, but stepped away from my multiple Wink units because of software updates and the modified APK not being updated. I’d love to bring them back into the mainstream again, possibly with a semi-official app integration into the Wink app with ActionTiles.

1 Like

Thanks for the suggestion! I’d like to give this a bit more ‘burn-in’ time before suggesting the masses use the OEM Disabler feature per my comment in post #134. I want to make sure the foreground service approach is sufficient and if not I’ll get my other Wink Relay installed and test out the System App approach.

I ran into some issues with the android app on the Wink Relay. It installed without issue, but when I launch it, I get a grey screen for half a second, then it goes away and the app is no longer running.

This is the unit I wrote the documentation with, so it’s been attached to the wall for the last many many months and I’ve done nothing more than use it for light control using IFTTT integration. I may have to wipe it and start fresh, which is no big deal… Has anyone else had a similar issue? If so, how did you resolve?

A couple things you might try. You might start by trying an older version of the APK. While I can’t think of anything off the top of my head I suppose it’s possible that this new 0.3.0 version is dependent upon something in a previous version being there first.

The other thing you could do that would be helpful in diagnosing the issue is to run logcat while you try to run the app. If it is crashing for some reason, logcat should have it in the logs.

1 Like

That fixed it. Uninstalling the newer version, then adb installing the old version and running it prompted me for root access. Once I was able to run it as root, I tested the switch control from the app, and then when that worked updated the app to the latest version.

I’m now able to directly automate my front porch instead of relying on faulty IFTTT logic that never really worked right.

Phenomenal work! The Relay is now a feasible piece of equipment for the ST platform.

1 Like

Thanks for the update. I’ll take a look and see if I can recreate on my side and fix.

I’m happy to report that using your app for button/relay control and disabling the OEM app fixed the problem I was having with the buttons acting weird (bottom button turning the top relay on when depressed and back off when un-pressed, and top button acting flakey turning the relay on and immediately off at times). The toast notifications for top/bottom button pressed are also accurate now. This is a really elegant solution.

1 Like

Awesome! Glad to hear it’s working well for you and thanks for reporting your success!

Perhaps this is more on a webCoRe question, but when i do a:
if Wink Realy bottombutton changes to on, then Reading Light turn On
it doesn’t work. The only way to make it work is to add an else statement:
if Wink Realy bottombutton changes to on, then Reading Light turn On else Reading light turn on.

Any idea why?

Great app, I am having a little problem. It seems that the app is going to sleep or something like that. When left alone for a while and then i go try to turn on the top button to turn on the load it is connected to it doesn’t work. If i wake the screen up first and wait a second then it will work.

I haven’t experienced that yet, but I’ve only had the new code running consistently for about 5 days now. The unit should wake the screen whenever buttons are pressed.

Just so I’m following correctly, you have the OEM app disabled and you have the top button configured in the STWinkRelay app to ‘Toggle Relay 1’? And when the screen is on and you tap the top button, relay 1 toggles on/off as expected. But if you wait 15 seconds and let the screen turn off, then when you tap the top button, relay 1 doesn’t toggle on/off? Does the LCD screen backlight turn on when you press the top button in this scenario? If so, when it comes on do you see the toast message showing the button event?

Also, are you leaving the STWinkRelay app running in the foreground or do you typically have another app/screen up?

What events are you seeing come across for bottomButton? You can see the history of the events in the SmartThings IDE > My Devices > Wink Relay > Current States: bottomButton

image

the bottombutton state is on

It happened twice but I haven’t been able to reproduce. When it did happen:
you have the OEM app disabled and you have the top button configured in the STWinkRelay app to ‘Toggle Relay 1’? yes
And when the screen is on and you tap the top button, relay 1 toggles on/off as expected. But if you wait 15 seconds and let the screen turn off, then when you tap the top button, relay 1 doesn’t toggle on/off? Correct except it was more like 3-5 minutes not 15 seconds
Does the LCD screen backlight turn on when you press the top button in this scenario? No, unless i touch the screen to wake it up first
If so, when it comes on do you see the toast message showing the button event?Can’t answer becuase screen doesn’t come on with button touch.

I think I’ve found an issue with the GPIO interrupts for the buttons and I believe that issue may be causing at least your second issue (if not both). I’ve primarily just been using the top-button, so I wasn’t experiencing the issue (at least not frequent enough to notice it).

I’ve been putting the system through some harder tests to try to reproduce your issue and I noticed there is a potential issue with the way the interrupts are being handled in native C code (which is called from Java). I’m still trying to figure out how to properly solve it, but just wanted to let you know that I’m looking into it.