Toggle HomeAssistant groups from Wink Relay buttons!

Thanks @jimpastos for wink_manager, I finally got a chance to set it up on my Relay today and it’s working very well. Haven’t had a chance to implement multi-click or hold for the buttons yet but I’m sure I can figure out some use-cases for them.

Re @jaburges problem, I use two automations to handle a light group (which is just several zigbee bulbs in one light fixture):

- alias: LR - Remote - WR Lower (on)
  trigger:
    platform: mqtt
    topic: winkrelay/buttons/1/click/1
    payload: 'ON'
  condition:
    condition: state
    entity_id: group.living_room_floor_lamp
    state: 'off'
  action:
    - service: light.turn_on
      data:
        entity_id: group.living_room_floor_lamp
        brightness_pct: 100

- alias: LR - Remote - WR Lower (off)
  trigger:
    platform: mqtt
    topic: winkrelay/buttons/1/click/1
    payload: 'ON'
  condition:
    condition: state
    entity_id: group.living_room_floor_lamp
    state: 'on'
  action:
    - service: homeassistant.turn_off
      entity_id: group.living_room_floor_lamp 

There’s no real sync problem here as if even one member of the group is on, the group state is on, so a press of the switch turns all of them off, and then another press turns them all on.

2 Likes

Havent really tested the held events fully yet either. They actually repeat (while button is held) i figured we can incrementally dim on each event or something similar.
Or we can build a local intercom and send sound snippets via mqtt too :slight_smile:

Hello again,

I installed the newest version of wink-manager this morning and have some questions.
The relays and button presses are working.
The temperature and humidity sensors are working.

Question - The proximity sensor no longer triggers a mqtt event and I noticed in the build readme there is no mqtt proximity/motion event, is this gone now?

I hope the stability has improved; I will test over the next couple of days.

Thanks for the work, I want you to know I am truly appreciative!

I never ended up implementing the proximity MQTT event. I was wondering what would be the best approach without getting too much noise.
It could be simply when the threshold gets triggered (same as the screen going on), or a different set of criteria.
The actual device has multiple sensors.
It has 3 different measurements for proximity but we only use one.
In addition it has light sensors (separate for visible and infra red) which we could use for other triggers.

Im open to ideas :slight_smile:

I will look at the proximity part, maybe we could make the sensors useful for some events.

Also, another issue has popped up. One of my relay’s screen is stuck on. I can turn it off with a mqtt screen event but it comes back on immediately. BTW I enabled the status bar in wink_manager.ini, I am using qemu.hw.mainkeys=0 in my build.prop and like having the status bar and navigation bar. However my other wink relay screen with the same settings works just fine.

Thanks again.

1 Like

Never mind, sorry. The proximity setting was set low (3000) to test, resetting to 5000 fixed the screen timeout.

1 Like

How difficult would it be to add an option for publishing the values of the 3 proximity sensors to the MQTT stream? That would empower the user and get some more ideas and test data coming. A simple percent or absolute change would work to trigger it, or to start just publish all 3 when the screen turns on.

publishing is easy, when to trigger the publish is tricky.
Currently we use the first value and have a threshold, once it goes above a certain value (default 5000) we trigger the screen to come on for a certain amount of time.
We can just send the values on a fixed interval but thats not ideal :slight_smile:

Ideally we should figure out what the actual values represent. I tried to look at the source code of the driver, but it doesn’t clarify what the values are, other than the sensor has Led A, B and C. Maybe with some experiments and trial/error we can figure out what they represent.

The values are actual posted to /dev/input/event3, 1 line per value

@jimpastos - had a few minutes to play around with the held message and here’s an automation I came up with that, when the button is held down, will progressively dim a light until it turns off. It dims in steps of about 10%. To change that, change the 25 below to a different value (25/255 = approx 10%).

- alias: LR - Remote - WR Upper (Dim)
  trigger:
    platform: mqtt
    topic: winkrelay/buttons/0/held/1
    payload: 'ON'
  action:
    service: light.turn_on
    entity_id: light.living_room_ceiling_light
    data_template:
      brightness: >
        {% set bright = states.light.living_room_ceiling_light.attributes.brightness %}
        {% if bright > 25 %}
          {{ bright - 25 }}
        {% else %}
          0 
        {% endif %} 
1 Like

Nice, next is to do the reverse. Increase brightness with double tap and hold. you’ll get event on “winkrelay/buttons/0/held/2” :slight_smile:

Can anyone post a binary of wink_manager, or maybe jimpastos can add the binary to Github? I am currently using wink-handler but would like to take advantage of the newer adds to this version. I’m using Win10 and not looking forward to the compile hoops. Thanks.

I managed to get the app compiled under Win10 ubuntu. Great update to the original wink-handler, thanks to jimpastos!

1 Like

@mterry63 Any chance you can share a precompiled binary? I’m trying to avoid setting up a whole build chain in order to try this out… Thanks!

here you go.

1 Like

Which commit is this based on? Also, it might help others and encourage more development if you add it to @jimpastos repo on GitHub.

Awesome. Thanks a lot!

Just added a new feature on the repo that gives the ability to disable the all touches when double clicking a preconfigured button (config with Flags).

One of my relays seems to be registering ghost touches when the room is too hot and humid and its toggling a bunch of stuff which is really annoying.

Now i can simply double click a button and the touch screen will stop registering any touches (blocks the rest of the OS too). Proximity and buttons will still turn the screen on, but you’ll have to double click the button to re-enable touches.

In addition, I added a precompiled binary (v1.0) in Releases as requested

3 Likes

Hey guys-

I need some help… I got this working, and I am able to successfully get the events from my mqtt (Mosca); however, I can not set the state via mqtt. It is definitely an issue w/ my HASS switch config as I can set the state via mosquito-publish successfully.

Here is my ini file

mqtt_clientid=Relay
mqtt_topic_prefix=Relay
mqtt_address=tcp://myhost:1883
screen_timeout=20
proximity_threshold=5000
hide_status_bar=true
relay_upper_flags=1
relay_lower_flags=2
send_proximity_trigger=true
send_screen_state=true
debug=true
log_file=/data/local/tmp/wink_manager.log

and here is my switch conf:

- platform: mqtt
  name: "Front Porch Light"
  state_topic: "Relay/relays/0/state"
  command_topic: "Relay/relays/0"
  payload_on: "on"
  payload_off: "off"
- platform: mqtt
  name: "Foyer Light"
  state_topic: "Relay/relays/1/state"
  command_topic: "Relay/relays/1"
  payload_on: "on"
  payload_off: "off"

When I sent an “on”, i see the following in the HASS logs, but nothing at all in the Wink Manager logs

2018-10-27 20:54:02 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on Relay/relays/0: on
2018-10-27 20:54:02 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on Relay/relays/0: b'on'

OK NEVERMIND… the answer is the payload_on and payload in hass appears to only work with the correct uppercase syntax i.e. ON and OFF and not on or off

Thank you for this @jimpastos!

I have your HA Wink integration running, while also using it in conjunction with the STWinkRelay.apk
https://community.smartthings.com/t/beta-wink-relay-custom-smartthings-integration/111732.

The top button controls the bathroom light, while the bottom one controls the bathroom’s extraction fan and so this Wink Relay now replaces an electronic timer switch that had multiple settings of 10, 20, 30 & 60 minute durations.

I wrote a node-red flow(?) that lets me replicate the functionality of the timer switch using the MQTT button event topics, so that:

  • 1 click = 10 minutes
  • 2 clicks = 15 minutes
  • 3 clicks = 20 minutes

I’m quite the newb at MQTT, node-red and HA in general so I’m quite proud of myself. If anyone wants to use the same flow, or show me how it could be improved, please take a look at the below:

