From 0868e613ea47ddf6ceac82a449ab926406021722 Mon Sep 17 00:00:00 2001 From: Luligu Date: Mon, 2 Dec 2024 15:32:25 +0100 Subject: [PATCH] Release 1.2.1 --- CHANGELOG.md | 22 +++++++++++++++++++ package.json | 4 ++-- src/platform.test.ts | 50 +++++++++++++++++++++++++++++++++++++++++++- src/platform.ts | 4 ++-- 4 files changed, 75 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24e5135..0cfc6e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. + + + Buy me a coffee + + ## [1.2.0] - 2024-12-02 ### Added diff --git a/package.json b/package.json index 7f4ee5e..414697f 100644 --- a/package.json +++ b/package.json @@ -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", @@ -93,4 +93,4 @@ "typescript": "5.7.2", "typescript-eslint": "8.16.0" } -} +} \ No newline at end of file diff --git a/src/platform.test.ts b/src/platform.test.ts index 6375d6d..90c4ffa 100644 --- a/src/platform.test.ts +++ b/src/platform.test.ts @@ -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'; @@ -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'); }), @@ -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 = []; @@ -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'); }); diff --git a/src/platform.ts b/src/platform.ts index 3d92141..d2c7ebc 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -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; } @@ -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(); }