HA stops reporting Wink state changes

Pubnub is requesting your pubnub subscription_key. Can you PM it to me?

If you run the following script from inside your deps folder it should spit out your key.

import pywink

pywink.set_bearer_token("YOUR TOKEN HERE")
key = pywink.get_subscription_key()
print(key)

I copied the commands into a text file and named it getkey.sh

Copied to deps folder, set permissions to 755 and ran it as sudo ./getkey.sh

But it gave me the following errors:

pi@raspi1:/home/hass/deps$ sudo ./getkey.sh
./getkey.sh: 1: ./getkey.sh: import: not found
: not found: 2: ./getkey.sh:
./getkey.sh: 3: ./getkey.sh: Syntax error: word unexpected (expecting ")")

What did I do wrong?

Nevermind - it turns out that Wink@home shows the subscription key in it’s info section for the hub.

PMing you that now.

Cool, thanks. BTW that script needed to be a .py and run with python3 not a .sh

Thought of that after I PM’d you - LOL!

Oh well, at least now you have an easier method. Always impressed by the amount of info and troubleshooting possible with Wink@Home.

BTW, for other users that may not be familiar with this - Wink@Home is an online web interface for Wink systems. It’s available at www.winkathome.net.

No Wink Relay. Not wife friendly at my house.

Gotcha, just checking. Do remember if you saw a similar error to what @rpitera saw prior to the pubnub take error when you were seeing the issue?

Yup. Accept it was a remote that caused my issue. I think I saw other devices too but can’t be 100% sure. The remote was how I tested until it was fixed. I’d reboot, use the remote and then no Wink updates. I quoted my errors above:

So I know you aren’t seeing the pubnub error now, but do you still see the error above that when using the remote?

That shouldn’t be happening. It looks like python-wink is confused about your remote, acting like it is a hub. Do you have a binary sensor called binary_sensor.office_remote_hub?

I am not sure how that would cause this problem, but I wonder if pubnub handler object is getting destroyed in home assistant, and pubnub is still running in another thread so it trys to call whatever that loop method is and then dies too.

I am catching the errors that I think pubnub and wink can through inside of home-assistant. I wonder if maybe that is too late and pubnub has died at that point. Maybe I need to catch the errors in pubnubsub-handler?

I see what you mean. I missed the word hub in that error. But to answer your question no I am not getting that error anymore. I am occasionally getting a few errors now but they seem to be related to a DropCam I have hooked up to Nest:

17-01-10 13:33:53 aiohttp.server: Error handling request
Traceback (most recent call last):
  File "/home/hass/deps/aiohttp/web_server.py", line 61, in handle_request
    resp = yield from self._handler(request)
  File "/home/hass/deps/aiohttp/web.py", line 249, in _handle
    resp = yield from handler(request)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/http/__init__.py", line 427, in handle
    result = yield from result
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/camera/__init__.py", line 186, in get
    response = yield from self.handle(request, camera)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/camera/__init__.py", line 204, in handle
    image = yield from camera.async_camera_image()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/camera/__init__.py", line 91, in async_camera_image
    None, self.camera_image)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 269, in result
    raise CancelledError
concurrent.futures._base.CancelledError

Just for the heck of it I checked my logs and they are clean - single error, which is something I know about that’s informational and not related.

Just triggered the top load switch on my relay from HA to see if it would cause an error and waited but saw nothing.

Then triggered the physical switch and immediately got the error!

17-01-10 17:23:59 homeassistant.components.wink: Error in pubnub JSON for Wink Relay's Top Button hub polling API for current state
17-01-10 17:23:59 pubnub: take message interrupted: 'NoneType' object has no attribute 'loop'

Odd thing is that I can’t duplicate it. I tried the bottom switch, which is not connected to a load but instead fires a shortcut. No error. Then I thought, maybe it’s just the load switches and pressed the top load switch but again, no new error.

