Discovery not discovering

I added a new switch this afternoon. Once I added it to wink, Alexa picked it up in about 5 minutes. But HA did not pick it up even though discovery is enabled. I run all my devices through wink. I had problems getting the HA zwave to work so I just went back to wink and use HA for automation. Once I restarted HA though, it came up just fine. So it is picked up on the initial discovery, but not on subsequent ones while the system is running.

I’ve always restarted HA after adding a device to Wink, but that’s just out of habit. Theoretically, when pubnub gets the updated info from the Wink API, HA should propagate it over. But I always restart after adding a new device to any platform to be sure.

I just checked the log. pubnub only runs once an hour. I probably haven’t ever been that patient.

ok found it. in pubnubsubhandler, the following comment explains it.

    keep_alive_function (func, optional): If provided will be run
        every keep_alive seconds. Use if something needs run to
        keep your PubNub updates flowing. Defaults to None.
        Example: For Wink subscriptions the Wink API needs polled
        occasionally to keep updates flowing from PubNub.
    keep_alive (int, optional): How often to run the keep_alive_function
        in seconds. Defaults to 3600 (1 hour)
    sub_delay (int, optional): How long to delay the call to subscribe.
        Defaults to 1 second. (No delay)

So apparently we need to give pubnub a option to keep wink alive. Now to figure out how/where to do that.

From what I am seeing it appears that the heartbeat is hard coded to 1 hour. Is it really hardcoded or can it be adjusted or run on demand?

@w1ll1am23 may be able to help on this - I am tagging him in.

So it is a little more complicated than that. Devices are only discovered during startup, this is because the main call to the Wink API to get the list of devices is only called once. So at the moment a restart is required in order to get all devices from Wink again. I have thought about how to make this work better/automatically but I am not sure what the best approach is. Maybe an additional service you could call? idk I’ll keep thinking on this.

The pubnub keep_alive thing is basically a poll to the Wink API to keep the pubnub connection active. It has nothing to do with getting device states/new devices at all.

I like this idea - similar to the harmony platform’s resync service.

I would be happy with something under services in the wink domain, to re-discover wink devices.

This PR adds a new service which can be called after you add a new device to your Wink account. This will make that new device show up in Home-Assistant.

1 Like