From 09db27c646195701fd539edd7c8461277a0d2466 Mon Sep 17 00:00:00 2001 From: tom Date: Thu, 27 Jun 2024 21:08:34 +0100 Subject: [PATCH] CHANGE: implemented DeviceClass --- src/app/_models/mqtt-binary.ts | 37 ++++++++++++++++++++++++++++++---- src/app/_models/mqtt-light.ts | 14 ++++++------- src/app/_models/mqtt-sensor.ts | 6 +++--- src/app/_models/mqtt-switch.ts | 12 +++++------ 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/src/app/_models/mqtt-binary.ts b/src/app/_models/mqtt-binary.ts index 35becac..f378ffe 100644 --- a/src/app/_models/mqtt-binary.ts +++ b/src/app/_models/mqtt-binary.ts @@ -1,7 +1,36 @@ -import { DEVICE_CLASS, MQTTEntity } from "./mqtt_base"; +import { DeviceClass, MQTTEntity } from './mqtt_base'; export class MqttBinary extends MQTTEntity { - dev_cla: DEVICE_CLASS = 0 - pl_on: string = "1"; - pl_off: string = "0"; + dev_cla: DeviceClass = new DeviceClass([ + 'battery', + 'battery_charging', + 'carbon_monoxide', + 'cold', + 'connectivity', + 'door', + 'garage_door', + 'gas', + 'heat', + 'light', + 'lock', + 'moisture', + 'motion', + 'moving', + 'occupancy', + 'opening', + 'plug', + 'power', + 'presence', + 'problem', + 'running', + 'safety', + 'smoke', + 'sound', + 'tamper', + 'update', + 'vibration', + 'window', + ]); + pl_on: string = '1'; + pl_off: string = '0'; } diff --git a/src/app/_models/mqtt-light.ts b/src/app/_models/mqtt-light.ts index b45dd55..0313407 100644 --- a/src/app/_models/mqtt-light.ts +++ b/src/app/_models/mqtt-light.ts @@ -1,9 +1,9 @@ -import { MQTTEntity } from "./mqtt_base"; +import { MQTTEntity } from './mqtt_base'; export class MqttLight extends MQTTEntity { - cmd_t: string = "command/topic"; - bri_cmd_t: string = "brightness/command/topic"; - pl_on: string = "1"; - pl_off: string = "0"; - val_tpl: string = ""; -} \ No newline at end of file + cmd_t: string = 'command/topic'; + bri_cmd_t: string = 'brightness/command/topic'; + pl_on: string = '1'; + pl_off: string = '0'; + val_tpl: string = ''; +} diff --git a/src/app/_models/mqtt-sensor.ts b/src/app/_models/mqtt-sensor.ts index d95aa19..369ac49 100644 --- a/src/app/_models/mqtt-sensor.ts +++ b/src/app/_models/mqtt-sensor.ts @@ -1,5 +1,5 @@ -import { MQTTEntity } from "./mqtt_base"; +import { MQTTEntity } from './mqtt_base'; export class MqttSensor extends MQTTEntity { - unit_of_meas: string = "meassure"; - } \ No newline at end of file + unit_of_meas: string = 'meassure'; +} diff --git a/src/app/_models/mqtt-switch.ts b/src/app/_models/mqtt-switch.ts index a3d9503..57c681a 100644 --- a/src/app/_models/mqtt-switch.ts +++ b/src/app/_models/mqtt-switch.ts @@ -1,8 +1,8 @@ -import { DEVICE_CLASS, MQTTEntity } from "./mqtt_base"; +import { DeviceClass, MQTTEntity } from './mqtt_base'; export class MqttSwitch extends MQTTEntity { - dev_cla: DEVICE_CLASS = 0 - cmd_t: string = "command/topic"; - pl_on: string = "1"; - pl_off: string = "0"; -} \ No newline at end of file + dev_cla: DeviceClass = new DeviceClass(['switch', 'outlet']); + cmd_t: string = 'command/topic'; + pl_on: string = '1'; + pl_off: string = '0'; +}