But like I said, my log was clean until I hit that switch for the first time and the error matched the time perfectly.

Cool! Now we might be on to something. So, can you test something for me? Clearly there is an issue with things thinking they are hubs when really they aren’t. Based on your message it looks like you probably have a binary_sensor.wink_relays_top_button_hub? That shouldn’t be there, but even though it is I don’t think you should be getting this error, so can you change your wink.py in your custom_components directory from this.

    def _pubnub_update(self, message):
        try:
            if message is None:
                _LOGGER.error("Error on pubnub update for %s "
                              "polling API for current state", self.name)
                self.update_ha_state(True)
            else:
                self.wink.pubnub_update(message)
                self.update_ha_state()
        except (ValueError, KeyError, AttributeError):
            _LOGGER.error("Error in pubnub JSON for %s "
                          "polling API for current state", self.name)
            self.update_ha_state(True)

To this

    def _pubnub_update(self, message):
        try:
            if message is None:
                _LOGGER.error("Error on pubnub update for %s "
                              "polling API for current state", self.name)
                self.update_ha_state(True)
            else:
                self.wink.pubnub_update(message)
                self.update_ha_state()
        except (ValueError, KeyError, AttributeError):
            _LOGGER.error("Error in pubnub JSON for %s "
                          "polling API for current state", self.name)
            _LOGGER.error(message)
            self.update_ha_state(True)

Adding in the _LOGGER.error(message) that should spit out the pubnub message when you see this error to the log. I am thinking the message is bad in some way I am not expecting.

Also could you provide me with the JSON from your relay switches? Should be able to get it from wink@home.

Before I change anything, let me give you some info -

I don’t have a binary_sensor.wink_relays_top_button_hub, but I do have a binary_sensor.wink_relays_bottom_button_hub

And when you say “Clearly there is an issue with things thinking they are hubs when really they aren’t.” you do realize that they do in fact act as hubs. When I pair a new device in, I can pair it to my Wink Hub or my Wink Relay. In fact I only have three devices paired to it, a garage tilt sensor and a GE Link light, also in the garage, because they are physically closer to my Relay than to my hub. In addition I also have another Link light connected via the Relay.

I checked this over at Wink@Home, where my relay shows up under “Hubs” along with my Wink v1 and my Hue Hub.

Relay JSON going to you via PM. I’m holding off on any changes until I see what you think about my response on whether Relays are actually hubs or not.

I am aware they act as a hub. The problem is, you should get one sensor for each hub and I think something is getting confused and creating more. For example in @kevince52 case, I don’t think he should have a hub sensor named office remote hub, I believe he has a remote called office remote, and python-wink is thinking it should be a hub, when in fact it should not. I think this is a flaw in the way I am creating the hub sensors.

OK, I needed that clarified. Thanks!

Should I go ahead and make those changes or do you want to review my JSON first?

I no longer see the office remote hub. I can’t tell you if it existed either other than that error.

I do see my hubs which is a new thing since 3.5.3 I think. I do have one device that doesn’t make sense. Something called binary_sensor.hub_hub. It reads as unavailable. I hide it because it annoys me. I think it’s an old Wink hub that I had to return because it wouldn’t update. I don’t see it in the Wink app but it’s been in Wink @ Home for a while.

I see a Philips Hue hub in there too even though I revoked access at meethue.com. Odd that Wink holds on to these things. I recently update from a v1 Wink hub to v2. Before this problem. That’s not there anymore.

Is it at all useful for me to make these edits? I’m not getting the error anymore.

Thanks for the info. Yes, the hub_hub is the sensor for your v1 hub. Do you not see binary sensors for your other hubs?

I only see those 3. The Wink v2, hub_hub and Hue. I don’t have any other hubs although I have a Smartthings hub on the way.

So do you see those three in home-assistant as well? They should be entities with names like binary_sensor.phillips_hue_hub and binary_sensor.wink_hub_v2.