From b7588ee9869117d04111e81d368631f531973e39 Mon Sep 17 00:00:00 2001 From: Johann Richard <189003+johannrichard@users.noreply.github.com> Date: Mon, 24 Oct 2022 18:23:47 +0200 Subject: [PATCH] fix(dingz): :bug: further fixes for new callback-url scheme - fixes new callback url scheme for FW v1.4.x fixes #511 --- src/dingzAccessory.ts | 8 +++++++- src/lib/commonTypes.ts | 4 +++- src/myStromPIRAccessory.ts | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/dingzAccessory.ts b/src/dingzAccessory.ts index 90a1941..24aeebd 100644 --- a/src/dingzAccessory.ts +++ b/src/dingzAccessory.ts @@ -243,7 +243,13 @@ export class DingzAccessory extends DingzDaBaseAccessory { token: this.device.token, endpoints: endpoints, }); - } else if (!callBackUrl?.url.includes(this.platform.getCallbackUrl())) { + } else if ( + // FIXME: because of #511 + (semver.lt(this.hw.fw_version, '1.4.0') && + !callBackUrl?.url?.includes(this.platform.getCallbackUrl())) || + (semver.gte(this.hw.fw_version, '1.4.0') && + !callBackUrl?.generic?.includes(this.platform.getCallbackUrl())) + ) { this.log.warn('Update existing callback URL ->', callBackUrl); this.platform.setButtonCallbackUrl({ diff --git a/src/lib/commonTypes.ts b/src/lib/commonTypes.ts index 8512858..4df3198 100644 --- a/src/lib/commonTypes.ts +++ b/src/lib/commonTypes.ts @@ -65,6 +65,8 @@ export interface AccessoryTypes { [key: string]: AccessoryType; } +// FIXME: Needed because of #511 export interface AccessoryActionUrl { - url: string; + url?: string; + generic?: string; } diff --git a/src/myStromPIRAccessory.ts b/src/myStromPIRAccessory.ts index 4948165..6e8cb08 100644 --- a/src/myStromPIRAccessory.ts +++ b/src/myStromPIRAccessory.ts @@ -155,7 +155,10 @@ export class MyStromPIRAccessory extends DingzDaBaseAccessory { token: this.device.token, endpoints: ['pir/generic'], }); - } else if (!callBackUrl?.url.includes(this.platform.getCallbackUrl())) { + } else if ( + // FIXME: Needed because of #511 + !callBackUrl?.url?.includes(this.platform.getCallbackUrl()) + ) { this.log.warn('Update existing callback URL ->', callBackUrl); // Set the callback URL (Override!) this.platform.setButtonCallbackUrl({