SmartThingsEdgeDrivers icon indicating copy to clipboard operation
SmartThingsEdgeDrivers copied to clipboard

Add DeepSmart

Open refuseRed opened this issue 1 year ago • 18 comments

Add DeepSmart

refuseRed avatar Mar 20 '24 09:03 refuseRed

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 20 '24 09:03 CLAassistant

Duplicate profile check: Passed - no duplicate profiles detected.

github-actions[bot] avatar Apr 01 '24 12:04 github-actions[bot]

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

github-actions[bot] avatar Apr 01 '24 12:04 github-actions[bot]

Test Results

   61 files  +1    377 suites  ±0   0s :stopwatch: ±0s 1 828 tests ±0  1 828 :white_check_mark: ±0  0 :zzz: ±0  0 :x: ±0  3 177 runs  ±0  3 177 :white_check_mark: ±0  0 :zzz: ±0  0 :x: ±0 

Results for commit c7e1f410. ± Comparison against base commit 23deab79.

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

github-actions[bot] avatar Apr 01 '24 12:04 github-actions[bot]

Minimum allowed coverage is 90%

Generated by :monkey: cobertura-action against c7e1f410d4530a945488a923943c32eefa7f7d13

github-actions[bot] avatar Apr 01 '24 12:04 github-actions[bot]

The main two issues I see which need to be addressed are:

  1. the periodic multicast discovery running every 30 seconds
  2. the way devices are initialized when first added and when the driver starts up do not follow existing patterns where it is done on a device by device basis in the init/added lifecycle handlers. See the Hue (most relevant), Sonos, or Bose drivers for example on how this works.

cjswedes avatar Apr 16 '24 18:04 cjswedes

The main two issues I see which need to be addressed are:

  1. the periodic multicast discovery running every 30 seconds
  2. the way devices are initialized when first added and when the driver starts up do not follow existing patterns where it is done on a device by device basis in the init/added lifecycle handlers. See the Hue (most relevant), Sonos, or Bose drivers for example on how this works.

1 periodic discovery is used to check whether the bridge is alive and the ip is same with previous ip 2 delete old wisers.init() function. bridge and devices are all initialized in lifecycle's init function

refuseRed avatar Apr 18 '24 09:04 refuseRed

Hi @refuseRed

Please move your driver dir deepsmart from SmartThingsEdgeDrivers/drivers to SmartThingsEdgeDrivers/ Just like SmartThingsEdgeDrivers/drivers/Aqara

liuyd96 avatar Apr 28 '24 02:04 liuyd96

Hi @refuseRed

Please move your driver dir deepsmart from SmartThingsEdgeDrivers/drivers to SmartThingsEdgeDrivers/ Just like SmartThingsEdgeDrivers/drivers/Aqara

Ok, adjusted

refuseRed avatar Apr 28 '24 03:04 refuseRed

Hi @refuseRed

Commits should be squashed down to a single commit prior to merging, as well as be rebased on top of the upstream branch

  1. Add upstream repo
❯ git remote add upstream https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers.git
  1. Rebase your branch with upstream
❯ git pull --rebase upstream main
From https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers
 * branch              main       -> FETCH_HEAD
Current branch dev is up to date.
  1. Check commit info
❯ git log --oneline
9c002b5d (HEAD -> dev) optimization
0f6fed98 deepsmart Change to DeepSmart
7def2870 update
43dc63d1 update
3e5c48a9 update
6412b586 update
c6eb992c update
37e9f705 optimization
a92744c8 optimization
57d8862b optimization
3b3f9d2e optimization
7cf8fce6 optimization
1e3a5c38 optimization
485ada2e update
1c21ce9c optimization
242af490 Add DeepSmart Hub
90206d9f (upstream/main, main) Merge pull request #1362 from SmartThingsCommunity/bugfix/multi-garage <------ This is upstream base commit
---snip---
  1. Squash your commit
❯ git rebase -i 90206d9f

  1 pick 242af490 Add DeepSmart Hub
  2 pick 1c21ce9c optimization
  3 pick 485ada2e update
  4 pick 1e3a5c38 optimization
  5 pick 7cf8fce6 optimization
  6 pick 3b3f9d2e optimization
  7 pick 57d8862b optimization
  8 pick a92744c8 optimization
  9 pick 37e9f705 optimization
 10 pick c6eb992c update
 11 pick 6412b586 update
 12 pick 3e5c48a9 update
 13 pick 43dc63d1 update
 14 pick 7def2870 update
 15 pick 0f6fed98 deepsmart Change to DeepSmart
 16 pick 9c002b5d optimization
 17
 18 # Rebase 90206d9f..9c002b5d onto 9c002b5d (16 commands)
 19 #
 ---snip---
  1. Edit pick to 's' from line 2 to line 16, then save
  1 # This is a combination of 16 commits.
  2 # This is the 1st commit message:
  3
  4 Add DeepSmart Hub
  5
  6 Signed-off-by: “liuzhonghua” <[email protected]>
  7
  8 # This is the commit message #2:
  9
 10 optimization
 11
 12 Signed-off-by: “liuzhonghua” <[email protected]>
 13
 14 # This is the commit message #3:
 15
 16 update
 17
 18 Signed-off-by: “liuzhonghua” <[email protected]>
 19
 20 # This is the commit message #4:
 21
 22 optimization
 23
 24 Signed-off-by: “liuzhonghua” <[email protected]>
 25
 26 # This is the commit message #5:
 27
 28 optimization
 29
 30 Signed-off-by: “liuzhonghua” <[email protected]>
 31
 32 # This is the commit message #6:
 33
 34 optimization
 35
 36 Signed-off-by: “liuzhonghua” <[email protected]>
  1. Squash commit info, then save.
1 Add DeepSmart Hub
  2
  3 Signed-off-by: “liuzhonghua” <[email protected]>
  4
  5 # Please enter the commit message for your changes. Lines starting
  6 # with '#' will be ignored, and an empty message aborts the commit.
  7 #
  8 # Author:    “liuzhonghua” <[email protected]>
  9 # Date:      Wed Mar 20 17:32:35 2024 +0800
 10 #
 11 # On branch dev
 12 # Changes to be committed:
 13 #>--new file:   DeepSmart/deepsmart/config.yml
 14 #>--new file:   DeepSmart/deepsmart/profiles/Ac.yml
 15 #>--new file:   DeepSmart/deepsmart/profiles/Deepsmart-bridge.yml
 16 #>--new file:   DeepSmart/deepsmart/profiles/Heater.yml
 17 #>--new file:   DeepSmart/deepsmart/profiles/Newfan.yml
 18 #>--new file:   DeepSmart/deepsmart/search-parameters.yml
 19 #>--new file:   DeepSmart/deepsmart/src/commands.lua
 20 #>--new file:   DeepSmart/deepsmart/src/config.lua
 21 #>--new file:   DeepSmart/deepsmart/src/deepsmart/api.lua
 22 #>--new file:   DeepSmart/deepsmart/src/deepsmart/devices.lua
 23 #>--new file:   DeepSmart/deepsmart/src/deepsmart/dp2knx.lua
 24 #>--new file:   DeepSmart/deepsmart/src/deepsmart/dpenum.lua
 25 #>--new file:   DeepSmart/deepsmart/src/deepsmart/wisers.lua
 26 #>--new file:   DeepSmart/deepsmart/src/discovery.lua
 27 #>--new file:   DeepSmart/deepsmart/src/init.lua
 28 #>--new file:   DeepSmart/deepsmart/src/lifecycles.lua
 29 #>--new file:   DeepSmart/deepsmart/src/lunchbox/init.lua
 30 #>--new file:   DeepSmart/deepsmart/src/lunchbox/rest.lua
 31 #>--new file:   DeepSmart/deepsmart/src/lunchbox/sse/eventsource.lua
 32 #>--new file:   DeepSmart/deepsmart/src/lunchbox/util.lua
 33 #>--new file:   DeepSmart/deepsmart/src/selfSignedRoot.crt
 34 #>--new file:   DeepSmart/deepsmart/src/ssdp.lua
 35 #>--new file:   DeepSmart/deepsmart/src/utils.lua
 ---snip---

Now you have squashed commit successfully.

❯ git log --oneline
38eaad6c (HEAD -> dev) Add DeepSmart Hub
90206d9f (upstream/main, main) Merge pull request #1362 from SmartThingsCommunity/bugfix/multi-garage <------ This is upstream base commit

liuyd96 avatar May 07 '24 06:05 liuyd96

Looks like luacheck isn't passing. We would like to keep this passing, so please make the changes to address it. You can view the errors in CI, but here they are as well:

Checking drivers/DeepSmart/deepsmart/src/deepsmart/api.lua 1 warning

    drivers/DeepSmart/deepsmart/src/deepsmart/api.lua:185:5: (W511) unreachable code

Checking drivers/DeepSmart/deepsmart/src/deepsmart/wisers.lua 4 warnings

    drivers/DeepSmart/deepsmart/src/deepsmart/wisers.lua:2:7: (W211) unused variable socket
    drivers/DeepSmart/deepsmart/src/deepsmart/wisers.lua:8:7: (W211) unused variable utils
    drivers/DeepSmart/deepsmart/src/deepsmart/wisers.lua:63:34: (W113) accessing undefined variable wiser_index_code
    drivers/DeepSmart/deepsmart/src/deepsmart/wisers.lua:65:24: (W113) accessing undefined variable wiser_index_code

Checking drivers/DeepSmart/deepsmart/src/discovery.lua 1 warning

    drivers/DeepSmart/deepsmart/src/discovery.lua:25:26: (W614) trailing whitespace in a comment

Checking drivers/DeepSmart/deepsmart/src/init.lua 2 warnings

    drivers/DeepSmart/deepsmart/src/init.lua:4:7: (W211) unused variable dp2knx
    drivers/DeepSmart/deepsmart/src/init.lua:5:7: (W211) unused variable dpenum

Checking drivers/DeepSmart/deepsmart/src/lifecycles.lua 3 warnings

    drivers/DeepSmart/deepsmart/src/lifecycles.lua:1:7: (W211) unused variable commands
    drivers/DeepSmart/deepsmart/src/lifecycles.lua:13:46: (W614) trailing whitespace in a comment
    drivers/DeepSmart/deepsmart/src/lifecycles.lua:42:59: (W612) line contains trailing whitespace

You can run luacheck locally by installing with luarocks, and then using this command from the SmartThingsEdgeDrivers/ directory: luacheck --config .github/workflows/.luacheckrc drivers/**

cjswedes avatar May 07 '24 15:05 cjswedes

Hi @refuseRed

There‘s still a warning needs to be solved.

❯ luacheck --config .github/workflows/.luacheckrc drivers/DeepSmart/*
Checking drivers/DeepSmart/deepsmart/src/commands.lua OK
Checking drivers/DeepSmart/deepsmart/src/config.lua OK
Checking drivers/DeepSmart/deepsmart/src/deepsmart/api.lua 1 warning

    drivers/DeepSmart/deepsmart/src/deepsmart/api.lua:173:3: (W512) loop is executed at most once

Checking drivers/DeepSmart/deepsmart/src/deepsmart/devices.lua OK
Checking drivers/DeepSmart/deepsmart/src/deepsmart/dp2knx.lua OK
Checking drivers/DeepSmart/deepsmart/src/deepsmart/dpenum.lua OK
Checking drivers/DeepSmart/deepsmart/src/deepsmart/wisers.lua OK
Checking drivers/DeepSmart/deepsmart/src/discovery.lua OK
Checking drivers/DeepSmart/deepsmart/src/init.lua OK
Checking drivers/DeepSmart/deepsmart/src/lifecycles.lua OK
Checking drivers/DeepSmart/deepsmart/src/ssdp.lua OK
Checking drivers/DeepSmart/deepsmart/src/utils.lua OK

Total: 1 warning / 0 errors in 12 files

liuyd96 avatar May 08 '24 04:05 liuyd96

@refuseRed

❯ luacheck --config .github/workflows/.luacheckrc drivers/DeepSmart/*
Checking drivers/DeepSmart/deepsmart/src/commands.lua OK
Checking drivers/DeepSmart/deepsmart/src/config.lua OK
Checking drivers/DeepSmart/deepsmart/src/deepsmart/api.lua OK
Checking drivers/DeepSmart/deepsmart/src/deepsmart/devices.lua OK
Checking drivers/DeepSmart/deepsmart/src/deepsmart/dp2knx.lua OK
Checking drivers/DeepSmart/deepsmart/src/deepsmart/dpenum.lua OK
Checking drivers/DeepSmart/deepsmart/src/deepsmart/wisers.lua 3 warnings

    drivers/DeepSmart/deepsmart/src/deepsmart/wisers.lua:40:14: (W311) value assigned to variable endpos is unused
    drivers/DeepSmart/deepsmart/src/deepsmart/wisers.lua:387:30: (W113) accessing undefined variable uuid
    drivers/DeepSmart/deepsmart/src/deepsmart/wisers.lua:389:17: (W211) unused variable dev

Checking drivers/DeepSmart/deepsmart/src/discovery.lua OK
Checking drivers/DeepSmart/deepsmart/src/init.lua OK
Checking drivers/DeepSmart/deepsmart/src/lifecycles.lua OK
Checking drivers/DeepSmart/deepsmart/src/ssdp.lua OK
Checking drivers/DeepSmart/deepsmart/src/utils.lua OK

Total: 3 warnings / 0 errors in 12 files

liuyd96 avatar Jul 22 '24 02:07 liuyd96

Update point:

  1. Change the search sub device to gateway and add it successfully before searching again
  2. device types resolved from uuid no longer using storage
  3. When controlling, change arg to args
  4. Change the search gateway to broadcast to prevent WiFi routers from not supporting multicast
  5. Do not update devices when querying gateway devices fails
  6. Do not delete devices during search (can only be deleted on the app)
  7. Add device queries and initial settings during bridge initialization

refuseRed avatar Jul 22 '24 02:07 refuseRed

@cjswedes again review

refuseRed avatar Jul 22 '24 02:07 refuseRed

We've reviewed the self-test cases for the latest code.

zouy414 avatar Jul 22 '24 10:07 zouy414

We will be re-reviewing this code as soon as we can, thank you!

lelandblue avatar Jul 23 '24 14:07 lelandblue

I will let @lelandblue merge when appropriate.

We have asked other departments to test ASAP.

Thank you so much.

liuyd96 avatar Aug 21 '24 02:08 liuyd96