studioimaginaire / phue

A Python library for the Philips Hue system
Other
1.54k stars 266 forks source link

TypeError: list indices must be integers or slices, not str #210

Open Nickduino opened 11 months ago

Nickduino commented 11 months ago

I'm just trying to get the state of a light (light 1 does exist, "print(lights[1].name)" returns a name)

image

image

Nickduino commented 11 months ago

Seems identical to https://github.com/studioimaginaire/phue/issues/107

Nickduino commented 11 months ago

I made a mistake

lights[1].name returned "Lit", so I thought light 1 was "Lit"

But it was [1] and not (1), meaning it was light #1 of the list lights and not light number 1

So, in the examples, instead of : Get the name of light 1 lights[1].name

Maybe you could propose: Get the name of light 1, b.get_light(1,'name'))

OR

Get the name of light [1] of lights lights[1].name

Nickduino commented 11 months ago

Also, when a light is unreachable, maybe you could return the error ([{'error': {'description': 'resource, /lights/1, not available', 'type': 3, 'address': '/lights/1'}}]) as a string, so that we can print it?

Nickduino commented 11 months ago

I consider my issue solved but I leave it open to give @studioimaginaire a chance to check it out