HA stops reporting Wink state changes

Can you try performing the steps in the post above HA stops reporting Wink state changes and see if running the test script fixes the issue.

I noticed you didn’t say this issue starts happening after awhile, does that mean you have this issue as soon as HA is restarted or do you have problem after several hours of it running?

I assume you aren’t seeing any issues in your logs?

I will give your test script a try and let you know.

I haven’t tested for the problem enough to know if it’s happens directly after startup or a while later. I will test for that as well.

And no, nothing in the log.

I’m not sure if I’m doing things correctly, but when I try to run the script using “pip3 wink_test.py” I get ERROR: unknown command “wink_test.py”

I put my client_id and client_secret in both places where it said. 2 each for YOUR_CLIENT_ID and YOUR_CLIENT_SECRET

Do I have to put the script in a special place? I have it in the pi user’s home directory and ran it from there.I tried it both with and without sudo also.

you should be running that command with python3 not pip3

Ok, now I get the following:

Traceback (most recent call last):
File “wink_test.py”, line 1, in
import pywink
ImportError: No module named ‘pywink’

Ran it from both pi user’s home and homeassistant user’s home.

run pip3 install python-wink and then try again

Ok, that worked. Ran the script and it gave me a url to visit. Do I visit the url or use the client_id for the token?

Here is what I did:
pi@RPi3bplus-HA:~$ python3 wink_test.py
Please vist the following URL to authenticate.
https://api.wink.com/oauth2/authorize?client_id=REMOVED&redirect_uri=127.0.0.1
Enter code from URL:https://api.wink.com/oauth2/authorize?client_id=REMOVED&redirect_uri=127.0.0.1
Traceback (most recent call last):
File “wink_test.py”, line 11, in
print(“Copy this in to the wink_test.py:” + auth.get(“access_token”))
TypeError: Can’t convert ‘NoneType’ object to str implicitly

You need to open the URL in your browser when it says “Please visit…” then after entering your username and password the URL in the address bar will have a code at the end. That code needs to be entered in the terminal

I really hate to be so stupid, but I’m on a RPi running stretch lite. No desktop to use a browser. I can’t remember for the life of me how I did this months back when I first setup wink.

I tried going to that url from another computer on the same network but I first got Redirect URI is not authorized. So I updated the 127.0.0.1 with the Redirect URI in developer and I got the login. When I login I get a 404 not found.

Ok, not sure if this is correct, but in the URL from the 404 page there is a code=REMOVED
I took that code and entered it in the script and got a token.
I commented out lines 4-11.
Added the token to and uncommented line 15.
Ran it again and no output.

So assuming this is all correct, now I run this when I have the updating state problem?

That is correct. Once you see that update issue run the script and then try to trigger one of your Wink sensors and see if it updates in HA.

Ran a quick test. This is done remotely so I’m relying on the wink app to give me the proper state of the light.

I turned the light on from HA’s frontend. Wink app showed the light turned on but HA still showed it off. Ran the test script and the state updated to show the light was on.

I then turned the light off via the wink app and took maybe 2 or 3 seconds and HA showed the state was off.

Next I turned the light on and off via the wink app and HA updated the state within 2 or 3 seconds. I’ll be home in a few hours and I will try again so I can confirm the light is actually turning on and off.

Awesome, sounds good. So how long does it take your system to get in to the state of not updating?

That I do not know for sure. Last reboot was last night but I didn’t try any wink lights till just now with this test. So I don’t know if it’s a problem right from the start or if it takes a while.

Should I do another restart and test the wink lights right away?

No I would wait. In the past this issue has occurred ~6 hours after restarting.

Sounds good. I’ll check and see if it stops working again from this point forward. Or after one of my reboots because ZHA stopped working which happens every few days. May just move all my zigbee stuff back over to wink and live with the 2 or 3 second delay.

Just providing some feedback. The state in wink for my lock is correct. The HA is not. After I do a wink refresh from HA it shows correctly. In my case I am unlocking from hombridge and the status in homekit stays unlocking and HA never changes to unlocked. Wink shows updated state of unlocked

Can you try the test script that @lviperz is trying?

Update. The next morning the state update problem is back. I ran the test script about 2:30pm central time yesterday. I tested about 9pm and the state was still updating. I didn’t try again till 9am the next morning and the problem was back.

I ran the test script and the problem was again fixed. I will try and remember to test throughout the day to see how long it takes to stop working.

Just noticed the following in my HA log. Posting here to see if it helps. This is the first time I’ve ever noticed it.

WARNING (EndpointThread-Heartbeat-0) [urllib3.connectionpool] Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ProtocolError(‘Connection aborted.’, ConnectionResetError(104, ‘Connection reset by peer’))’: /v2/presence/sub-key/sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe/channel/9c17305fc3f8917927c3abbbe33258ca95a089da%7Clight_bulb-4021557%7Cuser-892302,0bd30fadf321c50e93e5b670ff4cb090920ded65%7Cfan-9806%7Cuser-892302,d2af6e055cbc16254e19eb1debd8282ff61f5e75%7Cfan-9835%7Cuser-892302,0b5233a5fb801661edb8627405efb14aff112814%7Chub-883628%7Cuser-892302,f81a2370ed334702b4d988b3a5b5715ce60d05ce%7Cgang-147704%7Cuser-892302,a7d18b526b163f5d03f576862e6755271380e0ce%7Cgang-147840%7Cuser-892302,4664c1076629e71aeba4280beb2bad386c6531d2%7Clight_bulb-4025018%7Cuser-892302/heartbeat?heartbeat=300&pnsdk=PubNub-Python%2F4.0.10&uuid=4cbc1c80-1107-454e-bd53-6c1121a091ec