HA stops reporting Wink state changes

Line 119 is correct.
I had it wrong in my post.
I have updated the Line number in my post.

Thanks guys. I just finished setting this up. Will see if it still works in the morning. :slight_smile:

So does this script work after the changes to the file? Im kinda new @ writing scripts.

Thanks

Having a new issue with mine now and wanted to see if others are experiencing it or just me. It will work fine when HA starts for the first 6 hours (seems to be what others are seeing as well) and then stop updating the state. The new development is that after that happens, it will start working again from 6am to 12pm EST every day.

Can anyone else confirm this?

Seems to work better than without this - not sure if it’s actually the automation that causes it, though.

There is an entry in the logbook that the automation has been triggered, I just don’t know if it does what it’s supposed to do yet.

Will need to play around with it a little more.

The refresh_state_from_wink service only updates the current state of the items in wink. It does not reset the connection. When your automation runs every 2 hours, it is grabbing the current state of the lights. At least that’s how I understand it from my experience.

W1ll1am has a ticket open with pubnub and they are investigating the issue. Will report back when more is known.

Bummer - looking at the graph, that’s what it seems to do exactly :frowning:

I used the manual method on via the dev-state and that seemed to fix it for a while, though.
Guess that triggered something else that the automation does not.

Thanks for the explanation!

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.