Toggle HomeAssistant groups from Wink Relay buttons!

Ok, so Wink doesn’t support my favorite switch/bulb brand TP-Link. But, I was able to make ANY light/switch brand you have added in home assistant work on relay.

  alias: Turn on lights when relay button pressed
    platform: state
    entity_id: binary_sensor.wink_relays_bottom_button
    from: 'off'
    to: 'on'
    service_template: homeassistant.{% if is_state('light.Window', 'off') %}turn_on{% else %}turn_off{% endif %}
    entity_id: group.lights

Automation is monitoring wink relay button being pressed, if so it is checking if light.window is on. If it is turn everything off, otherwise turn everything on.

This creates a toggle of all the lights in “group.lights”. I have combined switches and bulbs in that group and they all work great.

Note: ‘light.window’ is just a random light I have. By reading its state it will decide whether to turn the lights on or off. If it’s off they turn on, if its on they turn off.


The Wink Relay has a bad reputation due to buggy/slow software, but is well worth the money. $50 allows you to control two power loads, 4 switches (two physical with short and long press), a monitor temperature, motion/proximity, and humidity all in one. Plus it is basically a small android tablet mounted on your wall with Bluetooth and a speaker. Just avoid the wink app and you’re set! I don’t even have a wink hub. I just keep home assistant’s new kiosk mode open in the web browser and add anything I want to control to the group. Working on setting up TTS notifications - the android version isn’t recent enough to support Lannouncer. Let me know if you find a solution for this.

Do the physical buttons still work with the Relay if you disable the Wink App?

No, they don’t, but there are a few solutions for sideloading with MQTT. I have have 3 wink relays and no hub - working perfectly entirely on my local network:

  1. Factory reset your relay, connect it to wifi, and install a home button & launcher as described here
  2. I’d avoid KingRoot and root it via abd using this guide
  3. Install the MQTT client to integrate sensors/switches - a precompiled version was just uploaded here
  4. Configured with home assistant as MQTT sensors and switches, install pandora/youtube/others, and configure your nova launcher homescreen or run home assistant in Kiosk mode
  - platform: mqtt
    state_topic: "wink_master_bath/sensors/temperature"
    name: "Master Bath Temperature"
    expire_after: 1200
    value_template: '{{(float(value) * 9 / 5 + 32) | round(1)}}'
    unit_of_measurement: "°F"
  - platform: mqtt
    state_topic: "wink_master_bath/sensors/humidity"
    name: "Master Bath Humidity"
    expire_after: 1200
    value_template: '{{value | round(0) | int}}'
    unit_of_measurement: "%"

  - platform: mqtt
    name: "Master Bath Main Light"
    state_topic: "wink_master_bath/relays/upper_state"
    command_topic: "wink_master_bath/relays/upper"
    payload_on: "ON"
    payload_off: "OFF"
  - platform: mqtt
    name: "Master Bath Shower Light"
    state_topic: "wink_master_bath/relays/lower_state"
    command_topic: "wink_master_bath/relays/lower"
    payload_on: "ON"
    payload_off: "OFF"

  - platform: mqtt
    name: "Master Bath Upper Button"
    state_topic: "wink_master_bath/switches/upper"
    expire_after: 12
    payload_on: 'on'
  - platform: mqtt
    name: "Master Bath Lower Button"
    state_topic: "wink_master_bath/switches/lower"
    expire_after: 12
    payload_on: 'on'

Then add an automation so a button press toggles the switch.

It looks like the smartthings community is building a dedicated sideloaded interface for the relay. I haven’t tried it but will be watching to see what kind of traction it gets.


@Woodsmith Here’s an example of an automation I’m using with my Wink Relay that doesn’t require making a binary sensor:

- id: ten
  alias: Wink Relay - Lower Switch
    - platform: mqtt
      topic: winkrelay/switches/lower
      payload: 'on'
    - service: light.toggle
      entity_id: light.living_room_floor_lamp

Similarly, you could also use service: switch.toggle and toggle the MQTT switch you made that controls the relay itself.

With respect to wink-relay-handler, the repo you pointed to is mine but doesn’t actually contain the compiled version. You can find it at the original repo mine was forked from, currently attached to a pull request I opened. Not sure if the original author plans to implement my PR but you can grab the compiled version there for now anyway.

Nice - I didn’t realize you could subscribe to MQTT topics directly in an automation. Less entities to keep track of…which I need (albeit it’s harder to debug if issues come up). I appreciate the fork/compile.

Will your trigger fire on each button press? There is a small issue with my binary sensors above - ‘expire_after’ is only implemented for non-binary MQTT sensors at the moment. So it never resets, and thus my downstream triggers never fire. When I realized this I just added an action to my toggle automation to publish ‘off’ back to ‘winkrelay/switches/lower’ - sloppy solution by resetting the state. And it only works if the switches are set as optimistic…I was chasing the sunk time rather than restarting and doing it right.

Long term I want to change this to a counter that recognizes double and triple taps (e.g. within 3-5 seconds). Then trigger casting different channels (news, music genre 1, music genre 2, etc) to my relay in the bathroom, which I have connected to this brilliant flood light speaker via bluetooth - sounds quality is remarkable for the price.

So, assuming it all comes together as planned, for $55 + $16 it will deliver 2-6 buttons, 2 load controls, a touch screen, thermometer, humidity sensor, proximity sensor, audio/video remote/player, and intercom/microphone (sideload alexa/google api perhaps?). Before going there, I still need a robust solution for presence detection. Find anything more here? It’s a drag pushing a button every morning just to get the weather, train/drive times, uber/lyft prices, and news update! The proximity value seen in the wink api is a start (also, it seems like the rooted proximity is less sensitive, based entirely on when the screen turns on) - closer to 1ft rather than the 1.5-2.5 that I was getting through the wink cloud). Perhaps wink uses light or sound sensors to help determine proximity?

