studioimaginaire / phue

A Python library for the Philips Hue system
Other
1.52k stars 267 forks source link

Feature Request: Serializable entities #165

Open CD-UNCC opened 4 years ago

CD-UNCC commented 4 years ago

Have we thought about making classes serializable? One cannot json.dumps bridge.lights

np3xpu commented 4 years ago

Out of curiosity, what's you use case for this?

PeanutButterPhil commented 3 years ago

Out of curiosity, what's you use case for this?

Great question, I was thinking the same. You can already identify by name, and index number once the system is established. I'm new here, but I want to keep adding to this library or fork, but I'm still discovering how to do it all.

CD-UNCC commented 3 years ago

Just trying to send bridge.lights back to a front end application as a json object. At least I think... sorry its been so long

PeanutButterPhil commented 3 years ago

Ah okay. Well, one thing I wrote for myself to handle lights was to make a For Loop and iterate through them. You could do that and add the key "name", "ID or Light Index" to a dictionary to pass to your front end as JSON.

I think my method used "hue_system"

for light, index in hue_system.get_lights():

add items to your dict

Not sure if you've tried that already or if it's more difficult than that, but this among other simple things is something I want to contribute because it's not very easy to just get all color lights or get all white lights, sensors, and in a format that can be used such as in your case.