Merge branch 'bluez' of https://github.com/icanos/hassio-plejd into bluez

This commit is contained in:
Marcus Westin 2020-01-24 11:00:32 +01:00
commit 1deb59ce6b
6 changed files with 58 additions and 9 deletions

View file

@ -98,6 +98,9 @@ Check this out for more information on how you can get your Plejd lights control
https://www.home-assistant.io/integrations/homekit/ https://www.home-assistant.io/integrations/homekit/
## Changelog ## Changelog
*v 0.2.8*:
* FIX: Reset characteristic state on disconnect
*v 0.2.7*: *v 0.2.7*:
* FIX: Added exception handling to unsubscribing lastData characteristic if already disconnected * FIX: Added exception handling to unsubscribing lastData characteristic if already disconnected

View file

@ -9,6 +9,9 @@ Thanks to [ha-plejd](https://github.com/klali/ha-plejd) for inspiration.
Disclaimer: Disclaimer:
I am in no way affiliated with Plejd and am solely doing this as a hobby project. 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)
## Getting started ## Getting started
To get started, make sure that the following requirements are met: To get started, make sure that the following requirements are met:
@ -33,7 +36,7 @@ The add-on has been tested on the following platforms:
Browse to your Home Assistant installation in a web browser and click on `Hass.io` in the navigation bar to the left. Browse to your Home Assistant installation in a web browser and click on `Hass.io` in the navigation bar to the left.
* Open the Home Assistant web console and click `Hass.io` in the menu on the left side. * Open the Home Assistant web console and click `Hass.io` in the menu on the left side.
* 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/ 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.
* Enjoy! * Enjoy!
@ -48,11 +51,19 @@ Browse your Hass.io installation using a tool that allows you to manage files, f
* A new Local Add-on should appear named Plejd. Open that and install. * A new Local Add-on should appear named Plejd. Open that and install.
* Enjoy! * Enjoy!
### NOTE
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 ### Configuration
You need to add the following to your `configuration.yaml` file: You need to add the following to your `configuration.yaml` file:
``` ```
mqtt: mqtt:
broker: [point to your broker IP] broker: [point to your broker IP eg. 'mqtt://localhost']
username: [username of mqtt broker] username: [username of mqtt broker]
password: !secret mqtt_password password: !secret mqtt_password
discovery: true discovery: true
@ -87,10 +98,43 @@ Check this out for more information on how you can get your Plejd lights control
https://www.home-assistant.io/integrations/homekit/ https://www.home-assistant.io/integrations/homekit/
## Changelog ## Changelog
*0.1.4*: *v 0.2.8*:
* FIX: bug preventing add-on from building * FIX: Reset characteristic state on disconnect
*0.1.3*: *v 0.2.7*:
* FIX: Added exception handling to unsubscribing lastData characteristic if already disconnected
*v 0.2.6*:
* FIX: Added null check to remove listeners for characteristics
*v 0.2.5*:
* FIX: Invalid scene id in events/scene message
*v 0.2.4*:
* Stability improvements
*v 0.2.3*:
* FIX: Container build error fix
*v 0.2.2*:
* Stability improvements
*v 0.2.1*:
* Stability improvements
*v 0.2.0*:
* Stability improvements
* Bugfixes
*v 0.1.1*:
* FIX: Fixed missing reference on startup, preventing add-on from starting
*v 0.1.0*:
* NEW: Rewrote the BLE integration for more stability
* FIX: discovery wasn't always sent
*previous*:
* FIX: bug preventing add-on from building
* NEW: Added support for Plejd devices with multiple outputs (such as DIM-02) * NEW: Added support for Plejd devices with multiple outputs (such as DIM-02)
## License ## License

View file

@ -45,7 +45,7 @@ class PlejdApi extends EventEmitter {
login() { login() {
console.log('plejd-api: login()'); console.log('plejd-api: login()');
console.log('logging into ' + this.siteName); console.log('plejd-api: logging into ' + this.siteName);
const self = this; const self = this;
const instance = axios.create({ const instance = axios.create({

View file

@ -198,7 +198,8 @@ class PlejdService extends EventEmitter {
} }
if (!uuid) { if (!uuid) {
this.device = Object.values(this.devices)[this.deviceIdx]; let sortedDevices = Object.values(this.devices).sort((a, b) => b.rssi - a.rssi);
this.device = sortedDevices[this.deviceIdx];
} }
else { else {
this.device = this.devices[uuid]; this.device = this.devices[uuid];

View file

@ -15,7 +15,6 @@ async function main() {
const client = new mqtt.MqttClient(config.mqttBroker, config.mqttUsername, config.mqttPassword); const client = new mqtt.MqttClient(config.mqttBroker, config.mqttUsername, config.mqttPassword);
plejdApi.once('loggedIn', () => { plejdApi.once('loggedIn', () => {
plejdApi.getCryptoKey();
plejdApi.on('ready', (cryptoKey) => { plejdApi.on('ready', (cryptoKey) => {
const devices = plejdApi.getDevices(); const devices = plejdApi.getDevices();
@ -72,6 +71,8 @@ async function main() {
} }
}); });
}); });
plejdApi.getCryptoKey();
}); });
plejdApi.login(); plejdApi.login();

View file

@ -140,7 +140,7 @@ class MqttClient extends EventEmitter {
logger(`sending discovery for ${device.name}`); logger(`sending discovery for ${device.name}`);
let payload = getDiscoveryPayload(device); let payload = getDiscoveryPayload(device);
console.log(`discovered ${device.type}: ${device.name} with Plejd ID ${device.id}.`); console.log(`plejd-mqtt: discovered ${device.type} named ${device.name} with PID ${device.id}.`);
self.deviceMap[device.id] = payload.unique_id; self.deviceMap[device.id] = payload.unique_id;