LIFX / LIFXKit

The LIFX SDK for Objective-C.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ability to determine there are no LIFX bulbs available

yonilevy opened this issue · comments

There seems to be no way to determine there are no LIFX bulbs available in the network. Obviously this can't be done without a timeout, but would be nice if you could provide such functionality with your library as you'd probably choose a better minimum timeout than I would. Also it's a bit weird that the LIFX Browser demo app suffers from this behaviour (is stuck in "searching" forever).

Another related issue: let's say I have 2 light bulbs connected (correctly detected by the library), and I turn one off. IIUC the library won't tell me that through the
- (void)lightCollection:(LFXLightCollection *)lightCollection didRemoveLight:(LFXLight *)light
API (or in any other way), although I would expect it to. This is related to timing out as well: you seem to be scanning the network every 30 seconds for light state, perhaps you could consider lights not responding within X seconds as being removed from the network.

@yonilevy on the first issue: the exact way in which each specific app manages or responds to a LIFX discovery timeout may be quite different, so we've left it out of the SDK for now, but we may add it in the future.

On the second issue: there is a .reachability on LFXLight which is intended to be used for this purpose. There currently isn't an observer callback for when .reachability changes, but that's something that we plan on implementing in the LFXLightObserver protocol.

@nsforge as you suggested, I check every second the reachability of all the lights. If you power on a bulb (with the wall switch), the SDK detects the new bulb immediately (when the bulb is connected to WiFi and blinks), but when I turn it off with the wall switch, then the reachability changes only after 28 seconds.

Due to the way the LIFX network currently works, this is the best (and fastest) way to find out if a device is reachable or not. We may be able to improve the speed of this in the future, but it depends on a complex combination of network architecture, firmware and client code.

Is there a specific reason you want LFXLight.reachability to trigger straight away? Do you have a specific feature that depends on it, or is it just that you'd like your UI to update instantaneously?

@nsforge thank you for your fast answer! I use the reachability of the lights just for the UI (to let the user know how many lights are connected), so it's not that important, I just wanted to know if this is normal/expected

I think it is necessary to have an event triggered when the reachability of an item changed. Polling the reachability of a light can impact battery life of devices. I currently have a timer checking every 20 seconds and this is sufficient for my needs; however, I would prefer an event via either a callback or message.

I'm seeing the same as @LArquint when you turn a light off, it's 23 - 28 seconds before reachability is update to off.

A problem I'm seeing is turning the light back on after it's removed, I can't seem to pick it up again. I tried looping though lifxNetworkContext.allLightsCollection.lights but it doesn't seem to change even after a light is removed - same count, same lights. Is there a way to refresh lifxNetworkContext?

How does the refresh button work on the official LIFX app?

@daz A private method on LFXNetworkContext I'm guessing #15