Skip to content

Commit

Permalink
Merge branch 'main' into fix-preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
aguilbault-Sinope authored Feb 13, 2024
2 parents eb0f747 + 7299001 commit f0228b4
Show file tree
Hide file tree
Showing 332 changed files with 19,921 additions and 1,868 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/mirror-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Mirror repo

on:
push:
branches:
- main
- beta
- production

jobs:
to_ecode:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pixta-dev/repository-mirroring-action@v1
with:
target_repo_url:
[email protected]:iot/EdgeDriversMirror.git
ssh_private_key:
${{ secrets.ECODE_SSH_PRIVATE_KEY }}
5 changes: 3 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ jobs:
- uses: actions/checkout@v3
- name: get changed drivers
id: changed-drivers
uses: tj-actions/changed-files@v35
uses: tj-actions/changed-files@v41
with:
dir_names: true
dir_names_max_depth: 3
files: "drivers"
files: "drivers/**"
safe_output: false
- run: echo ${{ steps.changed-drivers.outputs.all_modified_files }}
- name: Install Python requirements
run: pip install -r tools/requirements.txt
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/upload-driver-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ jobs:
- uses: actions/checkout@v3
- name: get changed drivers
id: changed-drivers
uses: tj-actions/changed-files@v35
uses: tj-actions/changed-files@v41
with:
dir_names: true
dir_names_max_depth: 3
files: "drivers"
files: "drivers/**"
json: true
safe_output: false
- id: set-outputs
run: echo "matrix=${{ steps.changed-drivers.outputs.all_modified_files }}" >> $GITHUB_OUTPUT
- run: echo ${{ steps.changed-drivers.outputs.all_modified_files }}
Expand All @@ -37,7 +38,7 @@ jobs:
- name: Package the driver
working-directory: ${{ matrix.driver }}
run: |
zip -v ${{env.package_key}}.zip config.yml fingerprints.yml search-parameters.y*ml $(find profiles -name "*.y*ml") $(find . -name "*.lua") -x "*test*"
zip -v ${{env.package_key}}.zip config.yml fingerprints.yml search-parameters.y*ml $(find . -name "*.pem") $(find . -name "*.crt") $(find profiles -name "*.y*ml") $(find . -name "*.lua") -x "*test*"
- name: Upload packaged driver artifact
uses: actions/upload-artifact@v3
with:
Expand Down
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pipeline {
currentBuild.displayName = "#" + currentBuild.number + " " + env.BRANCH
currentBuild.description = "Drivers changed: " + env.CHANGED_DRIVERS
}
sh 'git config --global --add safe.directory "*"'
sh 'git clean -xfd'
sh 'apt-get update'
sh 'apt-get install zip -y'
Expand Down
29 changes: 29 additions & 0 deletions drivers/Aqara/aqara-cube/capabilities/cubeAction.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
id: stse.cubeAction
version: 1
status: proposed
name: Cube Action
ephemeral: false
attributes:
cubeAction:
schema:
type: object
properties:
value:
title: ActionType
type: string
enum:
- noAction
- shake
- rotate
- pickUpAndHold
- flipToSide1
- flipToSide2
- flipToSide3
- flipToSide4
- flipToSide5
- flipToSide6
additionalProperties: false
required:
- value
enumCommands: []
commands: {}
25 changes: 25 additions & 0 deletions drivers/Aqara/aqara-cube/capabilities/cubeFace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
id: stse.cubeFace
version: 1
status: proposed
name: Cube Face
ephemeral: false
attributes:
cubeFace:
schema:
type: object
properties:
value:
title: CubeFace
type: string
enum:
- face1Up
- face2Up
- face3Up
- face4Up
- face5Up
- face6Up
additionalProperties: false
required:
- value
enumCommands: []
commands: {}
6 changes: 6 additions & 0 deletions drivers/Aqara/aqara-cube/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: 'Aqara Cube'
packageKey: 'aqara-cube'
permissions:
zigbee: {}
description: "SmartThings driver for Aqara Cube devices"
vendorSupportInformation: "https://www.aqara.com/en/support/"
6 changes: 6 additions & 0 deletions drivers/Aqara/aqara-cube/fingerprints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
zigbeeManufacturer:
- id: "Lumi/lumi.remote.cagl02"
deviceLabel: Aqara Cube T1 Pro
manufacturer: LUMI
model: lumi.remote.cagl02
deviceProfileName: cube-t1-pro
19 changes: 19 additions & 0 deletions drivers/Aqara/aqara-cube/profiles/cube-t1-pro.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: cube-t1-pro
components:
- id: main
capabilities:
- id: stse.cubeAction
version: 1
- id: stse.cubeFace
version: 1
- id: battery
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
categories:
- name: RemoteController
metadata:
mnmn: SolutionsEngineering
vid: SmartThings-smartthings-Aqara_CubeT1Pro
133 changes: 133 additions & 0 deletions drivers/Aqara/aqara-cube/src/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
local ZigbeeDriver = require "st.zigbee"
local capabilities = require "st.capabilities"
local data_types = require "st.zigbee.data_types"
local cluster_base = require "st.zigbee.cluster_base"
local battery_defaults = require "st.zigbee.defaults.battery_defaults"
local clusters = require "st.zigbee.zcl.clusters"
local PowerConfiguration = clusters.PowerConfiguration

