CHANGE: automatic topic generation in class
This commit is contained in:
@@ -1,9 +1,48 @@
|
||||
import { MQTTEntity } from './mqtt_base';
|
||||
import { iMQTTEntityBase, 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 = '';
|
||||
bri_cmd_t: string = 'brightness/command/topic';
|
||||
_cmd_t: string = 'command/topic';
|
||||
|
||||
override readonly ent_type: string = 'light';
|
||||
override attrs: Set<string> = new Set([
|
||||
'name',
|
||||
'uniq_id',
|
||||
'stat_t',
|
||||
'pl_on',
|
||||
'pl_off',
|
||||
'val_tpl',
|
||||
'bri_cmd_t',
|
||||
'cmd_t',
|
||||
]);
|
||||
|
||||
get cmd_t() {
|
||||
return this._cmd_t;
|
||||
}
|
||||
set cmd_t(data: string) {
|
||||
this._cmd_t = data;
|
||||
}
|
||||
|
||||
override set name(data: string) {
|
||||
super.name = data;
|
||||
this.topic_updates.next('cmd_t');
|
||||
this.topic_updates.next('bri_cmd_t');
|
||||
}
|
||||
|
||||
override get name() {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
override set uniq_id(data: string) {
|
||||
super.uniq_id = data;
|
||||
this.topic_updates.next('cmd_t');
|
||||
this.topic_updates.next('bri_cmd_t');
|
||||
}
|
||||
|
||||
override get uniq_id() {
|
||||
return this._uniq_id;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user