From 7ba38d6acf306cb72dfca77e07ddca12e3afd376 Mon Sep 17 00:00:00 2001 From: faanskit Date: Fri, 7 May 2021 08:52:57 +0200 Subject: [PATCH 1/7] 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. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- plejd/MqttClient.js | 1 + plejd/PlejdApi.js | 5 +++++ plejd/types/DeviceRegistry.d.ts | 1 + 3 files changed, 7 insertions(+) diff --git a/plejd/MqttClient.js b/plejd/MqttClient.js index 64586bd..d10840b 100644 --- a/plejd/MqttClient.js +++ b/plejd/MqttClient.js @@ -69,6 +69,7 @@ const getOutputDeviceDiscoveryPayload = ( manufacturer: 'Plejd', model: device.typeName, name: device.name, + ...(device.roomName !== undefined ? { suggested_area: device.roomName } : {}), sw_version: device.version, }, ...(device.type === MQTT_TYPES.LIGHT ? { brightness: device.dimmable, schema: 'json' } : {}), diff --git a/plejd/PlejdApi.js b/plejd/PlejdApi.js index ab5cbf4..a338cba 100644 --- a/plejd/PlejdApi.js +++ b/plejd/PlejdApi.js @@ -436,6 +436,8 @@ class PlejdApi { loadType = 'light'; } + const room = this.siteDetails.rooms.find((x) => x.roomId === device.roomId); + /** @type {import('types/DeviceRegistry').OutputDevice} */ const outputDevice = { bleOutputAddress, @@ -446,6 +448,7 @@ class PlejdApi { name: device.title, output: deviceOutput, roomId: device.roomId, + roomName: room.title, state: undefined, type: loadType, typeName, @@ -519,6 +522,7 @@ class PlejdApi { name: room.title, output: undefined, roomId, + roomName: room.title, state: undefined, type: 'light', typeName: 'Room', @@ -548,6 +552,7 @@ class PlejdApi { name: scene.title, output: undefined, roomId: undefined, + roomName: undefined, state: false, type: 'scene', typeName: 'Scene', diff --git a/plejd/types/DeviceRegistry.d.ts b/plejd/types/DeviceRegistry.d.ts index 5ee68ae..9e4d6ba 100644 --- a/plejd/types/DeviceRegistry.d.ts +++ b/plejd/types/DeviceRegistry.d.ts @@ -13,6 +13,7 @@ export interface OutputDevice { name: string; output: number; roomId: string; + roomName: string; state: boolean | undefined; type: string; typeName: string; From dc3d2237da2fbd1a2ba427239f9496efc50faaa2 Mon Sep 17 00:00:00 2001 From: faanskit Date: Fri, 7 May 2021 10:59:52 +0200 Subject: [PATCH 2/7] Updating the Plejd / HA Device information model to be compatible with suggested_area. --- plejd/MqttClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plejd/MqttClient.js b/plejd/MqttClient.js index d10840b..47c7d92 100644 --- a/plejd/MqttClient.js +++ b/plejd/MqttClient.js @@ -65,7 +65,7 @@ const getOutputDeviceDiscoveryPayload = ( qos: 1, retain: true, device: { - identifiers: `${device.deviceId}`, + identifiers: `${device.uniqueId}`, manufacturer: 'Plejd', model: device.typeName, name: device.name, From 672c957fd31f34ef46dfdfff3a2e6c47c145130b Mon Sep 17 00:00:00 2001 From: faanskit Date: Fri, 7 May 2021 18:25:47 +0200 Subject: [PATCH 3/7] Updated CHANGELOG to reflect additions with rooms. Updated README to provide clarity how different Plejd units will be propagated into Home Assistant. Updated README to solve #189 --- plejd/CHANGELOG.md | 4 ++-- plejd/README.md | 45 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/plejd/CHANGELOG.md b/plejd/CHANGELOG.md index 43264bc..6491c1c 100644 --- a/plejd/CHANGELOG.md +++ b/plejd/CHANGELOG.md @@ -4,7 +4,7 @@ **BREAKING - READ BELOW FIRST** -Release 0.8 will break ALL EXISTING DEVICES. Unique mqtt id:s will change, meaning HA will create new devices. Scenes will be added as scenes not as switches. +Release 0.8 will break ALL EXISTING DEVICES. Unique mqtt id:s will change, meaning HA will create new devices. Scenes will be added as scenes not as switches. Devices will be installed to Areas named by the rooms defined in the Plejd app (can be changed) Recommendations to minimize impact @@ -13,7 +13,7 @@ Recommendations to minimize impact - Reboot HA - Go to Configuration => Integration => MQTT. Go to entities and after that devices and remove all Plejd devices (should be listed as unavailable) - Upgrade addon to latest version and start -- All devices should now be back. With luck they will have the same HA id:s as before so most things should work. Room assignments, icons, etc will be gone though. +- All devices should now be back. With luck they will have the same HA id:s as before so most things should work. Room assignments, icons, automations, scenes, etc will have to be gone though. ## [0.7.1](https://github.com/icanos/hassio-plejd/tree/0.7.1) (2021-03-25) diff --git a/plejd/README.md b/plejd/README.md index e126733..a95baea 100644 --- a/plejd/README.md +++ b/plejd/README.md @@ -1,9 +1,32 @@ # Hass.io Plejd add-on Hass.io add-on for Plejd home automation devices. Gives you the ability to control the Plejd home automation devices through Home Assistant. -It uses MQTT to communicate with Home Assistant and supports auto discovery of the devices in range. +It uses MQTT to communicate with Home Assistant and supports auto discovery of the devices in range. Changed made in the Plejd app are propagated to Home Assistant. -It also supports notifications so that changed made in the Plejd app are propagated to Home Assistant. +Plejd output devices typically appears as either lights or switches in Home Assistant depending on how they are configured. + + + + + + + + + + + + + + + + + + + + + + +
DevicePlejd ConfigurationHome Assistant RoleComment
CTR-01Relay, LightLight
CTR-01Relay, OtherSwitch
REL-01Relay, LightLight
REL-01Relay, OtherSwitch
REL-02Relay, LightLight
REL-02Relay, OtherSwitch
SPR-01Relay, LightLightNot tested, not released by Plejd
SPR-01Relay, OtherSwitchNot tested, not released by Plejd
DIM-01-Light
DIM-02-Light
LED-10-Light
DAL-01--Not supported, not released by Plejd
WPH-01-Device Automationtype:button_short_press, subtype:button_1, button_2,button_3,button_4
WRT-01-Device Automationtype:button_short_press, subtype:button_1
GWY-01--
RTR-01--
Scene-Scene
Scene-Device Automationtype:scene, subtype:trigger
Room-AreaCan be changed by Home Assistant
Room-LightIf includeRoomsAsLights is set to true
Thanks to [ha-plejd](https://github.com/klali/ha-plejd) for inspiration. @@ -41,8 +64,8 @@ The add-on has been tested on the following platforms: - CTR-01 - REL-01 - REL-02 -- WPH-01 (Note: Available as Device Trigger short_button_press, button_1 .. button_4) -- WRT-01 (Note: Available as Device Trigger short_button_press, button_1. Rotation/dimming not offered by the device) +- WPH-01 +- WRT-01 ### Easy Installation @@ -52,6 +75,7 @@ Browse to your Home Assistant installation in a web browser and click on `Hass.i - Click on `Add-on Store` in the top navigation bar of that page. - Paste the URL to this repo https://github.com/icanos/hassio-plejd.git in the `Add new repository by URL` field and hit `Add`. - Scroll down and you should find a Plejd add-on that can be installed. Open that and install. +- Configure hassio-plejd (see below) - Enjoy! ### Manual Installation @@ -108,7 +132,16 @@ If you restore a backup from a 32bit system to a new 64bit system, use the Rebui ### Configuration -You need to add the MQTT integration to Home Assistant either by going to Configuration -> Integrations and clicking the Add Integration button, or by adding the following to your `configuration.yaml` file: +#### Simple MQTT Configurations +When you are using the official Mosquitto Broker from Home Assistant Add-on store, minimal configuration is required. +
+ + + +
mqttBrokermqtt://localhost
mqttUsernamehomeassistant
mqttPasswordMosquitto password, fetched via Configuration->Integrations->Mosquitto broker->Configure->RE-CONFIGURE->Password
+ +#### Advanced MQTT Configurations +For more advanced instllations, you need to add the MQTT integration to Home Assistant either by going to Configuration -> Integrations and clicking the Add Integration button, or by adding the following to your `configuration.yaml` file: ``` mqtt: @@ -121,6 +154,8 @@ mqtt: The above is used to notify the add-on when Home Assistant has started successfully and let the add-on send the discovery response (containing information about all Plejd devices found). +#### Configuration Parameters + The plugin needs you to configure some settings before working. You find these on the Add-on page after you've installed it. | Parameter | Value | From d239aacbc15c67219b3aba163eb02245c3babeb3 Mon Sep 17 00:00:00 2001 From: faanskit Date: Fri, 7 May 2021 18:37:07 +0200 Subject: [PATCH 4/7] Fixed error only showing in github for the readme --- plejd/README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/plejd/README.md b/plejd/README.md index a95baea..0763eb8 100644 --- a/plejd/README.md +++ b/plejd/README.md @@ -6,23 +6,23 @@ It uses MQTT to communicate with Home Assistant and supports auto discovery of t Plejd output devices typically appears as either lights or switches in Home Assistant depending on how they are configured. - - - - - - + + + + + + - - - + + + - - - + + + From 729559750e14b6f82a8edb3e5e0f6c6ccc237cf9 Mon Sep 17 00:00:00 2001 From: faanskit Date: Tue, 11 May 2021 21:03:48 +0200 Subject: [PATCH 5/7] Updated based on review feedback from @SweVictor. Thanks! --- plejd/PlejdApi.js | 3 +- plejd/README.md | 59 +++++++++++++++++---------------- plejd/types/DeviceRegistry.d.ts | 4 +-- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/plejd/PlejdApi.js b/plejd/PlejdApi.js index a338cba..9208b95 100644 --- a/plejd/PlejdApi.js +++ b/plejd/PlejdApi.js @@ -437,6 +437,7 @@ class PlejdApi { } const room = this.siteDetails.rooms.find((x) => x.roomId === device.roomId); + const roomTitle = room ? room.title : undefined; /** @type {import('types/DeviceRegistry').OutputDevice} */ const outputDevice = { @@ -448,7 +449,7 @@ class PlejdApi { name: device.title, output: deviceOutput, roomId: device.roomId, - roomName: room.title, + roomName: roomTitle, state: undefined, type: loadType, typeName, diff --git a/plejd/README.md b/plejd/README.md index 0763eb8..1a7197e 100644 --- a/plejd/README.md +++ b/plejd/README.md @@ -4,29 +4,29 @@ Hass.io add-on for Plejd home automation devices. Gives you the ability to contr It uses MQTT to communicate with Home Assistant and supports auto discovery of the devices in range. Changed made in the Plejd app are propagated to Home Assistant. Plejd output devices typically appears as either lights or switches in Home Assistant depending on how they are configured. -
DevicePlejd ConfigurationHome Assistant RoleComment
CTR-01Relay, LightLight
CTR-01Relay, OtherSwitch
REL-01Relay, LightLight
REL-01Relay, OtherSwitch
REL-02Relay, LightLight
REL-02Relay, OtherSwitch
CTR-01Relay, LightLight
CTR-01Relay, OtherSwitch
REL-01Relay, LightLight
REL-01Relay, OtherSwitch
REL-02Relay, LightLight
REL-02Relay, OtherSwitch
SPR-01Relay, LightLightNot tested, not released by Plejd
SPR-01Relay, OtherSwitchNot tested, not released by Plejd
DIM-01-Light
DIM-02-Light
LED-10-Light
DIM-01-Light
DIM-02-Light
LED-10-Light
DAL-01--Not supported, not released by Plejd
WPH-01-Device Automationtype:button_short_press, subtype:button_1, button_2,button_3,button_4
WRT-01-Device Automationtype:button_short_press, subtype:button_1
GWY-01--
RTR-01--
Scene-Scene
GWY-01--
RTR-01--
Scene-Scene
Scene-Device Automationtype:scene, subtype:trigger
Room-AreaCan be changed by Home Assistant
Room-LightIf includeRoomsAsLights is set to true
- - - - - - - - - - - - - - - - - - - - - -
DevicePlejd ConfigurationHome Assistant RoleComment
CTR-01Relay, LightLight
CTR-01Relay, OtherSwitch
REL-01Relay, LightLight
REL-01Relay, OtherSwitch
REL-02Relay, LightLight
REL-02Relay, OtherSwitch
SPR-01Relay, LightLightNot tested, not released by Plejd
SPR-01Relay, OtherSwitchNot tested, not released by Plejd
DIM-01-Light
DIM-02-Light
LED-10-Light
DAL-01--Not supported, not released by Plejd
WPH-01-Device Automationtype:button_short_press, subtype:button_1, button_2,button_3,button_4
WRT-01-Device Automationtype:button_short_press, subtype:button_1
GWY-01--
RTR-01--
Scene-Scene
Scene-Device Automationtype:scene, subtype:trigger
Room-AreaCan be changed by Home Assistant
Room-LightIf includeRoomsAsLights is set to true
+ +| Device | Plejd Configuration | Home Assistant Role | Comment | +| ------ | ------------------- | ------------------- | --------------------------------------------------------------------- | +| CTR-01 | Relay, Light | Light | | +| CTR-01 | Relay, Other | Switch | | +| REL-01 | Relay, Light | Light | | +| REL-01 | Relay, Other | Switch | | +| REL-02 | Relay, Light | Light | | +| REL-02 | Relay, Other | Switch | | +| SPR-01 | Relay, Light | Light | Not tested, not supported | +| SPR-01 | Relay, Other | Switch | Not tested, not supported | +| DIM-01 | - | Light | | +| DIM-02 | - | Light | | +| LED-10 | - | Light | | +| DAL-01 | - | - | Not supported, not released by Plejd | +| WPH-01 | - | Device Automation | type:button_short_press, subtype:button_1, button_2,button_3,button_4 | +| WRT-01 | - | Device Automation | type:button_short_press, subtype:button_1 | +| GWY-01 | - | - | | +| RTR-01 | - | - | | +| Scene | - | Scene | | +| Scene | - | Device Automation | type:scene, subtype:trigger | +| Room | - | Area | Can be changed by Home Assistant | +| Room | - | Light | If includeRoomsAsLights is set to true | Thanks to [ha-plejd](https://github.com/klali/ha-plejd) for inspiration. @@ -133,14 +133,17 @@ If you restore a backup from a 32bit system to a new 64bit system, use the Rebui ### Configuration #### Simple MQTT Configurations + When you are using the official Mosquitto Broker from Home Assistant Add-on store, minimal configuration is required. -
- - - -
mqttBrokermqtt://localhost
mqttUsernamehomeassistant
mqttPasswordMosquitto password, fetched via Configuration->Integrations->Mosquitto broker->Configure->RE-CONFIGURE->Password
+ +| Parameter | Value | +| ------------ | ---------------------------------------------------------------------------------------------------------------- | +| mqttBroker | mqtt://localhost | +| mqttUsername | homeassistant | +| mqttPassword | Mosquitto password, fetched via Configuration->Integrations->Mosquitto broker->Configure->RE-CONFIGURE->Password | #### Advanced MQTT Configurations + For more advanced instllations, you need to add the MQTT integration to Home Assistant either by going to Configuration -> Integrations and clicking the Add Integration button, or by adding the following to your `configuration.yaml` file: ``` diff --git a/plejd/types/DeviceRegistry.d.ts b/plejd/types/DeviceRegistry.d.ts index 9e4d6ba..2d705cc 100644 --- a/plejd/types/DeviceRegistry.d.ts +++ b/plejd/types/DeviceRegistry.d.ts @@ -12,8 +12,8 @@ export interface OutputDevice { hiddenFromSceneList?: boolean; name: string; output: number; - roomId: string; - roomName: string; + roomId: string | undefined; + roomName: string | undefined; state: boolean | undefined; type: string; typeName: string; From de30a6aa3d7dd0c33c635337840fb469466f3167 Mon Sep 17 00:00:00 2001 From: faanskit Date: Wed, 12 May 2021 10:45:27 +0200 Subject: [PATCH 6/7] changed back behaviour of rooms as devices. Will not appear in suggested rooms --- plejd/PlejdApi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plejd/PlejdApi.js b/plejd/PlejdApi.js index 9208b95..45e9fb5 100644 --- a/plejd/PlejdApi.js +++ b/plejd/PlejdApi.js @@ -523,7 +523,7 @@ class PlejdApi { name: room.title, output: undefined, roomId, - roomName: room.title, + roomName: undefined, state: undefined, type: 'light', typeName: 'Room', From 78b815d3f04eef5a1e161af9c4641a98bf2ffd3a Mon Sep 17 00:00:00 2001 From: faanskit Date: Wed, 12 May 2021 11:31:43 +0200 Subject: [PATCH 7/7] Updated legacy based on feedback from @SweVictor --- plejd/PlejdApi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plejd/PlejdApi.js b/plejd/PlejdApi.js index 45e9fb5..3f4a00f 100644 --- a/plejd/PlejdApi.js +++ b/plejd/PlejdApi.js @@ -522,7 +522,7 @@ class PlejdApi { hiddenFromIntegrations: false, name: room.title, output: undefined, - roomId, + roomId: undefined, roomName: undefined, state: undefined, type: 'light',