Fix setting state for created Plejd room devices
- when using includeRoomsAsLights setting
This commit is contained in:
parent
3804c63991
commit
55f0f60be9
3 changed files with 12 additions and 4 deletions
|
|
@ -54,7 +54,11 @@ class DeviceRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
getDevice(deviceId) {
|
getDevice(deviceId) {
|
||||||
return this.plejdDevices[deviceId];
|
return this.plejdDevices[deviceId] || this.roomDevices[deviceId];
|
||||||
|
}
|
||||||
|
|
||||||
|
getDeviceIdsByRoom(roomId) {
|
||||||
|
return this.deviceIdsByRoom[roomId];
|
||||||
}
|
}
|
||||||
|
|
||||||
getDeviceBySerialNumber(serialNumber) {
|
getDeviceBySerialNumber(serialNumber) {
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,7 @@ class MqttClient extends EventEmitter {
|
||||||
);
|
);
|
||||||
device = this.deviceRegistry.getScene(decodedTopic.id);
|
device = this.deviceRegistry.getScene(decodedTopic.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceName = device ? device.name : '';
|
const deviceName = device ? device.name : '';
|
||||||
|
|
||||||
switch (decodedTopic.command) {
|
switch (decodedTopic.command) {
|
||||||
|
|
|
||||||
|
|
@ -332,14 +332,17 @@ class PlejdApi {
|
||||||
const { roomId } = room;
|
const { roomId } = room;
|
||||||
const roomAddress = this.siteDetails.roomAddress[roomId];
|
const roomAddress = this.siteDetails.roomAddress[roomId];
|
||||||
|
|
||||||
|
const deviceIdsByRoom = this.deviceRegistry.getDeviceIdsByRoom(roomId);
|
||||||
|
|
||||||
|
const dimmable = deviceIdsByRoom
|
||||||
|
&& deviceIdsByRoom.some((deviceId) => this.deviceRegistry.getDevice(deviceId).dimmable);
|
||||||
|
|
||||||
const newDevice = {
|
const newDevice = {
|
||||||
id: roomAddress,
|
id: roomAddress,
|
||||||
name: room.title,
|
name: room.title,
|
||||||
type: 'light',
|
type: 'light',
|
||||||
typeName: 'Room',
|
typeName: 'Room',
|
||||||
dimmable: this.deviceIdsByRoom[roomId].some(
|
dimmable,
|
||||||
(deviceId) => this.plejdDevices[deviceId].dimmable,
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.deviceRegistry.addRoomDevice(newDevice);
|
this.deviceRegistry.addRoomDevice(newDevice);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue