studioimaginaire / phue

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

Not Reachable logging errors when trying to change light state #213

Closed Jackson8195 closed 2 months ago

Jackson8195 commented 2 months ago

I have been working with Phue on my desktop and things have been working great, but when trying to get this basic test script running on my Raspberry Pi Zero 2w, I get the following from the logger:

WARNING:phue:ERROR: resource, /lights/False/state, not available for light swversion WARNING:phue:ERROR: resource, /lights/False/state, not available for light name WARNING:phue:ERROR: resource, /lights/False/state, not available for light swupdate WARNING:phue:ERROR: resource, /lights/False/state, not available for light productid WARNING:phue:ERROR: resource, /lights/False/state, not available for light uniqueid WARNING:phue:ERROR: resource, /lights/False/state, not available for light capabilities WARNING:phue:ERROR: resource, /lights/False/state, not available for light productname WARNING:phue:ERROR: resource, /lights/False/state, not available for light state WARNING:phue:ERROR: resource, /lights/False/state, not available for light manufacturername WARNING:phue:ERROR: resource, /lights/False/state, not available for light swconfigid WARNING:phue:ERROR: resource, /lights/False/state, not available for light config WARNING:phue:ERROR: resource, /lights/False/state, not available for light type WARNING:phue:ERROR: resource, /lights/False/state, not available for light modelid

Seems as though the states cannot be changed? I can connect to the bridge and print all my light names etc just fine. I am running Python 2.7 on the Pi. Here is the example script I am testing with:

from phue import Bridge
import time
import logging

logging.basicConfig()
b = Bridge('192.168.0.156')
b.logging=('debug')

# If the app is not registered and the button is not pressed, press the button and call connect() (this only needs to be run a single time)
b.connect()

# Get the bridge state (This returns the full dictionary that you can explore)
bridge_state = b.get_api()

# Get a dictionary with the light name as the key
light_names = b.get_light_objects('name')
print(light_names)

light1 = b.get_light('Flower 1')
print(light1)

b.set_light(light1, 'bri', 1)
Jackson8195 commented 2 months ago

I found out my issue here, I was trying to pass a variable (light1) in the set_light() function, apparently the parameter must be the light ID or name directly, not a variable assigned with get_light(). Changing this to b.set_light('Flower 1', 'bri', 1) fixes the problem.