Toggle HomeAssistant groups from Wink Relay buttons!

I was having similar issues with proximity and in my implementation I ended up using a configurable value for proximity, not delta (e.g 5000, as the original wink-handler did).
The proximity sensor on the device has actually 3 leds, each with its own proximity value. We only use the first one which seems to do a great job.
In addition I noticed we have access to Light sensors, both visible and IR.

I will be publishing my work to github soon (hopefully tonight EST, time permitting).
If anyone is interested in building/testing, I suggest peeps download the latest Android NDK :slight_smile:

cool, thanks - so (given the non dev I am)
what would be the chance of a new release with:
prox_value= blah
in the mqtt.ini

:wink:

Hey @jimpastos, looking forward to it!

The only problem I found with setting an absolute value for the prox threshold (even a configurable one) is that the value reported by the prox seems to walk all over the place, steadily increasing or decreasing over time. Another user in this thread graphed it and thought it might be related to ambient temperature.

So my “relative” prox code was in part an attempt to compensate for that (the other part was to accommodate the fact that each relay seems to have a different resting prox value).

If you are going in this direction I’d suggest also an mqtt topic that reports the prox value to make it easy for users to figure out what the absolute value is to set the corresponding parameter.

Just posted

Perhaps the other 2 proximity values are significant then. Not sure

Hey @jimpastos - got it compiled and installed, but it doesn’t seem to be connecting to my mqtt broker (Mosca). The mqtt_address parameter looks like this, is this correct?

tcp://192.168.88.10:1883

Any way for me to debug what’s going on?

Edit: Also, the screen is constantly on, if that’s a clue to anything (and the default of 5000 should be well above my prox sensor resting value).

Address looks good.
I think i should send a screen on event at start so the off timer kicks in. Test by touching the screen/press button or trigger proximity and wait 20 seconds.
You 100% sure it doesnt crash?
You can delete edisonwink and run it manually as root in adb shell.

Hello,

I followed the directions for creating the build, and after some path issues (running windows 10 w/ cygwin) got the build to complete. Followed the rest of the instructions.

The wink relay boots up fine but no mqqt.

wink_manager.ini…

mqtt_clientid=Wink_Relay_2
mqtt_topic_prefix=Wink_Relay_2
mqtt_address=tcp://192.168.3.4:1883
screen_timeout=30
proximity_threshold=7500
hide_status_bar=true
relay_upper_flags=1
relay_lower_flags=2

and from adb shell as root…
am start edisonwink
returns…
root@edison_dvt:/ # am start edisonwink
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] pkg=edisonwink }
Error: Activity not started, unable to resolve Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=edisonwink }

Don’t know what else to do to troubleshoot…

am start wont work as its not an Android app with activities.
You either replace /system/bin/edisonwink (first rm and then cp over and chmod 755) and reboot (this will run in the background on boot) or you can manually copy the binary in /system/bin/wink_manager and run (just type /system/bin/wink_manager) in the foreground to test. Just make sure you dont have multiple versions running

Thx I will try that.

BTW the wink_manager build is 222kb in size. Does that sound right? I have never built form source so I don’t know what I am doing in that arena, but the build did produce a file…

root@edison_dvt:/ # /system/bin/edisonwink
Result: Parcel(00000000 ‘…’)

I removed the edisonwink so it would not start on boot
rebooted
copied wink_manager to system.bin
chmod 755 /system/bin/wink_manager

root@edison_dvt:/system/bin/wink_manager

root@edison_dvt: # wink_manager
Result: Parcel(00000000 ‘…’)

then nothing

Nothing is good, means its running. :slight_smile:
Most of the logging is commented out so you wont see much but i believe paho has an environment variable you can set that will post more mqtt debug logs.
Type export MQTT_C_CLIENT_TRACE=ON before you run the app.
As for size 200k is mostly linking in C++ stuff and android NDK libs. We can probably look into reducing but not priority right now.

@lightmind as a side note, what happens when you press the top button when its running? Does the too relay switch on?
Also does your mqtt server show anything in its logs?

Thanks for responding,
Relay switches do not turn on when pressed, no mqtt messages or log entries from the device at all

Pushed a minor fix for turning on the screen on startup (which also allows for it to turn off after timeout).
once you enabled MQTT tracing you saw nothing in the shell?
Does your MQTT server require authentication? I haven’t fully tested with Auth or SSL.

sorry if you answered this but is there a way to:

  1. not have the relay turn to on (on reboot)
  2. detect lack of communication with the wink and reboot?

right now i’m still setting up and rebooting fairly regularly, but when it fails to connect it would be good to have the relay send an MQTT payload every minute say, and a sensor that could report last MQTT packet. If over 2 minutes

adb connect <IP> 
adb shell
sudo su && reboot

probably a more graceful way of doing that (and requires ADB to have root access and listening all the time).

latest version contains “retained” messages for states.
The MQTT server will save the last state of relays/temp/humidity.
The app also sends the latest state on (re)connection.

sweet - so i need to get building

not built/made this solution before - dont suppose someone can share the wink-handler file so i can test it on one device (assuming same process, adb push, adb shell, cp from /sdcard/ )
or is this a different set of steps?
Thanks for building this new version too!

apologies, but what should i add to the ini file for username and password when connecting to my MQTT server?

You can add the following to the INI file to set the username & password:

mqtt_username=username
mqtt_password=password

1 Like