Yes, the automation I posted fires on each button press (because the wink button press just publishes “on” each time it is pressed). Definitely saves you having to do some fancy trick to reset your binary sensor.

With wink-relay-handler the screen should turn on when the prox sensor is tripped; or are you talking about triggering an automation with a prox detection? I’m also not happy with the prox sensitivity (for me it’s about 5-10cm I would say) and have been investigating another solution for triggering the screen to come on. There is a light sensor available but I need to do some tests to see how it reacts to presence because I wouldn’t think it would be usable for that purpose but only testing would tell. I’ve just gotten used to waving my hand in front of the prox at the top to turn it on.

If you are taking about triggering an automation when the prox is tripped, that should be relatively easy to accomplish in wink-relay-handler. Let me know!

Read through that link - there isn’t an alternative app. Basically all that modified app does is allow you to keep the stock Wink app but not have it wipe the credentials of all your other programs (home assistant, ecobee, etc) every hour or so.

you ever figure out how to TTS to a wink relay?

Yes, by installing Kodi. Not the best solution, since Kodi is rather resource intensive, but it works. You can push any audio or video file to the relay and it plays just fine.

I’m working on configuring a whole-home audio setup with synchronized zones/rooms that accepts various input sources (pandora, bluetooth, airplay, DLNA, etc). Similar to Sonos but open-source. For that I’m hoping to have a server (that accepts external inputs) be the “source” and have my relays be one of many “clients” (some of my relays are permanently paired to bluetooth speakers of much better quality). There are projects out there for this, but configuring everything requires some time. For now I have the relays accepting wifi audio streams via AirPin. AirScreen and AirReceiver are two other apps I’ve tried, but AirPin was the one that worked best for me and is free. It’d be better if it were recognized as a chromecast device rather than airplay - let me know if you find anything for this.

Sorry for the delay, was backpacking South America with my girlfriend for a while. You’re a king and your script is your crown. The MQTT actions work great. The only issue I have is that the relay occasionally has to be reset/restarted (either when HA or my home router is restarted). I’m guessing the relay’s MQTT sevice connection is timing out? A fix for this would be huge, as right now having a smart switch doesn’t justify having the dumb switch only work 90% of the time.

As for the prox sensor, yes, the screen is turning on, but it’d be nice to have a published topic for this, even if it doesn’t have the same range as the native Wink sensor. I can’t find any existing app/service that notices the proximity or light sensors. And it baffles me that Wink’s app reacts at 2+ feet (enough to pickup someone walking by in a hallway) while the proximity sensor’s distance alone is so poor (< 6 inches). We are using the same hardware…so they must be using a combination of proximity, light, and perhaps sound together to trigger presence? If you can mod your script to also publish the light and/or sound levels, I’ll mount one of my motion sensors to the top of a relay for a week and use the resulting data to train the sensor levels to detect “presense”. That’s my best guess as to how Wink is doing it. I’m more of a data scientist than a developer, but together no reason why we can’t tackle this…

Shouldn’t be a problem at all to add publishing a message when the prox is tripped. I’ll get to it in the next couple of days and let you know when I do.

As for the issue of the relay needing to be reset, I can’t say I’ve noticed this when restarting HA, though I haven’t tried after restarting my router. I’ll take a poke at the code around the mqtt connection and see if it’s maybe not trying to reconnect as robustly as it should.

1 Like

I confirmed it only happens when the Relay’s wifi connection is lost (router reboot, etc). Haven’t had an issue restarting HASS, but may happen if the MQTT server on HASS is down for a long time.

Thank you for this! Works very well and makes the wink relay very useful!
I can confirm that if the MQTT server goes down for any length or if the app loses connectivity to the MQTT server then the MQTT server does not get any messages from the relay and hence loss of control of the relays. The only option is to reset the wink relay or kill the wink-relay (edsionwink) app-in which case it starts working again. If HA is restarted or killed it doesnt seem to be a problem (I have a separate MQTT server).
Since I have just discovered and learning HA I have frequent restarts so creating a few challenges! Any way if you could look at auto reconnecting would be great.

One other request if is possible without extensive changes, would it be possible to add a parameter to the ini file - when the wink relay restarts it turns on both relays, if there could be a parameter that could be set to control the behavior (so I could set it up that on restart/reboot it ether turns on or off).

Thanks for the awesome work!

Better yet, if there is a way to make the relay buttons control the load directly when the MQTT Server is down, that would be a better solution. Of course some prefer to use the buttons to control scenes and not the load directly, so it would need to have a config setting for this or be setup to only control the load when the MQTT server is unreachable. I know this is all open source and I may be dreaming, but throwing ideas out there…

I tested a lot last night - restarting HASS, my mqtt broker, and wifi like crazy and can’t reproduce your issue. After HASS and mqtt are back online, my relay buttons work again to trigger the HASS automations I’ve setup.

I’m wondering if there are differences in the Wink relay hardware. My guess is yours is having a hard time reconnecting to wifi, and so of course the mqtt client can’t reconnect.

Strange, I can reproduce the problem every time I restart the mqtt server. I am connected to the wink relay via adb so its not a wifi issue. Restarting HA doesnt have this problem. Are there any logs I could check, am on a shell to the wink relay.
Are you using the embedded HA MQTT server, wondering if that is the difference.

And I have tried the above on two different wink relays.

I’m using mosquitto.

So is mine, are there any parameters in the mosquitto.conf file that needs to be set?
Can I enable any logs on the wink relay to see why no messages pass from the relay to the server after a restart of the mqtt server? Thanks for your help on this!

Did you see this recently opened issue on the original author’s repo? . I think the mqtt code probably needs to be made a bit more robust to handle reconnections.