ascernas77
(Alejandro Segura)
October 22, 2024, 4:14pm
1
Is anyone having issues with the Philips Hue Integration. Today I realized the lights were not updating its status on ST, then noticed it started getting communication errors with Philips hue.
Then when I checked the Philips hue device suddenly screwed up all my rooms, put everything in one room (where I put the bridge on the app), then some of the light stopped responding.
I decided to remove the hue bridge from Smartthings as the mess up was already done by Samsung
Now when try to add the hue via the Add Suggestion the ST is giving me, it get an error every time, so right now i am unable to add all my lights to ST
1 Like
I leave this here as for reference:
The Philips Hue driver uses the same code as the Aqara FP2 driver to communicate with the device, called lunchbox . There seems to be an issue…
opened 12:04AM - 30 Sep 24 UTC
The wantread message indicates that the socket is not ready to read data yet and… the operation should be retried later. This happens when you're trying to read data from a socket, but the data isn't available at that moment.
This is a proposal for a fix for the Aqara FP2 issue #1648 .
Add a new function in rest.lua to check if the socket is ready for reading
```
local function wait_for_read(socket, timeout)
-- Use socket.select to check if the socket is ready for reading
local ready_sockets, _, _ = socket.select({socket}, nil, timeout)
return #ready_sockets > 0 -- Returns true if the socket is ready to read
end
```
And use it here:
https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/7821a5d168d89fb449391a584a3566c605389265/drivers/SmartThings/philips-hue/src/lunchbox/rest.lua#L106-L108
https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/7821a5d168d89fb449391a584a3566c605389265/drivers/Aqara/aqara-presence-sensor/src/lunchbox/rest.lua#L104-L106
```
if wait_for_read(sock, 1) then
next_recv, next_err, partial = sock:receive(pat)
else
-- No data is ready, sleep for a bit
socket.sleep(0.1)
end
```
Additionally handle wantread here by waiting and trying again:
https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/7821a5d168d89fb449391a584a3566c605389265/drivers/SmartThings/philips-hue/src/lunchbox/rest.lua#L109-L120
https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/7821a5d168d89fb449391a584a3566c605389265/drivers/Aqara/aqara-presence-sensor/src/lunchbox/rest.lua#L107-L118
```
if next_err ~= nil then
if string.lower(next_err) == "closed" then
if partial ~= nil and #partial >= 1 then
full_response:append_body(partial)
next_chunk_bytes = 0
else
return nil, next_err
end
elseif string.lower(next_err) == "wantread" then
-- Wait and try again if socket is not ready yet
socket.sleep(0.1)
else
return nil, ("unexpected error reading chunked transfer: " .. next_err)
end
end
```
Sorry for the formatting...
opened 01:04PM - 25 Sep 24 UTC
Edit: there's the problem:
```
2024-09-27T22:47:45.440063966Z ERROR Aqara Pr… esence Sensor get_credential : ip = 192.168.1.121, failed to get token, error = wantread
2024-09-27T22:47:45.445295882Z WARN Aqara Presence Sensor credential is nil
2024-09-27T22:47:45.450356841Z ERROR Aqara Presence Sensor failed to get credential. dni= 54:EF:44:5C:4C:98, ip= 192.168.1.121
```
Can't add the device anymore! Removed the device, deleted the driver, added driver, tried to add the device. Tried it with main, beta, and PR channel to make sure.
It worked about a month ago. Since then, changes were made to *discovery.lua*, *init.lua*, *device_manager.lua*...
Can someone please check if adding the device still works?
Device firmware: 1.2.7_0011.0080
Hub firmware: 000.053.00019
ST app (Android): 1.8.18.21
Device works with the Aqara Home app.
This is the complete log and it looks like the driver lifecycle ends?
```
2024-09-25T10:34:03.597153457Z TRACE Aqara Presence Sensor Setup driver aqara-fp2 with lifecycle handlers:
DeviceLifecycleDispatcher: aqara-fp2
default_handlers:
infoChanged:
added:
init:
removed:
driverSwitched:
child_dispatchers:
2024-09-25T10:34:03.609944082Z TRACE Aqara Presence Sensor Setup driver aqara-fp2 with Capability handlers:
CapabilityCommandDispatcher: aqara-fp2
default_handlers:
refresh:
refresh
multipleZonePresence:
createZone
deleteZone
updateZoneName
child_dispatchers:
2024-09-25T10:34:03.616156957Z INFO Aqara Presence Sensor Created dispatcher [SecretDataDispatcher]aqara-fp2 that had no handlers
2024-09-25T10:34:03.628525582Z TRACE Aqara Presence Sensor Setup driver aqara-fp2 with Secret Data handlers:
SecretDataDispatcher: aqara-fp2
default_handlers:
child_dispatchers:
2024-09-25T10:34:03.686260707Z TRACE Aqara Presence Sensor Received event with handler driver_lifecycle
2024-09-25T10:34:03.707111916Z INFO Aqara Presence Sensor received driver startupState: {"hub_zigbee_id":"KG2XAAILh00=","hub_node_id":1,"hub_ipv4":"192.168.1.116"}
2024-09-25T10:34:03.712373791Z TRACE Aqara Presence Sensor Received event with handler discovery
2024-09-25T10:34:03.718594541Z INFO Aqara Presence Sensor discovery_mdns.find_device_ips
2024-09-25T10:34:04.889382333Z INFO Aqara Presence Sensor found_name = _Aqara-FP2._tcp
2024-09-25T10:34:04.941494333Z INFO Aqara Presence Sensor ip = 192.168.1.109
2024-09-25T10:34:04.959243583Z INFO Aqara Presence Sensor found_name = _Aqara-FP2._tcp
2024-09-25T10:34:04.972437916Z INFO Aqara Presence Sensor ip = 192.168.1.109
2024-09-25T10:34:05.017133958Z TRACE Aqara Presence Sensor unknown dni= 54:EF:44:5C:4C:98, ip= 192.168.1.109
2024-09-25T10:34:05.041282958Z TRACE Aqara Presence Sensor try_add_device : dni= 54:EF:44:5C:4C:98, ip= 192.168.1.109
2024-09-25T10:34:05.075223208Z INFO Aqara Presence Sensor 54:EF:44:5C:4C:98 Creating TCP socket for REST Connection
2024-09-25T10:34:05.097121666Z INFO Aqara Presence Sensor 54:EF:44:5C:4C:98 Setting TCP socket timeout for REST Connection
2024-09-25T10:34:05.118858583Z INFO Aqara Presence Sensor 54:EF:44:5C:4C:98 Connecting TCP socket for REST Connection
2024-09-25T10:34:05.394824874Z INFO Aqara Presence Sensor 54:EF:44:5C:4C:98 Set Keepalive for TCP socket for REST Connection
2024-09-25T10:34:05.408426249Z INFO Aqara Presence Sensor 54:EF:44:5C:4C:98 Creating SSL wrapper for for REST Connection
2024-09-25T10:34:05.423615083Z INFO Aqara Presence Sensor 54:EF:44:5C:4C:98 Performing SSL handshake for for REST Connection
2024-09-25T10:34:07.962791666Z INFO Aqara Presence Sensor 54:EF:44:5C:4C:98 Successfully created TCP connection
2024-09-25T10:35:02.506882839Z TRACE Aqara Presence Sensor Received event with handler discovery
2024-09-25T10:35:02.574833131Z TRACE Aqara Presence Sensor Received event with handler driver_lifecycle
```
And a rollback to a previous version of the lunchbox used in the FP2 driver fixed the issue:
SmartThingsCommunity:main
← hdlee27:fp2_rollback
opened 10:35AM - 22 Oct 24 UTC
Check all that apply
# Type of Change
- [ ] WWST Certification Request
… - If this is your first time contributing code:
- [ ] I have reviewed the README.md file
- [ ] I have reviewed the CODE_OF_CONDUCT.md file
- [ ] I have signed the CLA
- [ ] I plan on entering a WWST Certification Request or have entered a request through the WWST Certification console at developer.smartthings.com
- [x] Bug fix
- [ ] New feature
- [ ] Refactor
# Checklist
- [x] I have performed a self-review of my code
- [] I have commented my code in hard-to-understand areas
- [x] I have verified my changes by testing with a device or have communicated a plan for testing
- [ ] I am adding new behavior, such as adding a sub-driver, and have added and run new unit tests to cover the new behavior
# Description of Change
# Summary of Completed Tests
The FP2 driver was working until this:
Please pull in the latest lunchbox version that exists in the philips hue driver. This will help with maintenance in the future when we add the library to the lua libs and no longer need to put it in these lan drivers.
I’m ldeora .
And here’s the patch that could fix it:
https://patch-diff.githubusercontent.com/raw/SmartThingsCommunity/SmartThingsEdgeDrivers/pull/1711.patch
jkp
October 22, 2024, 4:48pm
3
Do you have an ST hub or only use the app without a hub? If you have a hub, which method are you using to connect your hue bridge; direct connection, cloud to cloud, custom edge driver (if you have a hub) or matter.
If you have a ST hub… you may want to try the Matter connection if you are able to.
ascernas77
(Alejandro Segura)
October 22, 2024, 6:56pm
4
Hi @jkp
I have been using for year the one that you need to press the Hub Bridge button to sync. That is the one that for some reason started having issue like not updating light status, delay on actions, etc. (maybe because of the explained above by @Andreas_Roedl )
I added back the Hub Bridge using the same method as above and it worked this time. However, it screwed up all my routings, scenes
Now, I just realized the “Smart lighting” SmartApp is showed “off” however all the routings inside are there and so far works fine, but when I try to Enabled it, it tells me “No network connection” even the Hub is online and connected (I can control everything). This started happening at the same time as the Hub bridge issue
BTW I have ST hub V2