Merge pull request #192 from faanskit/feature/room-as-area

Split HA devices per Plejd output and suggest areas when adding devices to Home Assistant

- Resolves #189
- Resolves #193
This commit is contained in:
Victor 2021-05-12 14:05:34 +02:00 committed by GitHub
commit e97aed904c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 10 deletions

View file

@ -4,7 +4,7 @@
**BREAKING - READ BELOW FIRST** **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 Recommendations to minimize impact
@ -13,7 +13,7 @@ Recommendations to minimize impact
- Reboot HA - Reboot HA
- Go to Configuration => Integration => MQTT. Go to entities and after that devices and remove all Plejd devices (should be listed as unavailable) - 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 - 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) ## [0.7.1](https://github.com/icanos/hassio-plejd/tree/0.7.1) (2021-03-25)

View file

@ -65,10 +65,11 @@ const getOutputDeviceDiscoveryPayload = (
qos: 1, qos: 1,
retain: true, retain: true,
device: { device: {
identifiers: `${device.deviceId}`, identifiers: `${device.uniqueId}`,
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,9 @@ class PlejdApi {
loadType = 'light'; loadType = 'light';
} }
const room = this.siteDetails.rooms.find((x) => x.roomId === device.roomId);
const roomTitle = room ? room.title : undefined;
/** @type {import('types/DeviceRegistry').OutputDevice} */ /** @type {import('types/DeviceRegistry').OutputDevice} */
const outputDevice = { const outputDevice = {
bleOutputAddress, bleOutputAddress,
@ -446,6 +449,7 @@ class PlejdApi {
name: device.title, name: device.title,
output: deviceOutput, output: deviceOutput,
roomId: device.roomId, roomId: device.roomId,
roomName: roomTitle,
state: undefined, state: undefined,
type: loadType, type: loadType,
typeName, typeName,
@ -518,7 +522,8 @@ class PlejdApi {
hiddenFromIntegrations: false, hiddenFromIntegrations: false,
name: room.title, name: room.title,
output: undefined, output: undefined,
roomId, roomId: undefined,
roomName: undefined,
state: undefined, state: undefined,
type: 'light', type: 'light',
typeName: 'Room', typeName: 'Room',
@ -548,6 +553,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

@ -1,9 +1,32 @@
# Hass.io Plejd add-on # 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. 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.
| 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. 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 - CTR-01
- REL-01 - REL-01
- REL-02 - REL-02
- WPH-01 (Note: Available as Device Trigger short_button_press, button_1 .. button_4) - WPH-01
- WRT-01 (Note: Available as Device Trigger short_button_press, button_1. Rotation/dimming not offered by the device) - WRT-01
### Easy Installation ### 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. - 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`. - 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. - Scroll down and you should find a Plejd add-on that can be installed. Open that and install.
- Configure hassio-plejd (see below)
- Enjoy! - Enjoy!
### Manual Installation ### Manual Installation
@ -108,7 +132,19 @@ If you restore a backup from a 32bit system to a new 64bit system, use the Rebui
### Configuration ### 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.
| 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:
``` ```
mqtt: mqtt:
@ -121,6 +157,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). 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. 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 | | Parameter | Value |

View file

@ -12,7 +12,8 @@ export interface OutputDevice {
hiddenFromSceneList?: boolean; hiddenFromSceneList?: boolean;
name: string; name: string;
output: number; output: number;
roomId: string; roomId: string | undefined;
roomName: string | undefined;
state: boolean | undefined; state: boolean | undefined;
type: string; type: string;
typeName: string; typeName: string;