HA stops reporting Wink state changes

After many days of working with @shire210 I believe we have figured out how to fix the issue! It appears that making an API call to https://api.wink.com/users/me make state changes start up again. This is one of the calls made by the iOS and Android applications when they start up. This should be a pretty simple fix to add to python-wink/pubnubsubhandler however I would like more users that are having this issue test it out first.

To make this easier I have created the following python script which needs to be run once the state changes stop working.

https://hastebin.com/zirihocico.py

This script needs to be run like soā€¦

Note: Rename the script to something useful, I called it get_wink_user.py

python3 zirihocico.py  -u [email protected] -p winkpassword -s

-u is the username for your Wink account.
-p is the password of your account.

The -s is optional and will suppress the output of the response. Without the -s you should get something like the below printed out. This means it worked.

{
    "data": {
        "confirmed": true,
        "created_at": 1449441909,
        "desired_state": {
            "current_location": null,
            "home_geofence_id": null,
            "robot_subscription": null,
            "units": null
        },
        "email": "myemail",
        "first_name": "William",
        "last_name": "Scanlon",
        "last_reading": {
            "current_location": null,
            "current_location_data": null,
            "current_location_data_updated_at": null,
            "current_location_updated_at": null,
            "desired_current_location_updated_at": 1453091393.6379838,
            "desired_home_geofence_id_updated_at": 1453091393.6379838,
            "desired_robot_subscription": null,
            "desired_robot_subscription_updated_at": null,
            "desired_units": null,
            "desired_units_updated_at": 1453091233.7842777,
            "feature_flags": [
                "faster_lights"
            ],
            "feature_flags_updated_at": 1455056917.7954974,
            "general_tos_version": "4",
            "general_tos_version_updated_at": 1466634432.1567028,
            "home_geofence_id": null,
            "home_geofence_id_updated_at": null,
            "premium_tos_version": null,
            "premium_tos_version_updated_at": null,
            "robot_subscription": null,
            "robot_subscription_updated_at": null,
            "units": {
                "temperature": "f"
            },
            "units_updated_at": 1453091233.737727
        },
        "locale": "en_us",
        "object_id": "377857",
        "object_type": "user",
        "subscription": {
            "pubnub": {
                "channel": "blah blah",
                "subscribe_key": "blah blah"
            }
        },
        "tos_accepted": true,
        "units": {},
        "user_id": "377857",
        "uuid": "5c063d24-4ec0-4076-80ea-XXXXXXXXXXXXXXx"
    },
    "errors": [],
    "pagination": {}
}

After you have manually confirmed that this fixes the problem, you can set it up to run in a HomeAssistant automation using a command line switch https://home-assistant.io/components/switch.command_line/ this will be a temporary workaround until I can get it added into the code, at which point you can remove the automation.

1 Like

Hi @w1ll1am23

I did what you described above but I donā€™t see an update from my wink-supported thermostat yet.

Hereā€™s the output I get when running your script:

{
    "data": {
        "confirmed": true,
        "created_at": 1481479092,
        "desired_state": {
            "current_location": "wink_fusion_away",
            "home_geofence_id": "231XX",
            "robot_subscription": null,
            "units": null
        },
        "email": "[email protected]",
        "first_name": "First ",
        "last_name": "Last ",
        "last_reading": {
            "current_location": "wink_fusion_away",
            "current_location_data": null,
            "current_location_data_updated_at": null,
            "current_location_updated_at": 1482176514.824018,
            "desired_current_location_updated_at": 1481752079.844516,
            "desired_home_geofence_id_updated_at": 1481751950.8047874,
            "desired_robot_subscription_updated_at": 1481752079.844516,
            "desired_units_updated_at": 1481752079.844516,
            "feature_flags": null,
            "feature_flags_updated_at": null,
            "general_tos_version": "4",
            "general_tos_version_updated_at": 1481479101.964843,
            "home_geofence_id": "231799",
            "home_geofence_id_updated_at": 1481751950.7839627,
            "premium_tos_version": null,
            "premium_tos_version_updated_at": null,
            "robot_subscription": null,
            "robot_subscription_updated_at": null,
            "units": null,
            "units_updated_at": null
        },
        "locale": "en_us",
        "object_id": "581935",
        "object_type": "user",
        "subscription": {
            "pubnub": {
                "channel": "blah blah",
                "subscribe_key": "blah blah"
            }
        },
        "tos_accepted": true,
        "units": {},
        "user_id": "1234567890",
        "uuid": "ab7dd104-dd54-4039-8e39-1234567890"
    },
    "errors": [],
    "pagination": {}
}

Not sure what Iā€™m supposed to look for here.

States should start working again. If you make a change on the thermostat since you ran the script does it update?

I made another change/restart to HASS which would have triggered the wink reconnect anyway - guess I might have been too impatient :frowning:

Iā€™m not good with the command line stuff, but definitely willing to give it a try.

Can you help me get the automation set up if I put your script into /home/homeassistant/.homeassistant/deps?

Confirming that this script works for me. I did have to go into the services and run ā€œrefresh state from winkā€ after I ran the script for the lights to show the correct state. But after that everything started working perfectly.

Next Iā€™ll take a stab at getting the command line switch and automation to work.

I have not had a chance to test the functionality of the switch yet, but it appears on my front end at least. Also my setup is a little different than normal, so I tried to change locations to match a standard installation. I renamed the script WinkUpdate.py and created the following switch.

switch:
  - platform: command_line
    switches:
      wink_update:
        command_on: "python3 /home/homeassistant/.homeassistant/deps/WinkUpdate.py  -u [email protected] -p winkpassword -s"
        command_off: ""

Want to test the switch before setting up the automation, but I plan on modifying my restartHA automation from above to activate every 2 hours or so and turn this switch on, wait a few seconds, refresh state from wink, and then turn off the switch so it is ready for the next time.

1 Like

In your automation you shouldnā€™t need to call the refresh state service. If you are calling this script every couple of hours I would expect you states to stay in sync.

Thanks - I set the command line switch up as @shire210 showed and added an automation that triggers the script every two hours.

Iā€™ll report back asap.

It has been working fine for me for the last 7h now - letā€™s see what it looks like tomorrow morning.

Same results here as @chairstacker . Still going strong 12+ hours after setting up the automation.

@chairstacker are you having the same results as @shire210?

Hi @w1ll1am23, itā€™s looking good :+1:

Thanks for all your help, folks!

1 Like

@chairstacker @shire210 I have opened a PR for HomeAssitant https://github.com/home-assistant/home-assistant/pull/7051 this will automatically perform the tasks that the script you are running now performs.

If either of you could test it out and remove your current automation that would be awesome.

Does the updated wink.py need to just be placed into the custom_components folder?

Yeah, that should do it. If you want to verify put it there and then check your log for the install of python-wink==1.2.4

Sure thing. I will test it out tonight and report back. Thanks for pulling all this together.

Not seeing that, but it does appear itā€™s loading from my custom_components directory. (If thatā€™s what the following means)

17-04-11 19:22:48 INFO (MainThread) [homeassistant.loader] Loaded wink from custom_components.wink

Yeah that means it is loading form the custom_component. The very first time you start up you should also see this

Attempting install of python-wink==1.2.4

in the logs.

Yeah I didnā€™t have logger enabled the first time I started it up.

Not sure if I did something wrong, but I am still having the issue after updating HA to include your pull request.

Worked for the first 6 hours, and then from 6 - 12 and now nothing.