Lights and switches, including roomsAsLighs, is now proposing an area for Home Assistant based on the room name from Plejd.

This by using suggested_area in MQTT config.

In many installations, Plejd units have the same name and are separated by the room they belong to.
Eg. Badrum -> Spottar, Kök->Spottar, Sovrum->Taklampa, Kök->Taklampa

With 8.0.0 devices can have the same name, and therefore it makes sense to now also support areas.
This commit is contained in:
faanskit 2021-05-07 08:52:57 +02:00
parent 49024f5392
commit 7ba38d6acf
3 changed files with 7 additions and 0 deletions

View file

@ -69,6 +69,7 @@ const getOutputDeviceDiscoveryPayload = (
manufacturer: 'Plejd', manufacturer: 'Plejd',
model: device.typeName, model: device.typeName,
name: device.name, name: device.name,
...(device.roomName !== undefined ? { suggested_area: device.roomName } : {}),
sw_version: device.version, sw_version: device.version,
}, },
...(device.type === MQTT_TYPES.LIGHT ? { brightness: device.dimmable, schema: 'json' } : {}), ...(device.type === MQTT_TYPES.LIGHT ? { brightness: device.dimmable, schema: 'json' } : {}),

View file

@ -436,6 +436,8 @@ class PlejdApi {
loadType = 'light'; loadType = 'light';
} }
const room = this.siteDetails.rooms.find((x) => x.roomId === device.roomId);
/** @type {import('types/DeviceRegistry').OutputDevice} */ /** @type {import('types/DeviceRegistry').OutputDevice} */
const outputDevice = { const outputDevice = {
bleOutputAddress, bleOutputAddress,
@ -446,6 +448,7 @@ class PlejdApi {
name: device.title, name: device.title,
output: deviceOutput, output: deviceOutput,
roomId: device.roomId, roomId: device.roomId,
roomName: room.title,
state: undefined, state: undefined,
type: loadType, type: loadType,
typeName, typeName,
@ -519,6 +522,7 @@ class PlejdApi {
name: room.title, name: room.title,
output: undefined, output: undefined,
roomId, roomId,
roomName: room.title,
state: undefined, state: undefined,
type: 'light', type: 'light',
typeName: 'Room', typeName: 'Room',
@ -548,6 +552,7 @@ class PlejdApi {
name: scene.title, name: scene.title,
output: undefined, output: undefined,
roomId: undefined, roomId: undefined,
roomName: undefined,
state: false, state: false,
type: 'scene', type: 'scene',
typeName: 'Scene', typeName: 'Scene',

View file

@ -13,6 +13,7 @@ export interface OutputDevice {
name: string; name: string;
output: number; output: number;
roomId: string; roomId: string;
roomName: string;
state: boolean | undefined; state: boolean | undefined;
type: string; type: string;
typeName: string; typeName: string;