local PRI_CLU = 0xFCC0
local PRI_ATTR = 0x0009
local MFG_CODE = 0x115F

local ROTATE_CLU = 0x000C
local EVENT_CLU = 0x0012
local FACE_ATTR = 0x0149
local ACTION_ATTR = 0x0055
local CUBE_MODE = 0x0148

local cubeAction = capabilities["stse.cubeAction"]
local cubeFace = capabilities["stse.cubeFace"]
local cubeFaceVal = { "face1Up", "face2Up", "face3Up", "face4Up", "face5Up", "face6Up" }
local cubeFlipToSideVal = { "flipToSide1", "flipToSide2", "flipToSide3", "flipToSide4", "flipToSide5", "flipToSide6" }

local CUBEACTION_TIMER = "cubeAction_timer"
local CUBEACTION_TIME = 3

local callback_timer = function(device)
return function()
device:emit_event(cubeAction.cubeAction("noAction"))
end
end

local function reset_thread(device)
local timer = device:get_field(CUBEACTION_TIMER)
if timer then
device.thread:cancel_timer(timer)
device:set_field(CUBEACTION_TIMER, nil)
end
device:set_field(CUBEACTION_TIMER, device.thread:call_with_delay(CUBEACTION_TIME, callback_timer(device)))
end

local function data_handler(driver, device, value, zb_rx)
local val = value.value
if val == 0x0000 then -- Shake
reset_thread(device)
device:emit_event(cubeAction.cubeAction("shake"))
elseif val == 0x0004 then -- hold
reset_thread(device)
device:emit_event(cubeAction.cubeAction("pickUpAndHold"))
elseif val & 0x0400 == 0x0400 then -- Flip to side
local faceNum = val & 0x0007
reset_thread(device)
device:emit_event(cubeAction.cubeAction(cubeFlipToSideVal[faceNum + 0x1]))
end
end

local function rotate_handler(driver, device, value, zb_rx)
-- Rotation
reset_thread(device)
device:emit_event(cubeAction.cubeAction("rotate"))
end

local function face_handler(driver, device, value, zb_rx)
local faceNum = value.value
device:emit_event(cubeFace.cubeFace(cubeFaceVal[faceNum + 1]))
end

local function do_refresh(driver, device)
-- refresh
device:send(PowerConfiguration.attributes.BatteryVoltage:read(device))
end

local function device_init(driver, device)
local power_configuration = {
cluster = PowerConfiguration.ID,
attribute = PowerConfiguration.attributes.BatteryVoltage.ID,
minimum_interval = 30,
maximum_interval = 3600,
data_type = PowerConfiguration.attributes.BatteryVoltage.base_type,
reportable_change = 1
}

battery_defaults.build_linear_voltage_init(2.6, 3.0)(driver, device)

device:add_configured_attribute(power_configuration)
device:add_monitored_attribute(power_configuration)
end

local function device_added(self, device)
-- Set private attribute
device:send(cluster_base.write_manufacturer_specific_attribute(device,
PRI_CLU, PRI_ATTR, MFG_CODE, data_types.Uint8, 1))

device:send(cluster_base.write_manufacturer_specific_attribute(device,
PRI_CLU, CUBE_MODE, MFG_CODE, data_types.Uint8, 1))
device:emit_event(cubeAction.cubeAction("noAction"))
device:emit_event(cubeFace.cubeFace("face1Up"))
do_refresh(self, device)
end

-- [[ register ]]
local aqara_cube_t1_pro_handler = {
NAME = "Aqara Cube T1 Pro",
capability_handlers = {
[capabilities.refresh.ID] = {
[capabilities.refresh.commands.refresh.NAME] = do_refresh
}
},
zigbee_handlers = {
attr = {
[EVENT_CLU] = {
[ACTION_ATTR] = data_handler
},
[ROTATE_CLU] = {
[ACTION_ATTR] = rotate_handler,
},
[PRI_CLU] = {
[FACE_ATTR] = face_handler
},
[PowerConfiguration.ID] = {
[PowerConfiguration.attributes.BatteryVoltage.ID] = battery_defaults.battery_volt_attr_handler
}
}
},
lifecycle_handlers = {
init = device_init,
added = device_added
}
}

local aqara_cube_t1_pro_driver = ZigbeeDriver("aqara_cube_t1_pro", aqara_cube_t1_pro_handler)
aqara_cube_t1_pro_driver:run()

Loading

0 comments on commit f0228b4

Please sign in to comment.