status handling
This commit is contained in:
5
dist/RelayBox.js
vendored
5
dist/RelayBox.js
vendored
@ -16,6 +16,7 @@ class RelayBoxThing extends AItem_1.AItem {
|
||||
`${this.deviceStatusTopic}`,
|
||||
`${this.stateTopicPre}/#`
|
||||
];
|
||||
this.oldSwitchStates = '';
|
||||
}
|
||||
processMessage(topic, payload) {
|
||||
// logger.info(`RT: ${topic}, ${payload}`)
|
||||
@ -23,6 +24,9 @@ class RelayBoxThing extends AItem_1.AItem {
|
||||
logger.info(`RT: status received`);
|
||||
this.status = JSON.parse(payload);
|
||||
let statusParsed = JSON.stringify(this.status);
|
||||
this.switchStates = JSON.stringify(this.status.data.switchStates);
|
||||
if (this.switchStates != this.oldSwitchStates) {
|
||||
this.oldSwitchStates = this.switchStates;
|
||||
logger.info(`RT: status parsed: ${statusParsed}`);
|
||||
logger.info(`RT: device: ${this.status.metadata.device}`);
|
||||
logger.info(`RT: uptime: ${this.status.data.uptime}`);
|
||||
@ -41,6 +45,7 @@ class RelayBoxThing extends AItem_1.AItem {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger.info(`RT: ${topic}, ${payload}`);
|
||||
let thingRelatedPart = topic.substring(this.stateTopicPre.length + 1);
|
||||
|
@ -12,6 +12,8 @@ export class RelayBoxThing extends AItem {
|
||||
private readonly feedbackTopicPre: string
|
||||
private readonly conflictTopicPre: string
|
||||
private status : any
|
||||
private switchStates : string
|
||||
private oldSwitchStates : string
|
||||
|
||||
constructor(floor: string, room: string, item: string, deviceCommandTopic: string,
|
||||
deviceStatusTopic: string, itemNames: string[]) {
|
||||
@ -26,6 +28,7 @@ export class RelayBoxThing extends AItem {
|
||||
`${this.deviceStatusTopic}`,
|
||||
`${this.stateTopicPre}/#`
|
||||
]
|
||||
this.oldSwitchStates = ''
|
||||
}
|
||||
|
||||
processMessage(topic: string, payload: string) {
|
||||
@ -34,6 +37,9 @@ export class RelayBoxThing extends AItem {
|
||||
logger.info(`RT: status received`)
|
||||
this.status = JSON.parse(payload)
|
||||
let statusParsed = JSON.stringify(this.status)
|
||||
this.switchStates = JSON.stringify(this.status.data.switchStates)
|
||||
if (this.switchStates != this.oldSwitchStates) {
|
||||
this.oldSwitchStates = this.switchStates
|
||||
logger.info(`RT: status parsed: ${statusParsed}`)
|
||||
logger.info(`RT: device: ${this.status.metadata.device}`)
|
||||
logger.info(`RT: uptime: ${this.status.data.uptime}`)
|
||||
@ -49,6 +55,7 @@ export class RelayBoxThing extends AItem {
|
||||
mqttHandler.send(`${this.conflictTopicPre}/${i}`, 'CONFLICT')
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.info(`RT: ${topic}, ${payload}`)
|
||||
let thingRelatedPart = topic.substring(this.stateTopicPre.length+1)
|
||||
|
Reference in New Issue
Block a user