Adafruit Hue

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
cnschuh
 
Posts: 9
Joined: Tue Nov 08, 2022 4:14 am

Adafruit Hue

Post by cnschuh »

Hi, currently i am experiencing with the adafruit_hue and i hope i am using the right thread.

I am using a Adafruit Feather RP2040 with a AirLift FeatherWing – ESP32 WiFi Co-Processor. I tested Circuitpython 7.3.3 and 8.0.0 - Beta 6 and the controller should be compatible, i guess.

Following this guide
https://learn.adafruit.com/pyportal-phi ... controller
my code fails always with the same error:

Traceback (most recent call last):
File "code.py", line 49, in <module>
File "/lib/adafruit_hue.py", line 109, in discover_bridge
File "/lib/adafruit_requests.py", line 419, in json
ValueError: syntax error in JSON

when executing functions like
ip = my_bridge.discover_bridge()
or
my_bridge.get_groups()

Doesn't matter which hue function i am using, the error is identical, just the line might be different (based on the function).
When creat

I have access to the bridge and i can fire GET,PUT..are possible (used the HUE API).
I created a user manually as well on the bridge, the connection to the HUE Bridge seems to be fine (when using a user created on the Bridge directly). But the functions like turning on of lights, get lights fails.

Currently i am using the adafruit_requests.py to debug a bit.

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adafruit Hue

Post by mikeysklar »

Did you setup a secrets.py?

Are you able to run the hue_simpletest.py?

https://github.com/adafruit/Adafruit_Ci ... pletest.py

There is a little bit of documentation on the github repo main page which might help a bit with getting communication going.

https://github.com/adafruit/Adafruit_CircuitPython_Hue

https://docs.circuitpython.org/projects ... tion-notes

User avatar
cnschuh
 
Posts: 9
Joined: Tue Nov 08, 2022 4:14 am

Re: Adafruit Hue

Post by cnschuh »

Thanks for reply.

Did you setup a secrets.py?
=> Yes i did. The ssid, password, hue user id and all required information's will be provided correctly.
I can see the acceess of the Airlift to the Hue Bridge (Timestamp).

Are you able to run the hue_simpletest.py?
https://github.com/adafruit/Adafruit_Ci ... pletest.py
=> Yes, i tested this example as well. Mostly i start with this examples first to see it is working or not.

-------------

There is a little bit of documentation on the github repo main page which might help a bit with getting communication going.

https://github.com/adafruit/Adafruit_CircuitPython_Hue

=> Thanks, i am aware of this and tested most of those things. As mentioned, the issue begin with the first function executions, e.g. lights = my_bridge.get_lights()

User avatar
cnschuh
 
Posts: 9
Joined: Tue Nov 08, 2022 4:14 am

Re: Adafruit Hue

Post by cnschuh »

I have an update, i would like to see the issue is truly related on the Adafruit_Hue or Adafruit_requests libs.

Usage of the test was the guide below:
https://learn.adafruit.com/adafruit-air ... et-connect

Result:
The first json cames from the guide above, the second JSON from my HUE bridge. The JSON from HUE is valid.

Fetching json from http://api.coindesk.com/v1/bpi/currentprice/USD.json
----------------------------------------
{'time': {'updated': 'Jan 11, 2023 08:28:00 UTC', 'updatedISO': '2023-01-11T08:28:00+00:00', 'updateduk': 'Jan 11, 2023 at 08:28 GMT'}, 'disclaimer': 'This data was produced from the CoinDesk BANNED Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org', 'bpi': {'USD': {'code': 'USD', 'description': 'United States Dollar', 'rate_float': 17428.1, 'rate': '17,428.0921'}}}
----------------------------------------

Fetching json from http://192.168.178.26/api/-lxlSLEO1If8k ... ZdrJJNdU4/
----------------------------------------
Traceback (most recent call last):
File "code.py", line 71, in <module>
File "adafruit_requests.py", line 419, in json
ValueError: syntax error in JSON
----------------------------------------

Fetching json from http://192.168.178.26/api/-lxlSLEO1If8k ... 4/lights/7
----------------------------------------
Traceback (most recent call last):
File "code.py", line 71, in <module>
File "adafruit_requests.py", line 419, in json
ValueError: syntax error in JSON

Code done running.


Could it be possible the firmware of the Airlift, i tested the Feater and Breakout Airlift, both runs with Firmware 1.2.2. Personally i don't believe it is related on the firmware.

Another point might be the size of 110 KB from the JSON file. I did a test with https://api.github.com/users/mralexgray/repos (json arround 170 KB), but i got another error, related on the memory (as expexted).

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adafruit Hue

Post by mikeysklar »

It appears you can access the Adafruit example JSON file without issue:

http://api.coindesk.com/v1/bpi/currentprice/USD.json

But the two attempts to pull down a JSON file from your internal web servers are failing. Is that correct?

http://192.168.178.26/....

Are you able to have the filename be accessible as JSON in case the adafruit_requests is looking at the name/extension. Have you verified you can manually pull down the file with the links you are using from another machine using wget?

User avatar
cnschuh
 
Posts: 9
Joined: Tue Nov 08, 2022 4:14 am

Re: Adafruit Hue

Post by cnschuh »

Hello,

looks like it was related on the missing content length of the Hue Bridge JSON file.

The issue occured with the adafruit_requests.py:

https://github.com/adafruit/Adafruit_Ci ... s/pull/123

Now it includes a timeout. Since using the new file the problem seems to be gone.

Thanks

Locked
Please be positive and constructive with your questions and comments.

Return to “Wireless: WiFi and Bluetooth”