diff --git a/README.md b/README.md index cd58155..987554a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ [![verified-by-homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins) ![Build and Lint](https://github.com/QuickSander/homebridge-mieleathome/workflows/Build%20and%20Lint/badge.svg) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) -[![npm version](https://badge.fury.io/js/homebridge-mieleathome.svg)](https://badge.fury.io/js/homebridge-mieleathome) +[![npm (beta))](https://img.shields.io/npm/v/homebridge-mieleathome/beta.svg)](https://www.npmjs.com/package/homebridge-mieleathome) +[![npm (latest)](https://img.shields.io/npm/v/homebridge-mieleathome/latest)](https://www.npmjs.com/package/homebridge-mieleathome) ![Miele + Homebridge](./homebridge-ui/public/miele-homebridge.png "Miele + Homebridge") @@ -19,7 +20,7 @@ It (currently) requires a - Miele Washing machine (e.g. WCG370, WMV960). - Miele Dryer (e.g. TMV840WP) - Miele Dishwasher. -- Experimental Miele Fridge and Fridge Freezer combination support. +- Miele Fridge and Fridge Freezer combination. ## Features - Easy setup: guided process to retrieve token via OAuth2 from Miele. @@ -28,8 +29,11 @@ It (currently) requires a - Start / stop (dish) washing machine program (with an option to disable to prevent unintentional program stop requests). - Remaining run time. - Washing machine / dish washer program target temperature. +- Fridge / Freezer target and current temperature +- Set Fridge / Freezer target temperature. - HomeKit identify support via Homebridge log. + ## Breaking changes ### Versions > 2.8.0 - The introduction of event based updating removed the need for the _Poll interval_ setting. This option can be removed from diff --git a/package.json b/package.json index e74e704..7213310 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,8 @@ "release": { "branches": [ "master", - "next" + "next", + "beta" ] } } diff --git a/src/mieleBasePlatformAccessory.ts b/src/mieleBasePlatformAccessory.ts index a82832e..072cea8 100644 --- a/src/mieleBasePlatformAccessory.ts +++ b/src/mieleBasePlatformAccessory.ts @@ -61,14 +61,13 @@ export abstract class MieleBasePlatformAccessory { let reconnectTimeout = this.platform.reconnectEventServerInterval; if(this.platform.reconnectEventServerInterval <=0) { - this.platform.log.warn('Incorrect \'reconnectEventServerInterval\' specified in yur configuration. '+ - `Value: ${reconnectTimeout}. Should be >0. Using default value ${DEFAULT_RECONNECT_EVENT_SERVER_INTERVAL_MIN}[min] instead.`); + this.platform.log.warn('Incorrect \'reconnectEventServerInterval\' specified in your configuration. '+ + `Value: ${reconnectTimeout} should be >0. Using default value ${DEFAULT_RECONNECT_EVENT_SERVER_INTERVAL_MIN}[min] instead.`); reconnectTimeout = DEFAULT_RECONNECT_EVENT_SERVER_INTERVAL_MIN; } - const reconnectTimeoutMs=reconnectTimeout*60*1000; + const reconnectTimeoutMs= (reconnectTimeout*60*1000); setInterval(this.connectToEventServer.bind(this), reconnectTimeoutMs); - } //----------------------------------------------------------------------------------------------- @@ -96,14 +95,35 @@ export abstract class MieleBasePlatformAccessory { 'Connection with Miele event server succesfully (re-)established.'); }; + this.eventSource.addEventListener('ping', (_event) => { + //this.platform.log.debug(`${this.accessory.context.device.displayName}: Event '${event.type}' received.`); + }); + this.eventSource.onerror = (error) => { this.eventSource?.close(); - this.platform.log.error(`${this.accessory.context.device.displayName}: Error received from Miele event server: `+ - `'${JSON.stringify(error)}'`); - this.mainService.setCharacteristic(this.platform.Characteristic.StatusFault, this.platform.Characteristic.StatusFault.GENERAL_FAULT); - this.platform.log.info(`${this.accessory.context.device.displayName}: Will attempt to reconnect to the Miele event server after`+ - ` ${EVENT_SERVER_RECONNECT_DELAY_S}[s].`); + interface IError{ + message: string; + status: number; + type: string; + } + + const errorObj = (error); + + // If Miele closed the connection on their end, EventSource raises an empty error object. + if(!errorObj.status) { + this.platform.log.debug(`${this.accessory.context.device.displayName}: Miele event server `+ + `connection lost. Auto-reconnect after ${EVENT_SERVER_RECONNECT_DELAY_S}[s]`); + } else { + this.platform.log.error(`${this.accessory.context.device.displayName}: Error received from Miele event server. `+ + `Status: ${errorObj.status}. Message: '${errorObj.message}'`); + this.mainService.setCharacteristic(this.platform.Characteristic.StatusFault, + this.platform.Characteristic.StatusFault.GENERAL_FAULT); + + this.platform.log.info(`${this.accessory.context.device.displayName}: Will attempt to reconnect to the Miele event server after`+ + ` ${EVENT_SERVER_RECONNECT_DELAY_S}[s].`); + } + setTimeout(()=> { this.connectToEventServer(); }, EVENT_SERVER_RECONNECT_DELAY_S*1000); @@ -113,7 +133,8 @@ export abstract class MieleBasePlatformAccessory { //----------------------------------------------------------------------------------------------- protected identify(_value: CharacteristicValue, _callback: CharacteristicSetCallback) { - this.platform.log.info(`Identify requested for: ${this.accessory.context.device.modelNumber} `+ + this.platform.log.info(`Identify requested for: ${this.accessory.context.device.displayName} `+ + `(${this.accessory.context.device.modelNumber}) `+ `with serial number: ${this.accessory.context.device.uniqueId}`); }