[
    {
        "id": "afd2a74b.3c69d8",
        "type": "tab",
        "label": "Fan control timer",
        "disabled": false,
        "info": ""
    },
    {
        "id": "da03f7e9.f40cc8",
        "type": "mqtt in",
        "z": "afd2a74b.3c69d8",
        "name": "Fan Button Listener (1x)",
        "topic": "Relay/buttons/1/click/1",
        "qos": "2",
        "datatype": "auto",
        "broker": "dafc92a1.fc8ce",
        "x": 100,
        "y": 20,
        "wires": [
            [
                "c278a14e.bad0e"
            ]
        ]
    },
    {
        "id": "abd171d1.938df",
        "type": "api-call-service",
        "z": "afd2a74b.3c69d8",
        "name": "Turn on Fan (10)",
        "server": "337b22fd.b997ae",
        "version": 1,
        "service_domain": "switch",
        "service": "toggle",
        "entityId": "switch.master_bath_fan",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 320,
        "y": 80,
        "wires": [
            [
                "77dd7347.af699c"
            ]
        ]
    },
    {
        "id": "2cbf97fa.8c21d8",
        "type": "api-call-service",
        "z": "afd2a74b.3c69d8",
        "name": "Turn on Fan (15)",
        "server": "337b22fd.b997ae",
        "version": 1,
        "service_domain": "switch",
        "service": "toggle",
        "entityId": "switch.master_bath_fan",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 320,
        "y": 260,
        "wires": [
            [
                "c1798a62.0b81a8"
            ]
        ]
    },
    {
        "id": "2d36d2eb.0c0fae",
        "type": "api-call-service",
        "z": "afd2a74b.3c69d8",
        "name": "Turn on Fan (20)",
        "server": "337b22fd.b997ae",
        "version": 1,
        "service_domain": "switch",
        "service": "toggle",
        "entityId": "switch.master_bath_fan",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 320,
        "y": 420,
        "wires": [
            [
                "583b50e9.09567"
            ]
        ]
    },
    {
        "id": "77dd7347.af699c",
        "type": "ha-wait-until",
        "z": "afd2a74b.3c69d8",
        "name": "Timer (10)",
        "server": "337b22fd.b997ae",
        "outputs": 2,
        "entityId": "switch.master_bath_fan",
        "property": "state",
        "comparator": "is",
        "value": "1",
        "valueType": "num",
        "timeout": "10",
        "timeoutUnits": "minutes",
        "entityLocation": "",
        "entityLocationType": "none",
        "checkCurrentState": true,
        "blockInputOverrides": true,
        "x": 500,
        "y": 80,
        "wires": [
            [],
            [
                "94c04950.6db018"
            ]
        ]
    },
    {
        "id": "c1798a62.0b81a8",
        "type": "ha-wait-until",
        "z": "afd2a74b.3c69d8",
        "name": "Timer (15)",
        "server": "337b22fd.b997ae",
        "outputs": 2,
        "entityId": "switch.master_bath_fan",
        "property": "state",
        "comparator": "is",
        "value": "1",
        "valueType": "str",
        "timeout": "15",
        "timeoutUnits": "minutes",
        "entityLocation": "",
        "entityLocationType": "none",
        "checkCurrentState": true,
        "blockInputOverrides": true,
        "x": 500,
        "y": 260,
        "wires": [
            [],
            [
                "94c04950.6db018"
            ]
        ]
    },
    {
        "id": "583b50e9.09567",
        "type": "ha-wait-until",
        "z": "afd2a74b.3c69d8",
        "name": "Timer (20)",
        "server": "337b22fd.b997ae",
        "outputs": 2,
        "entityId": "switch.master_bath_fan",
        "property": "state",
        "comparator": "is",
        "value": "1",
        "valueType": "str",
        "timeout": "20",
        "timeoutUnits": "minutes",
        "entityLocation": "",
        "entityLocationType": "none",
        "checkCurrentState": true,
        "blockInputOverrides": true,
        "x": 500,
        "y": 420,
        "wires": [
            [],
            [
                "94c04950.6db018"
            ]
        ]
    },
    {
        "id": "94c04950.6db018",
        "type": "api-call-service",
        "z": "afd2a74b.3c69d8",
        "name": "Turn off Fan",
        "server": "337b22fd.b997ae",
        "version": 1,
        "service_domain": "switch",
        "service": "turn_off",
        "entityId": "switch.master_bath_fan",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 690,
        "y": 180,
        "wires": [
            []
        ]
    },
    {
        "id": "5d2dbe42.b0fbf",
        "type": "mqtt in",
        "z": "afd2a74b.3c69d8",
        "name": "Fan Button Listener (2x)",
        "topic": "Relay/buttons/1/click/2",
        "qos": "2",
        "datatype": "auto",
        "broker": "426ef3a3.09388c",
        "x": 100,
        "y": 180,
        "wires": [
            [
                "d8e519bf.a34f28"
            ]
        ]
    },
    {
        "id": "6bc8f206.de3d8c",
        "type": "mqtt in",
        "z": "afd2a74b.3c69d8",
        "name": "Fan Button Listener (3x)",
        "topic": "Relay/buttons/1/click/3",
        "qos": "2",
        "datatype": "auto",
        "broker": "a76dc38a.2d32c",
        "x": 100,
        "y": 340,
        "wires": [
            [
                "67dd7421.c4791c"
            ]
        ]
    },
    {
        "id": "c278a14e.bad0e",
        "type": "api-current-state",
        "z": "afd2a74b.3c69d8",
        "name": "Fan status",
        "server": "337b22fd.b997ae",
        "version": 1,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "switch.master_bath_fan",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 290,
        "y": 20,
        "wires": [
            [
                "94c04950.6db018"
            ],
            [
                "abd171d1.938df"
            ]
        ]
    },
    {
        "id": "d8e519bf.a34f28",
        "type": "api-current-state",
        "z": "afd2a74b.3c69d8",
        "name": "Fan status",
        "server": "337b22fd.b997ae",
        "version": 1,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "switch.master_bath_fan",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 290,
        "y": 180,
        "wires": [
            [
                "94c04950.6db018"
            ],
            [
                "2cbf97fa.8c21d8"
            ]
        ]
    },
    {
        "id": "67dd7421.c4791c",
        "type": "api-current-state",
        "z": "afd2a74b.3c69d8",
        "name": "Fan status",
        "server": "337b22fd.b997ae",
        "version": 1,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "switch.master_bath_fan",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 290,
        "y": 340,
        "wires": [
            [
                "94c04950.6db018"
            ],
            [
                "2d36d2eb.0c0fae"
            ]
        ]
    },
    {
        "id": "dafc92a1.fc8ce",
        "type": "mqtt-broker",
        "z": "",
        "name": "MQTT-fan-button-listener-1",
        "broker": "localhost",
        "port": "1883",
        "clientid": "node-red-01",
        "usetls": false,
        "compatmode": false,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "337b22fd.b997ae",
        "type": "server",
        "z": "",
        "name": "Home Assistant"
    },
    {
        "id": "426ef3a3.09388c",
        "type": "mqtt-broker",
        "z": "",
        "name": "MQTT-fan-button-listener-2",
        "broker": "localhost",
        "port": "1883",
        "clientid": "node-red-02",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "a76dc38a.2d32c",
        "type": "mqtt-broker",
        "z": "",
        "name": "MQTT-fan-button-listener-3",
        "broker": "localhost",
        "port": "1883",
        "clientid": "node-red-03",
        "usetls": false,
        "compatmode": false,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    }
]
1 Like