SmartThingsCommunity / SmartThingsEdgeDrivers

Apache License 2.0
269 stars 463 forks source link

[Aqara] Presence Sensor FP2 #1546

Closed seojune79 closed 2 months ago

seojune79 commented 4 months ago

Check all that apply

Type of Change

Checklist

Description of Change

Summary of Completed Tests

github-actions[bot] commented 4 months ago

Duplicate profile check: Passed - no duplicate profiles detected.

github-actions[bot] commented 4 months ago

Invitation URL: https://bestow-regional.api.smartthings.com/invite/d429GXaPoyjo

github-actions[bot] commented 4 months ago

Test Results

   62 files    375 suites   0s :stopwatch: 1 822 tests 1 822 :white_check_mark: 0 :zzz: 0 :x: 3 146 runs  3 146 :white_check_mark: 0 :zzz: 0 :x:

Results for commit 640f0667.

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 4 months ago

Minimum allowed coverage is 90%

Generated by :monkey: cobertura-action against 640f0667a413440b9674c6adc6228d57c2f236fc

varzac commented 4 months ago

For LAN devices we need to include a search-parameters.yml to allow the hub to only start the driver if there is a matching device on the network.

varzac commented 4 months ago

I have an FP2 so I decided to try to discover it. Currently I am just getting:

2024-07-29T16:17:20.207227119Z TRACE aqara-presence-sensor  try_add_device : dni= ***, ip= 192.168.1.146
2024-07-29T16:17:24.910038642Z ERROR aqara-presence-sensor  get_credential : ip = 192.168.1.146, failed to get token, error = closed
2024-07-29T16:17:24.915560443Z ERROR aqara-presence-sensor  credential is nil
2024-07-29T16:17:24.927665159Z ERROR aqara-presence-sensor  failed to get credential. dni= ***, ip= 192.168.1.146

I made sure to update the FP2 to the latest firmware, but if there is anything else needed to test let me know.

seojune79 commented 4 months ago

For LAN devices we need to include a search-parameters.yml to allow the hub to only start the driver if there is a matching device on the network.

I added it.

seojune79 commented 4 months ago

I have an FP2 so I decided to try to discover it. Currently I am just getting:

2024-07-29T16:17:20.207227119Z TRACE aqara-presence-sensor  try_add_device : dni= ***, ip= 192.168.1.146
2024-07-29T16:17:24.910038642Z ERROR aqara-presence-sensor  get_credential : ip = 192.168.1.146, failed to get token, error = closed
2024-07-29T16:17:24.915560443Z ERROR aqara-presence-sensor  credential is nil
2024-07-29T16:17:24.927665159Z ERROR aqara-presence-sensor  failed to get credential. dni= ***, ip= 192.168.1.146

I made sure to update the FP2 to the latest firmware, but if there is anything else needed to test let me know.

You'll need to use the firmware that will be released in August to enroll in the SmartThings Hub. If you need that firmware, please let me know the information below in the Aqara Home app.

You give me the information and our developers will request Equipment diagnosis permission application authorization. You'll have to approve it. After that, our developers will update your FP2 to that firmware.(FP2 must be online to be updated.)

How to connect to your SmartThings hub after the FP2 firmware update.

  1. The FP2 must be enrolled in the Aqara Home app.
  2. The SmartThings hub and FP2 must be connected to the same network.
  3. Your SmartThings hub must have the current driver installed.
  4. "Scan nearby" in the SmartThings app and the FP2 will register with the SmartThings hub.
lelandblue commented 4 months ago

@seojune79 Can you please clarify, what testing have you completed to date? I noticed this was missing from the original message in this PR, can you please add or share more details?

seojune79 commented 4 months ago

@seojune79 Can you please clarify, what testing have you completed to date? I noticed this was missing from the original message in this PR, can you please add or share more details?

We tested with Samsung to ensure that the following events are handled the same as in the Aqara Home app. (Settings can only be made in the Aqara Home app, and depending on the setting, the same event will occur in both the Aqara Home app and the SmartThings app.)

lelandblue commented 3 months ago

@tpmanley or @varzac Could you review the latest commit when you get a chance and let me know if this review is good to proceed? Thank you.

varzac commented 3 months ago

One issue I ran into was I edited the names of my Zones last week, however when looking today I see that the names have reverted to Zone 1, Zone 2, Zone 3. I don't know if that is due to ongoing development or something else.

tpmanley commented 3 months ago

One issue I ran into was I edited the names of my Zones last week, however when looking today I see that the names have reverted to Zone 1, Zone 2, Zone 3. I don't know if that is due to ongoing development or something else.

I saw this too and reproduced it by rebooting my hub. The first multipleZonePresence.zoneState event generated after the reboot had the default "zone1" name again.

seojune79 commented 3 months ago

One issue I ran into was I edited the names of my Zones last week, however when looking today I see that the names have reverted to Zone 1, Zone 2, Zone 3. I don't know if that is due to ongoing development or something else.

Did it happen even though you didn't change the zone? If you experience that issue again, please share how to reproduce it.

seojune79 commented 3 months ago

One issue I ran into was I edited the names of my Zones last week, however when looking today I see that the names have reverted to Zone 1, Zone 2, Zone 3. I don't know if that is due to ongoing development or something else.

I saw this too and reproduced it by rebooting my hub. The first multipleZonePresence.zoneState event generated after the reboot had the default "zone1" name again.

Thanks. I've reproduced the issue on my FP2, I'll check it out.

seojune79 commented 3 months ago

One issue I ran into was I edited the names of my Zones last week, however when looking today I see that the names have reverted to Zone 1, Zone 2, Zone 3. I don't know if that is due to ongoing development or something else.

I saw this too and reproduced it by rebooting my hub. The first multipleZonePresence.zoneState event generated after the reboot had the default "zone1" name again.

I fixed it.

varzac commented 3 months ago

I did have my Zone names disappear again. Otherwise the device has been working great for me. I don't know how the zone names were lost I just opened up the app and they were gone. There was a hub firmware update so there was a hub reboot. But I did re-name them and manually reboot the hub and the name persisted. Was the fix you added something that would only take affect the next time I named them?

seojune79 commented 3 months ago

Can someone let me know how this PR is going?

lelandblue commented 3 months ago

Can someone let me know how this PR is going?

Hey @seojune79 - @cjswedes just did a review of the new commit. Please feel welcome to review. As a result - This device will proceed through the WWST Certification process. I hope I have answered your question.

seojune79 commented 3 months ago

We made some code changes based on his comments.

ldeora commented 2 months ago

Edit: latest commit (mainly rest.lua) broke it.

2024-09-27T22:47:45.440063966Z ERROR Aqara Presence 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 this 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.

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

This is the complete log and it looks like the driver lifecycle ends?

ldeora commented 2 months ago

Proposal for a fix for the wantread, socket not ready issue:

https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/issues/1654