feat: Update sensor initialization to use existing hardware values and adjust pin change handling
This commit is contained in:
parent
17fb57f1d4
commit
83286c318e
1 changed files with 5 additions and 6 deletions
|
@ -84,20 +84,19 @@ export class BedHardwareMQTT extends EventEmitter implements IBedHardware {
|
|||
|
||||
this.pinStates.set(data.pin, pinState);
|
||||
this.emit('pinInitialized', pinState);
|
||||
}
|
||||
} else if (topic === this.topics.pinChange) {
|
||||
if (data.pin !== undefined && data.previousState !== undefined && data.currentState !== undefined) {
|
||||
} } else if (topic === this.topics.pinChange) {
|
||||
if (data.pin !== undefined && data.previousValue !== undefined && data.currentValue !== undefined) {
|
||||
const pinChange: PinChange = {
|
||||
pin: data.pin,
|
||||
previousState: data.previousState,
|
||||
currentState: data.currentState,
|
||||
previousState: data.previousValue,
|
||||
currentState: data.currentValue,
|
||||
timestamp: new Date(data.timestamp || Date.now())
|
||||
};
|
||||
|
||||
// Update stored pin state
|
||||
const pinState: PinState = {
|
||||
pin: data.pin,
|
||||
state: data.currentState,
|
||||
state: data.currentValue,
|
||||
name: data.name || `PIN${data.pin}`,
|
||||
timestamp: new Date(data.timestamp || Date.now())
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue