Skip to content

Commit

Permalink
Merge pull request #14 from Luligu/dev
Browse files Browse the repository at this point in the history
Release 1.2.1
  • Loading branch information
Luligu authored Dec 2, 2024
2 parents 64dabda + caed531 commit 709215d
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 7 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ If you like this project and find it useful, please consider giving it a star on

All notable changes to this project will be documented in this file.

## [1.2.1] - 2024-12-02

### Added

- [edge]: Verified to work with Matterbridge edge (matter.js new API).
- [plugin]: Refactor movement to support concurrent movements from all screens.
- [plugin]: Refactor movement to show the movement on the controller (if it supports that) even for close and open commands.
- [matter]: Added bridgedNode and powerSource device types to the cover.

### Changed

- [package]: Requires matterbridge 1.6.5.
- [package]: Updated dependencies.

### Fixed

- [somfy]: Fixed stop sent when the target is fully open or fully closed.

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

## [1.2.0] - 2024-12-02

### Added
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matterbridge-somfy-tahoma",
"version": "1.2.0",
"version": "1.2.1",
"description": "Matterbridge somfy tahoma plugin",
"author": "https://github.com/Luligu",
"license": "Apache-2.0",
Expand Down Expand Up @@ -93,4 +93,4 @@
"typescript": "5.7.2",
"typescript-eslint": "8.16.0"
}
}
}
50 changes: 49 additions & 1 deletion src/platform.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Matterbridge, MatterbridgeDevice, MatterbridgeEndpoint, PlatformConfig } from 'matterbridge';
import { coverDevice, Matterbridge, MatterbridgeDevice, MatterbridgeEndpoint, PlatformConfig } from 'matterbridge';
import { AnsiLogger, dn, LogLevel, wr } from 'matterbridge/logger';
import { SomfyTahomaPlatform } from './platform';

Expand Down Expand Up @@ -38,6 +38,7 @@ describe('TestPlatform', () => {
matterbridgePluginDirectory: 'temp',
systemInformation: { ipv4Address: undefined },
matterbridgeVersion: '1.6.5',
edge: false,
addBridgedDevice: jest.fn(async (pluginName: string, device: MatterbridgeDevice) => {
// console.error('addBridgedDevice called');
}),
Expand Down Expand Up @@ -114,6 +115,22 @@ describe('TestPlatform', () => {
expect(mockLog.info).toHaveBeenCalledWith('Starting client Tahoma service somfy_europe with user None password: None');
});

it('should receive tahomaClient events', () => {
(somfyPlatform as any).tahomaClient?.emit('connect');
(somfyPlatform as any).tahomaClient?.emit('disconnect');
expect(mockLog.info).toHaveBeenCalledWith('TaHoma service connected');
expect(mockLog.warn).toHaveBeenCalledWith('TaHoma service disconnected');
});

it('should create a mutableDevice', async () => {
expect(await somfyPlatform.createMutableDevice(coverDevice)).toBeDefined();
expect(await somfyPlatform.createMutableDevice(coverDevice)).toBeInstanceOf(MatterbridgeDevice);
mockMatterbridge.edge = true;
expect(await somfyPlatform.createMutableDevice(coverDevice)).toBeDefined();
expect(await somfyPlatform.createMutableDevice(coverDevice)).toBeInstanceOf(MatterbridgeEndpoint);
mockMatterbridge.edge = false;
});

it('should return false and log a warning if entity is not in the whitelist', () => {
(somfyPlatform as any).whiteList = ['entity1', 'entity2'];
(somfyPlatform as any).blackList = [];
Expand Down Expand Up @@ -216,7 +233,38 @@ describe('TestPlatform', () => {
expect(mockLog.info).toHaveBeenCalledWith('onConfigure called');
});

it('should call onConfigure and log error', async () => {
const client = (somfyPlatform as any).tahomaClient;
(somfyPlatform as any).tahomaClient = undefined;
await somfyPlatform.onConfigure();
expect(mockLog.info).toHaveBeenCalledWith('onConfigure called');
expect(mockLog.error).toHaveBeenCalledWith('TaHoma service not created');
(somfyPlatform as any).tahomaClient = client;
});

it('should call onShutdown with reason', async () => {
const client = (somfyPlatform as any).tahomaClient;
(somfyPlatform as any).tahomaClient = undefined;
await somfyPlatform.onShutdown('Test reason');
expect(mockLog.info).toHaveBeenCalledWith('onShutdown called with reason:', 'Test reason');
expect((somfyPlatform as any).tahomaClient).toBeUndefined();
(somfyPlatform as any).tahomaClient = client;
});

it('should call onShutdown with reason and call unregisterAll', async () => {
const client = (somfyPlatform as any).tahomaClient;
(somfyPlatform as any).tahomaClient = undefined;
somfyPlatform.name = mockConfig.name as string;
mockConfig.unregisterOnShutdown = true;
await somfyPlatform.onShutdown('Test reason');
expect(mockLog.info).toHaveBeenCalledWith('onShutdown called with reason:', 'Test reason');
expect(mockMatterbridge.removeAllBridgedDevices).toHaveBeenCalledWith(mockConfig.name);
expect((somfyPlatform as any).tahomaClient).toBeUndefined();
(somfyPlatform as any).tahomaClient = client;
mockConfig.unregisterOnShutdown = false;
});

it('should call onShutdown with reason and log error', async () => {
await somfyPlatform.onShutdown('Test reason');
expect(mockLog.info).toHaveBeenCalledWith('onShutdown called with reason:', 'Test reason');
});
Expand Down
4 changes: 2 additions & 2 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class SomfyTahomaPlatform extends MatterbridgeDynamicPlatform {
override async onConfigure() {
this.log.info('onConfigure called');
if (!this.tahomaClient) {
this.log.error('TaHoma service not connected');
this.log.error('TaHoma service not created');
return;
}

Expand All @@ -148,7 +148,7 @@ export class SomfyTahomaPlatform extends MatterbridgeDynamicPlatform {
override async onShutdown(reason?: string) {
this.log.info('onShutdown called with reason:', reason ?? 'none');
if (!this.tahomaClient) {
this.log.error('TaHoma service not connected');
this.log.error('TaHoma service not created');
} else {
this.tahomaClient.removeAllListeners();
}
Expand Down

0 comments on commit 709215d

Please sign in to comment.