HA stops reporting Wink state changes

Thanks. Prepped to run the wink test python script once it fails.

It has been almost 10 hours since I last ran the wink app and my sensors and light started working again. Just checked and home assistant no longer sees state changes on the light, and when I try to turn on the light nothing happens and the light slider switches back to off after a few seconds.

So, I ran the script, got the URL, went to wink site, logged in, got 404, copied code, entered and got token. Then pasted the token into wink test script, commented out the correct lines, uncommented the new one and ran the script, no output (as expected).

Tried to toggle the light from the wall switch, no state updates in home assistant. Tried this a few times. Then I tried to turn on the light from home assistant, and this time the light came on, but the slider still goes back to off after a few seconds.

So while I can control my lights (as in I can turn them on), the state didn’t update and since the slider is on off, I cannot turn off the light.

I opened the wink app on iPhone, then went back to home assistant ios app, and all is working fine again, state changes seem to track and I can turn on and off the light.

So, the script was’t really successful for me. Hope this helps us get closer to a solution. Do you feel full debug logs may help figure out why it is failing?

Just another followup, I just got home and again my wink light didn’t follow state. I tried the python scripts again, following all the steps and again it didn’t work to update the state.

Opened wink app and all is running.

This is also impacting my zigbee water sensors, which is my bigger concern.

I don’t think I am doing anything wrong. If there is something I can help with to debug this, let me know. I am a developer and comfortable with python.

Thank you.

Thanks for the feed back. I wonder if they have made a change to only accept updates from the official app. I will try to put together a test script with the Android user-agent and then have you try running that and see if it works.

Their API is published no? I would be surprised if they blocked that based on user Agent.

Looking at the code I realized that in my first run when I get the code I had both the set bearer and get devices call commented out. Was the first run suppose to call get devices as well?

Also, how long is the token generated good for? Should I regenerate it every time?

Need to see how to get the logger output into the screen to see if there are any errors as the second run never has any output.

The API is public but not documented well. I had to use the calls from the Android app to get a fully working library. For example the device type on each device isn’t sent back if you don’t call the API with a properly formated user agent, but that isn’t documented anywhere.

I am not sure how long token are good for, they don’t send an token expiration time back when we get a token.

The first run is just to get your token. That token is good for several weeks but I am not sure exactly how long.

If there were any errors it would output no output means it worked.

Thanks, that makes sense. This was a lot of work to figure out, thank you for doing it and sharing.

So, in an attempt to help, I turn on full debug logs for pubnub,wink,pywink.api and left it overnight. In the morning, sure enough the light state doesn’t follow the wall switch.

I have not opened the wink app, and I have not run any scripts yet. If there something worth trying, I will leave this as to experiment.

What I can say, all night and still continuing in the logs, the pubnub heart 5 minute poll and the 5 minute subscription long poll continue to operate and continue to get success 200. The hourly pywink.api poll “to keep pubnub updates flowing” keeps working as well with 200 success.

This is very useful, thanks. So not sure if you have been able to read through this entire thread I hope not lol. But this is the EXACT same issue that first started happening when I first put in push updates for Wink. The solution to the problem after a couple months was to poll the API with a different user-agent from the Home assistant user-agent. That work for a long time and still works for some users (me) but isn’t anymore. I will try to find the Wink Android user-agent real quick and get it sent over to you.

Okay that was easier than I thought.

Can you add a call before the call to get devices

pywink.set_user_agent(“Manufacturer/unknown-Android_SDK_built_for_x86 Android/4.4.2 WinkAndroid/6.9.0.65-production-debug”)

And try running that?

No luck. Same. I didn’t re-generate the token. I just used the same one from last night, but as you indicated the token should be good for a few months.

Also, I have a wink hub v1 if that is a difference.

Perhaps a robot on the wink hub side could keep it sending states to the cloud. Would need to think about this some more.

Thanks again.

Well that blows.

So I am trying to go through and see what is different in the official app calls vs what python-wink does. I noticed that there is a new header in the calls I don’t recall seeing before X-DEVICE-IDENTIFIER maybe we should try to add that? It is a random value that is sent by each platform I think. For Android it looks like e36659c47cce2843 so I don’t know if that will work.

Worth a shot. So odd that it works for a while normally and then would need a changed header.

How do you collect all the calls that the Android app makes? Using a tool like wireshark?
What are all the calls it makes?

Have you tried unsubscribing from pubnub and then re-subscribing to see if that fixes it? I am assuming now, since it seems pubnub is fine as once I run the offical app updates start coming through.

I also validated that the python script is getting back all my devices with the get_all_devices call by printing the object to the screen.

Using an app called Charles Proxy to intercept the SSL calls. I can post the session and send it. You will need Charles to view it

Ok, I see the tool. Did you then configure your mobile to route all traffic through your machine running charles?

Correct, I am using an emulator though. Can’t route apps you don’t own through charles unless you are running Android 4, new version prevent it.

So I found out I can export as XML and it is kinda readable lol. I replaced my email and password as well as my access token which I replaced with someRandomToken

All user that were having this issue should test out the fix that is being merged in to dev if possible https://github.com/home-assistant/home-assistant/pull/20594 @juched spent a great deal of time diagnosing and testing this fix. Without the help of @juched this fix would not have been possible.

This fix is in the 0.87 release so please upgrade if you are having this issue and report your findings here.

Is anyone else seeing state changes not being reported from Wink to HA?

you can read all about it here

Wink/PubNub not updating

Wink made a back end change and HA needs some changes to start working again.

Gotcha. Sorry, I should have searched more thoroughly. Let me know if you need any testing help.

Thanks.