Skip to content

Commit

Permalink
Merge pull request #48 from Luligu/dev
Browse files Browse the repository at this point in the history
Release 0.9.9
  • Loading branch information
Luligu authored Sep 17, 2024
2 parents b36250c + 5a90b5f commit 7fd7c86
Show file tree
Hide file tree
Showing 7 changed files with 455 additions and 83 deletions.
17 changes: 6 additions & 11 deletions .github/workflows/build-matterbridge-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Clean cache
run: npm cache clean --force

- name: Install latest npm
run: npm install -g npm@latest

- name: Verify Node.js version
run: node -v

Expand All @@ -42,14 +48,3 @@ jobs:
- name: Build the project
run: npm run build

# - name: List, audit, fix outdated dependencies and build again
# run: |
# npm uninstall matterbridge
# npm list --outdated
# npm audit || true # ignore failures
# npm audit fix || true
# npm list --outdated
# npm install -g matterbridge
# npm install
# npm run build

6 changes: 6 additions & 0 deletions .github/workflows/publish-matterbridge-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ jobs:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Clean cache
run: npm cache clean --force

- name: Install latest npm
run: npm install -g npm@latest

- name: Verify Node.js version
run: node -v

Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ If you like this project and find it useful, please consider giving it a star on

- Unless you are using docker (in that case all is already updated when you pull the image), please update Matterbridge to 1.5.4 to work with matterbridge-shelly >= 0.9.5. This is a one time issue due to the update to matter.js 0.10.0.

## [0.9.9] - 2024-09-17

### Changed

- [matterbridge]: Removed Matterbridge deprecated method to get the child endpoints.
- [package]: Updated dependencies.

### Fixed

- [shelly]: Fixed the bug in configure when postfix is used.

<a href="https://www.buymeacoffee.com/luligugithub">
<img src="./yellow-button.png" alt="Buy me a coffee" width="120">
</a>

## [0.9.8] - 2024-09-13

### Added
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matterbridge-shelly",
"version": "0.9.8",
"version": "0.9.9",
"description": "Matterbridge shelly plugin",
"author": "https://github.com/Luligu",
"license": "Apache-2.0",
Expand Down Expand Up @@ -64,8 +64,8 @@
"test:utils": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js src/utils.spec.ts --coverage",
"test:shellyProperty": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js src/shellyProperty.test.ts --coverage",
"test:shellyComponent": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js src/shellyComponent.test.ts --coverage",
"test:mock": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js src/shellyDevice.mock.test.ts --coverage",
"test:real": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js src/shellyDevice.real.test.ts --coverage",
"test:mock": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js src/shellyDevice.mock.test.ts --runInBand --coverage",
"test:real": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js src/shellyDevice.real.test.ts --runInBand --coverage",
"test:shelly": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js src/shelly.test.ts --coverage",
"lint": "eslint --max-warnings=0 .",
"lint:fix": "eslint --fix --max-warnings=0 .",
Expand All @@ -75,7 +75,7 @@
"cleanBuild": "npm run clean && tsc",
"deepClean": "rimraf tsconfig.tsbuildinfo package-lock.json ./dist ./node_modules",
"deepCleanRebuild": "npm run deepClean && npm install && npm run build",
"prepublishOnly": "npm run lint && npm run cleanBuild && npm shrinkwrap",
"prepublishOnly": "npm run lint && npm run cleanBuild && npm shrinkwrap --omit=dev",
"checkDependencies": "npx npm-check-updates",
"updateDependencies": "npx npm-check-updates -u && npm install & npm run cleanBuild",
"preversion": "npm run build && npm run lint",
Expand Down Expand Up @@ -110,9 +110,9 @@
"devDependencies": {
"@eslint/js": "9.10.0",
"@types/eslint__js": "8.42.3",
"@types/jest": "29.5.12",
"@types/jest": "29.5.13",
"@types/multicast-dns": "7.2.4",
"@types/node": "22.5.4",
"@types/node": "22.5.5",
"@types/ws": "8.5.12",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "28.8.3",
Expand Down
27 changes: 20 additions & 7 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ export class ShellyPlatform extends MatterbridgeDynamicPlatform {
mbDevice.addCommandHandler('off', async (data) => {
this.shellyLightCommandHandler(mbDevice, data.endpoint.number, device, 'Off', false);
});
mbDevice.addCommandHandler('toggle', async (data) => {
this.shellyLightCommandHandler(mbDevice, data.endpoint.number, device, 'Toggle', false);
});

// Add event handler
switchComponent.on('update', (component: string, property: string, value: ShellyDataType) => {
Expand Down Expand Up @@ -802,12 +805,20 @@ export class ShellyPlatform extends MatterbridgeDynamicPlatform {
override async onConfigure() {
this.log.info(`Configuring platform ${idn}${this.config.name}${rs}${nf}`);
this.bridgedDevices.forEach(async (mbDevice) => {
if (!mbDevice.serialNumber) return;
this.log.info(`Configuring device ${dn}${mbDevice.deviceName}${nf} shelly ${hk}${mbDevice.serialNumber}${nf}`);
const shellyDevice = this.shelly.getDevice(mbDevice.serialNumber);
if (!shellyDevice) return;
if (!mbDevice.serialNumber) {
this.log.error(`Shelly device ${dn}${mbDevice.deviceName}${er} has no serial number`);
return;
}
const serial = isValidString(this.config.postfix, 1, 3) ? mbDevice.serialNumber.replace('-' + this.config.postfix, '') : mbDevice.serialNumber;
this.log.info(`Configuring device ${dn}${mbDevice.deviceName}${nf} shelly ${hk}${serial}${nf}`);
const shellyDevice = this.shelly.getDevice(serial);
if (!shellyDevice) {
this.log.error(`Shelly device with serial number ${hk}${serial}${er} not found`);
return;
}
mbDevice.getChildEndpoints().forEach(async (childEndpoint) => {
const label = mbDevice.getEndpointLabel(childEndpoint.number);
// const label = mbDevice.getEndpointLabel(childEndpoint.number);
const label = childEndpoint.uniqueStorageKey;
// Configure the cluster OnOff attribute onOff
if (label?.startsWith('switch') || label?.startsWith('relay') || label?.startsWith('light') || label?.startsWith('rgb')) {
const switchComponent = shellyDevice.getComponent(label) as ShellySwitchComponent;
Expand Down Expand Up @@ -1026,7 +1037,8 @@ export class ShellyPlatform extends MatterbridgeDynamicPlatform {
return false;
}
// Get the Shelly switch component
const componentName = matterbridgeDevice.getEndpointLabel(endpointNumber);
// const componentName = matterbridgeDevice.getEndpointLabel(endpointNumber);
const componentName = endpoint.uniqueStorageKey;
if (!componentName) {
shellyDevice.log.error(`shellyCommandHandler error: componentName not found for shelly device ${dn}${shellyDevice?.id}${er}`);
return false;
Expand Down Expand Up @@ -1081,7 +1093,8 @@ export class ShellyPlatform extends MatterbridgeDynamicPlatform {
return false;
}
// Get the Shelly cover component
const componentName = matterbridgeDevice.getEndpointLabel(endpointNumber);
// const componentName = matterbridgeDevice.getEndpointLabel(endpointNumber);
const componentName = endpoint.uniqueStorageKey;
if (!componentName) {
shellyDevice.log.error(`shellyCoverCommandHandler error: endpointName not found for shelly device ${dn}${shellyDevice?.id}${er}`);
return false;
Expand Down
Loading

0 comments on commit 7fd7c86

Please sign in to comment.