HA stops reporting Wink state changes

I just pushed the newest version of the wink.py to the Pull Request linked above. Everyone can test that out.

@dspille I don’t have a Hub 2, but I just updated my hub v1 the other day. It shouldn’t cause any problems with what we are testing.

@rpitera What printer did you get? Make sure you check out http://octoprint.org/ and the HomeAssistant component. https://home-assistant.io/components/octoprint/

2 Likes

Downloaded and installed. I will report back this evening.

I am still showing the updates stop after 6 hours with this new wink file. No errors that I can see. Wait and see what others are reporting before making final judgement. Very strange that setting it up in an automation works, but it refuses to work properly this way.

Updates still working for me after 8 hours. We’ll see how it’s doing in the morning.

@w1ll1am23 It had stopped updating when I checked this morning. I will PM log.

I bought a Monoprice Mini Select based on the reviews. It’s a small printer, but as I am just starting out and most of what I want to do initially is build enclosures for Ben’s sensors and a few other things, the 4.7x4.7x4.7 print volume should do fine for me.

I am definitely going to look into connecting it to Octoprint though and may even buy a dedicated pi with a camera hat for it.

1 Like

@balloob Can you please see if you can figure out what is causing this to not work? If you see @shire210 comment above what he is indicating, is that when executing the same code via a manual call to the same code as a service, it fixes the problem users are having. However, when using the current code here https://github.com/home-assistant/home-assistant/pull/7051 to call the same code via an async_track_time_interval call, the commands don’t seem to be executed, or if they are, they are failing for some reason and not resulting in a Traceback in the logs.

You are not in an async context, hence you should use track_time_interval instead of async_track_time_interval. Or, after creating the task, you should enqueue it for execution: hass.add_job(async_track_time_interval(…)).

Just creating an async task will not execute it.

I originally used the non-async version. That is what @shire210 tested with first. Still had the same results, the call to _LOGGER was present in the logs, but the response from the calls to pywink were not output to a temporary log we setup and there were no tracebacks.

In fact using the current code with the async call the call to logging is showing up in the logs?

Oh, looks like async_track_time_interval is a callback. In that case it will execute but it is not threadsafe. Use the non-async one.

Also, you will have to wait the interval time (60 minutes) before it gets executed.

So… @shire210 and I have been working on this some more. It looks like the call that is made to Wink every hour has to come from a different token in order of the updates to keep working. Doesn’t make any sense… but I have managed to figure out how to come up with a way to get a new token and “poll” the API.

Can everyone that is still seeing this issue, or is using one of the previously working workarounds please test out this new file. https://hastebin.com/cakuzeyudo.py

This method will only work for client_id/client_secret setups and username/password setups. That means if you are just using an access token in your config this will not work.

Basically this fetches a new Wink token every 2 hours and after getting the new token it calls out to the Wink API /users/me endpoint and /users/me/wink_devices endpoint just to hit the API. @shire210 test this with oauth and with the email/password combo for almost an entire day for each without problems.

Lets hope this ends up working and we can finally get this fixed!

If we can get this fixed, I have some additional Wink features I would like to start putting some time in on.

4 Likes

Downloaded and installed. I’m running now and will let you know how it goes. Thanks to you both for all your hard work.

@w1ll1am23 Your update is working great for me after 23 hours. I’ve never seen it go beyond the 6 hours until now. Thank you very much!

2 Likes

Me too! The patch is working perfectly so far :tada:

3 Likes

@dspille @aaronwolen Awesome! Thanks for testing. I’ll open up the HA pull request now.

3 Likes

@dspille @aaronwolen @shire210 can you guys note that you have tested on the PR?

1 Like

Also working stable for me. Thanks for all the effort.

2 Likes

Works well for me too! Thanks!

Cheers to @w1ll1am23! Also found out the other day that he is responsible for a couple of other platforms including OctoPrint support. A great dev who always seems personally vested in everyone’s experience and is quick to respond to issues.

People like @w1ll1am23 make HA a great place and I just wanted to take this opportunity to thank him for all of his hard work and super friendly demeanor!

:wink:

3 Likes

@rpitera thanks for the kind words. I am just glad to be able to give back.

Thanks to everyone that provided assistance getting this figured out. Let’s hope we really got it worked out this time.

2 Likes