diff --git a/src/tasmotaCharacteristic.ts b/src/tasmotaCharacteristic.ts index 16cbdd8..1461bcd 100644 --- a/src/tasmotaCharacteristic.ts +++ b/src/tasmotaCharacteristic.ts @@ -17,16 +17,10 @@ export type Mapping = { to: CharacteristicValue }[]; -export enum ValueUpdate { - OnChange, - Always, - Never, -} - export type TasmotaResponse = { topic?: string; path?: string; - update?: ValueUpdate + update?: boolean; shared?: boolean; } @@ -95,7 +89,7 @@ export class TasmotaCharacteristic { this.characteristic.onSet(this.onSet.bind(this)); } // stat path defaults to get.res.path if not set - if (definition.stat?.update !== ValueUpdate.Never) { + if (definition.stat?.update !== false) { const topic = this.replaceTemplate(definition.stat?.topic || '{stat}/RESULT'); const path = definition.stat?.path || definition.get?.res?.path || definition.get?.cmd; if (path !== undefined) { @@ -191,8 +185,8 @@ export class TasmotaCharacteristic { const hbValue = this.checkHBValue(this.mapToHB(value)); if (hbValue !== undefined) { const prevValue = this.value; - const getUpdateAlways = this.definition.get?.res?.update === ValueUpdate.Always; - const updateAlways = this.definition.stat?.update === ValueUpdate.Always; + const getUpdateAlways = this.definition.get?.res?.update === true; + const updateAlways = this.definition.stat?.update === true; const update = (hbValue !== prevValue) || updateAlways || getUpdateAlways; if (update) { this.service.getCharacteristic(this.platform.Characteristic[this.name]).updateValue(hbValue); diff --git a/src/tasmotaDeviceTypes.ts b/src/tasmotaDeviceTypes.ts index 1da3110..317179e 100644 --- a/src/tasmotaDeviceTypes.ts +++ b/src/tasmotaDeviceTypes.ts @@ -1,27 +1,26 @@ import { TasmotaDeviceDefinition } from './tasmotaAccessory'; -import { ValueUpdate } from './tasmotaCharacteristic'; export const ACCESSORY_INFORMATION: TasmotaDeviceDefinition = { AccessoryInformation: { Manufacturer: { get: {cmd: 'MODULE0', res: {path: 'Module.0'}}, - stat: {update: ValueUpdate.Never}, + stat: {update: false}, default: 'Tasmota', }, Model: { get: {cmd: 'DeviceName'}, - stat: {update: ValueUpdate.Never}, + stat: {update: false}, default: 'Unknown', }, SerialNumber: { get: {cmd: 'STATUS 5', res: {topic: '{stat}/STATUS5', path: 'StatusNET.Mac'}}, - stat: {update: ValueUpdate.Never}, + stat: {update: false}, default: 'Unknown', }, FirmwareRevision: { get: {cmd: 'STATUS 2', res: {topic: '{stat}/STATUS2', path: 'StatusFWR.Version'}}, - stat: {update: ValueUpdate.Never}, + stat: {update: false}, default: 'Unknown', }, }, @@ -39,7 +38,7 @@ export const DEVICE_TYPES: { [key: string] : TasmotaDeviceDefinition } = { BUTTON: { StatelessProgrammableSwitch: { ProgrammableSwitchEvent: { - stat: {path: 'Button{idx}.Action', update: ValueUpdate.Always}, + stat: {path: 'Button{idx}.Action', update: true}, mapping: [{from: 'SINGLE', to: 0}, {from: 'DOUBLE', to: 1}, {from: 'HOLD', to: 3}], }, },