Improve documentation

This commit is contained in:
Victor Hagelbäck 2021-06-09 15:49:18 +02:00
parent 71dbcc0b44
commit 56ab10744c
2 changed files with 173 additions and 172 deletions

View file

@ -1,28 +1,55 @@
# Details for Home Assistant beginners # Details regarding installation
If you can reach your Home Assistant at [http://homeassistant.local:8123](http://homeassistant.local:8123) the links below should work. If you can reach your Home Assistant at [http://homeassistant.local:8123](http://homeassistant.local:8123) the links below should work.
## Mosquitto ## Mosquitto
Head over to Supervisor -> Add-on Store and search for `mosquitto broker`.
Install it and then start [mosquito addon link](http://homeassistant.local:8123/hassio/addon/core_mosquitto/info)
Head over to Supervisor -> Add-on Store and search for `mosquitto broker`.
Install it and then start [mosquito addon link](http://homeassistant.local:8123/hassio/addon/core_mosquitto/info)
## Add api user for Mosquito ## Add api user for Mosquito
Add a Home Assistant user for the Plejd addon to be able to connect to Mosquito [Configuration -> Users](http://homeassistant.local:8123/config/users) Add a Home Assistant user for the Plejd addon to be able to connect to Mosquito [Configuration -> Users](http://homeassistant.local:8123/config/users)
Call the user e.g. `mqtt-api-user`, set a password and save Call the user e.g. `mqtt-api-user`, set a password and save
## Plejd ## Plejd
Follow the `Easy Installation` in [README.MD](plejd/README.md) Follow the `Easy Installation` in [README.MD](plejd/README.md)
And `Configuration Parameters` on the same page. And `Configuration Parameters` on the same page.
The only parameters needing a value are The only parameters needing a value are
* site
* username - site
* password - username
* mqttUsername e.g. `mqtt-api-user` - password
* mqttPassword - mqttUsername e.g. `mqtt-api-user`
- mqttPassword
Now you can start the Plejd add-on Now you can start the Plejd add-on
## Where are the lights? ## Where are the lights?
Head over to [Configuration -> Integrations](http://homeassistant.local:8123/config/integrations) and click Configure on MQTT Head over to [Configuration -> Integrations](http://homeassistant.local:8123/config/integrations) and click Configure on MQTT
After this step a new `Mosquito broker` should appear on the same page. If everything was setup correctly. It will list your lights under After this step a new `Mosquito broker` should appear on the same page. If everything was setup correctly. It will list your lights under
`1 entity`/`n entities` `1 entity`/`n entities`
## Running the Plejd add-on in VirtualBox on Windows
If on Windows + VirtualBox or similar setup
- Install VirtualBox extensions to get USB 2/3
- Redirect correct USB device
- Potentially try to replace BT drivers with WinUSB using Zadig
- (Re)start VirtualBox HA machine
## Running the Plejd add-on outside of Home Assistant Operating System ("HassOS")
If you're planning on running this add-on outside of HassOS, you might need to turn off AppArmor in the `config.json` file. This is due to missing AppArmor configuration that is performed in HassOS (if you've manually done it, ignore this).
Open the `config.json` file and locate `host_dbus`, after that line, insert: `"apparmor": "no",` and then restart the add-on.
More information about available parameters can be found here:
https://developers.home-assistant.io/docs/en/hassio_addon_config.html
## Migration from 32bit to 64 bit
If you restore a backup from a 32bit system to a new 64bit system, use the Rebuild option in the Add-on

View file

@ -3,6 +3,131 @@
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. Changed made in the Plejd app are propagated to Home Assistant. 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.
Thanks to [ha-plejd](https://github.com/klali/ha-plejd) for inspiration.
Disclaimer:
I am in no way affiliated with Plejd and am solely doing this as a hobby project.
**Did you like this? Consider helping me continue the development:**
[Buy me a coffee](https://www.buymeacoffee.com/w1ANTUb)
[![Gitter](https://badges.gitter.im/hassio-plejd/community.svg)](https://gitter.im/hassio-plejd/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
## Getting started
To get started, make sure that the following requirements are met:
### Requirements
- A Bluetooth device (BLE), se "Tested on" section below.
- An MQTT broker (the [Mosquitto broker Home Assistant add-on](https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md) works perfectly well).
### Tested on
The add-on has been tested on the following platforms:
- Odroid-n2+ / Home Assistant Blue / Home Assistant Operating System ("HassOS") / BT ASUS USB-BT400 - Chipset: Broadcom BCM20702A1-0b05-17cb
- Raspberry Pi 4 with Home Assistant ("Hass.io") / Built-in BT
- Raspberry Pi 4 with Home Assistant ("Hass.io"/aarch64) / Built-in BT
- Intel NUC7i5BNH with Home Assistant Operating System ("HassOS") intel NUC image / Built-in BT
- Windows 10 Pro host / Oracle VirtualBox 6.1 / Home Assistant VBox image / Deltaco BT-118 with Cambridge Silicon Radio chipset / Windows + Zadig to change driver to WinUSB
- Windows 10 host / Oracle Virtualbox 6.1 / Home Assistant VBox image / ASUS BT400
- Mac OS Catalina 10.15.1 with Node v. 13.2.0
Supported Plejd devices are detailed in a specific "Plejd devices" section below.
### Easy Installation
Browse to your Home Assistant installation in a web browser and click on `Supervisor` in the navigation bar to the left.
- Open the Home Assistant web console and click `Supervisor` in the menu on the left side.
- Click on `Add-on Store` in the top navigation bar of that page.
- Click on the three vertical dots to the far right and chose `Repositories`
- Paste the URL to this repo https://github.com/icanos/hassio-plejd.git in the `Add` 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
Browse your Home Assistant installation using a tool that allows you to manage files, for eg. SCP, SMB, SFTP client, etc.
- Open the `/addon` directory
- Create a new folder named `hassio-plejd`
- Copy all files from this repository into that newly created one.
- Open the Home Assistant web console and click `Supervisor` in the menu on the left side.
- Click on `Add-on Store` in the top navigation bar of that page.
- Click on the refresh button in the upper right corner.
- A new Local Add-on should appear named Plejd. Open that and install.
- Enjoy!
### Install older versions or development version
To install older versions, follow the "Manual Installation" instructions above, but copy the code from [one of the releases](https://github.com/icanos/hassio-plejd/releases). To test new functionality you can download the development version, available in the [develop branch](https://github.com/icanos/hassio-plejd/tree/develop).
### More details regarding installation
Please look at [The details](./Details.md) separate document for more detailed instructions regarding Home Asssistant, Mosquitto, etc.
### Startup error message
When starting the add-on, the log displays this message:
```
parse error: Expected string key before ':' at line 1, column 4
[08:56:24] ERROR: Unknown HTTP error occured
```
However, the add-on still works as expected and this is something I'm looking into, but not with that much effort yet though.
## Configuration
### Simple MQTT Configurations
When you are using the official Mosquitto Broker from Home Assistant Add-on store, minimal configuration is required.
Create a user in [Configuration -> Users](http://homeassistant.local:8123/config/users) named e.g. mqtt-api-user
| Parameter | Value |
| ------------ | ------------------------------------------------ |
| mqttBroker | mqtt:// |
| mqttUsername | Arbitrary Home Assistant User e.g. mqtt-api-user |
| mqttPassword | Users 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:
broker: [point to your broker IP eg. 'mqtt://localhost']
username: [username of mqtt broker]
password: !secret mqtt_password
discovery: true
discovery_prefix: homeassistant
```
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 |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| site | Name of your Plejd site, the name is displayed in the Plejd app (top bar). |
| username | Username of your Plejd account, this is used to fetch the crypto key and devices from the Plejd API. |
| password | Password of your Plejd account, this is used to fetch the crypto key and devices from the Plejd API. |
| mqttBroker | URL of the MQTT Broker, eg. mqtt:// |
| mqttUsername | Username of the MQTT broker |
| mqttPassword | Password of the MQTT broker |
| includeRoomsAsLights | Adds all rooms as lights, making it possible to turn on/off lights by room instead. Setting this to false will ignore all rooms. |
| updatePlejdClock | Hourly update Plejd devices' clock if out of sync. Clock is used for time-based scenes. Not recommended if you have a Plejd gateway. Clock updates may flicker scene-controlled devices. |
| logLevel | Minimim log level. Supported values are `error`, `warn`, `info`, `debug`, `verbose`, `silly` with increasing amount of logging. Do not log more than `info` for production purposes. |
| connectionTimeout | Number of seconds to wait when scanning and connecting. Might need to be tweaked on platforms other than RPi 4. Defaults to: 2 seconds. |
| writeQueueWaitTime | Wait time between message sent to Plejd over BLE, defaults to 400. If that doesn't work, try changing the value higher in steps of 50. |
## Plejd devices and corresponding Home Assistant devices
Plejd output devices typically appears as either lights or switches in Home Assistant depending on how they are configured. 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 | | Device | Plejd Configuration | Home Assistant Role | Comment |
@ -28,157 +153,21 @@ Plejd output devices typically appears as either lights or switches in Home Assi
| Room | - | Area | Can be changed by Home Assistant | | Room | - | Area | Can be changed by Home Assistant |
| Room | - | Light | If includeRoomsAsLights is set to true | | Room | - | Light | If includeRoomsAsLights is set to true |
Thanks to [ha-plejd](https://github.com/klali/ha-plejd) for inspiration. ## Transitions
Disclaimer: Transitions from Home Assistant are supported (for dimmable devices) when transition is longer than 1 second. Plejd will do a bit of internal transitioning (default soft start is 0.1 seconds).
I am in no way affiliated with Plejd and am solely doing this as a hobby project.
**Did you like this? Consider helping me continue the development:** This implementation will transition each device independently, meaning that brightness change might be choppy if transitioning many devices at once or a changing brightness a lot in a limited time. Hassio-plejd's communication channel seems to handle a few updates per second, this is the combined value for all devices.
[Buy me a coffee](https://www.buymeacoffee.com/w1ANTUb)
[![Gitter](https://badges.gitter.im/hassio-plejd/community.svg)](https://gitter.im/hassio-plejd/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) Transition points will be skipped if the queue of messages to be sent is over a certain threshold, by default equal to the number of devices in the system. Total transition time is prioritized rather than smoothness.
## Getting started Recommendations
To get started, make sure that the following requirements are met: - Only transition a few devices at a time when possible
- Entire rooms can be transitioned efficiently after settin gincludeRoomsAsLights to true
### Requirements - Expect 5-10 brightness changes per second, meaning 5 devices => 1-2 updates per device per second
- ... meaning that SLOW transitions will work well (wake-up light, gradually fade over a minute, ...), but quick ones will only work well for few devices or small relative changes in brightness
- A Bluetooth device (BLE), for eg. the built-in device in Raspberry Pi 4. - When experiencing choppy quick transitions, turn transitioning off and let the Plejd hardware do the work instead
- An MQTT broker (the Mosquitto Hass.io add-on works perfectly well).
### Tested on
The add-on has been tested on the following platforms:
- Mac OS Catalina 10.15.1 with Node v. 13.2.0
- Raspberry Pi 4 with Hass.io
- Raspberry Pi 4 with Hass.io/aarch64
- Intel NUC7i5BNH with HassOS intel NUC image (built-in BT)
#### Tested Plejd devices
- DIM-01
- DIM-02
- LED-10
- CTR-01
- REL-01
- REL-02
- WPH-01
- WRT-01
### Easy Installation
Browse to your Home Assistant installation in a web browser and click on `Supervisor` in the navigation bar to the left.
- Open the Home Assistant web console and click `Supervisor` in the menu on the left side.
- Click on `Add-on Store` in the top navigation bar of that page.
- Click on the three vertical dots to the far right and chose `Repositories`
- Paste the URL to this repo https://github.com/icanos/hassio-plejd.git in the `Add` 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
Browse your Hass.io installation using a tool that allows you to manage files, for eg. SMB or an SFTP client etc.
- Open the `/addon` directory
- Create a new folder named `hassio-plejd`
- Copy all files from this repository into that newly created one.
- Open the Home Assistant web console and click `Supervisor` in the menu on the left side.
- Click on `Add-on Store` in the top navigation bar of that page.
- Click on the refresh button in the upper right corner.
- A new Local Add-on should appear named Plejd. Open that and install.
- Enjoy!
### Detailed Home Assistant instructions
[The details](./Details.md)
### Install older versions or developemnt version
To install older versions, follow the "Manual Installation" instructions above, but copy the code from [one of the releases](https://github.com/icanos/hassio-plejd/releases). To test new functionality you can download the development version, available in the [develop branch](https://github.com/icanos/hassio-plejd/tree/develop).
### IMPORTANT INFORMATION
#### Startup error message
When starting the add-on, the log displays this message:
```
parse error: Expected string key before ':' at line 1, column 4
[08:56:24] ERROR: Unknown HTTP error occured
```
However, the add-on still works as expected and this is something I'm looking into, but not with that much effort yet though.
#### Running the Plejd add-on in VirtualBox on Windows
If on Windows + VirtualBox or similar setup
- Install VirtualBox extensions to get USB 2/3
- Redirect correct USB device
- Potentially try to replace BT drivers with WinUSB using Zadig
- (Re)start VirtualBox HA machine
#### Running the Plejd add-on outside of HassOS
If you're planning on running this add-on outside of HassOS, you might need to turn off AppArmor in the `config.json` file. This is due to missing AppArmor configuration that is performed in HassOS (if you've manually done it, ignore this).
Open the `config.json` file and locate `host_dbus`, after that line, insert: `"apparmor": "no",` and then restart the add-on.
More information about available parameters can be found here:
https://developers.home-assistant.io/docs/en/hassio_addon_config.html
#### Migration from 32bit to 64 bit
If you restore a backup from a 32bit system to a new 64bit system, use the Rebuild option in the Add-on
### Configuration
#### Simple MQTT Configurations
When you are using the official Mosquitto Broker from Home Assistant Add-on store, minimal configuration is required.
Create a user in [Configuration -> Users](http://homeassistant.local:8123/config/users) named e.g. mqtt-api-user
| Parameter | Value |
| ------------ | ---------------------------------------------------------------------------------------------------------------- |
| mqttBroker | mqtt:// |
| mqttUsername | Arbitrary Home Assistant User e.g. mqtt-api-user |
| mqttPassword | Users 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:
broker: [point to your broker IP eg. 'mqtt://localhost']
username: [username of mqtt broker]
password: !secret mqtt_password
discovery: true
discovery_prefix: homeassistant
```
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 |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| site | Name of your Plejd site, the name is displayed in the Plejd app (top bar). |
| username | Username of your Plejd account, this is used to fetch the crypto key and devices from the Plejd API. |
| password | Password of your Plejd account, this is used to fetch the crypto key and devices from the Plejd API. |
| mqttBroker | URL of the MQTT Broker, eg. mqtt:// |
| mqttUsername | Username of the MQTT broker |
| mqttPassword | Password of the MQTT broker |
| includeRoomsAsLights | Adds all rooms as lights, making it possible to turn on/off lights by room instead. Setting this to false will ignore all rooms. |
| updatePlejdClock | Hourly update Plejd devices' clock if out of sync. Clock is used for time-based scenes. Not recommended if you have a Plejd gateway. Clock updates may flicker scene-controlled devices. |
| logLevel | Minimim log level. Supported values are `error`, `warn`, `info`, `debug`, `verbose`, `silly` with increasing amount of logging. Do not log more than `info` for production purposes. |
| connectionTimeout | Number of seconds to wait when scanning and connecting. Might need to be tweaked on platforms other than RPi 4. Defaults to: 2 seconds. |
| writeQueueWaitTime | Wait time between message sent to Plejd over BLE, defaults to 400. If that doesn't work, try changing the value higher in steps of 50. |
## Troubleshooting ## Troubleshooting
@ -202,21 +191,6 @@ If you're having issues to get the addon working, there are a few things you can
- One Plejd device means max one BLE connection, meaning using the Plejd app over BT will disconnect the addon BLE connection - One Plejd device means max one BLE connection, meaning using the Plejd app over BT will disconnect the addon BLE connection
- It seems you can kick yourself out (by connecting using the app) even when you have multiple devices if the app happens to connect to the same device as the addon is using - It seems you can kick yourself out (by connecting using the app) even when you have multiple devices if the app happens to connect to the same device as the addon is using
## Transitions
Transitions from Home Assistant are supported (for dimmable devices) when transition is longer than 1 second. Plejd will do a bit of internal transitioning (default soft start is 0.1 seconds).
This implementation will transition each device independently, meaning that brightness change might be choppy if transitioning many devices at once or a changing brightness a lot in a limited time. Hassio-plejd's communication channel seems to handle a few updates per second, this is the combined value for all devices.
Transition points will be skipped if the queue of messages to be sent is over a certain threshold, by default equal to the number of devices in the system. Total transition time is prioritized rather than smoothness.
Recommendations
- Only transition a few devices at a time when possible
- Expect 5-10 brightness changes per second, meaning 5 devices => 1-2 updates per device per second
- ... meaning that SLOW transitions will work well (wake-up light, gradually fade over a minute, ...), but quick ones will only work well for few devices or small relative changes in brightness
- When experiencing choppy quick transitions, turn transitioning off and let the Plejd hardware do the work instead
## I want voice control! ## I want voice control!
With the Google Home integration in Home Assistant, you can get voice control for your Plejd lights right away, check this out for more information: With the Google Home integration in Home Assistant, you can get voice control for your Plejd lights right away, check this out for more information: