dotMorten / LifxNet

A .NET library for controlling LIFX light bulbs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider public setters for Device / LightBulb

dmarjoram opened this issue · comments

At the moment, these types can't be serialized/deserialized in UWP (no reflection as a workaround). I don't want to have to rely on device discovery upon app startup before issuing commands to cached light bulbs and the Lifxnet API only accepts Lightbulb instances for telling it where to send commands.

An alternative would be to provide API overloads allowing MAC, IP, port params etc and I can just cache that data instead rather than Lightbulb instances.

Thanks ;)

I would suggest you build a model around each bulb that you can serialize. As lights gets re-discovered, you feed the model the Lightbulb instance, and enable it to allow for interaction in the UI. I would heavily recommend against trying to work with bulbs that hasn't actually been announced yet. You can't really rely on parameters staying the same

I think making these parameters settable would make the object model lie about what is actually settable or not. I'd prefer a concise and clear API that tells you exactly what it can and can't do.

I did exactly as you described in the first version of the code. Unfortunately, to respond to Cortana commands, I can't wait for bulbs to announce :(

Fair point. Let me think a little and see if I can't come up with a way the supports both.