-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 97fac49
Showing
24 changed files
with
1,695 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Plejd | ||
|
||
This App brings support for the Plejd devices. | ||
|
||
## Q&A | ||
|
||
> **Q1** Why can’t Homey connect to Plejd? | ||
* _Check if the Plejd mesh is not connected to another bluetooth device. The `Plejd` app for example_ | ||
|
||
> **Q2** Why is the Plejd devices displaying wrong states in Homey? | ||
* _It’s because Homey can’t get the state from the Plejd device due to limitation in Homeys Bluetooth support. See https://github.com/athombv/homey-apps-sdk-issues/issues/81._ | ||
|
||
## Usage | ||
|
||
Obtaining the crypto key and the device ids is a crucial step to get this | ||
running, for this it is required to get the .site json file from the plejd app on android or iOS. Then enter them while adding devices to Homey. | ||
|
||
### Steps for android: | ||
|
||
1. Turn on USB debugging and connect the phone to a computer. | ||
2. Extract a backup from the phone: | ||
``` | ||
$ adb backup com.plejd.plejdapp | ||
``` | ||
3. Unpack the backup: | ||
``` | ||
$ dd if=backup.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" | tar -xv | ||
``` | ||
4. Recover the .site file: | ||
``` | ||
$ cp apps/com.plejd.plejdapp/f/*/*.site site.json | ||
``` | ||
|
||
### Steps for iOS: | ||
|
||
1. Open a backup in iBackup viewer. | ||
2. Select raw files, look for AppDomainGroup-group.com.plejd.consumer.light. | ||
3. In AppDomainGroup-group.com.plejd.consumer.light/Documents there should be two folders. | ||
4. The folder that isn't named ".config" contains the .site file. | ||
|
||
### Gather cryto key and ids for devices | ||
|
||
When the site.json file has been recovered the cryptokey and the output | ||
addresses can be extracted: | ||
|
||
1. Extract the cryptoKey: | ||
``` | ||
$ cat site.json | jq '.PlejdMesh.CryptoKey' | sed 's/-//g' | ||
``` | ||
2. Extract the outputAddresses: | ||
``` | ||
$ cat site.json | jq '.PlejdMesh.outputAdresses' | grep -v '\$type' | jq '.[][]' | ||
``` | ||
|
||
Or just open site.json in your favorite editor and extract the crypto key and output addresses (IDs). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
const Homey = require('homey'); | ||
|
||
class PlejdApp extends Homey.App { | ||
|
||
async onInit() { | ||
this.log('PlejdApp is running...'); | ||
} | ||
} | ||
|
||
module.exports = PlejdApp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"id": "se.emilohman.plejd", | ||
"version": "0.0.1", | ||
"compatibility": ">=2.1.2", | ||
"sdk": 2, | ||
"name": { | ||
"en": "Plejd" | ||
}, | ||
"description": { | ||
"en": "Adds support for Plejd devices." | ||
}, | ||
"tags": { | ||
"en": [ "plejd, light, bluetooth, BLE, dimmer" ] | ||
}, | ||
"category": [ | ||
"lights" | ||
], | ||
"permissions": [ | ||
"homey:wireless:ble" | ||
], | ||
"images": { | ||
"large": "/assets/images/large.png", | ||
"small": "/assets/images/small.png" | ||
}, | ||
"author": { | ||
"name": "Emil Öhman", | ||
"email": "emilohman@gmail.com" | ||
}, | ||
"contributors": { | ||
"developers": [ | ||
{ | ||
"name": "Emil Öhman", | ||
"email": "emilohman@gmail.com" | ||
} | ||
] | ||
}, | ||
"drivers": [ | ||
{ | ||
"id": "plejd", | ||
"name": { | ||
"en": "Plejd" | ||
}, | ||
"class": "light", | ||
"capabilities": [ | ||
"dim", | ||
"onoff" | ||
], | ||
"images": { | ||
"large": "/drivers/plejd/assets/images/large.png", | ||
"small": "/drivers/plejd/assets/images/small.png" | ||
}, | ||
"pair": [ | ||
{ | ||
"id": "settings", | ||
"navigation": { | ||
"next": "done" | ||
} | ||
}, | ||
{ | ||
"id": "done" | ||
} | ||
] | ||
} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
const Homey = require('homey'); | ||
|
||
class PlejdDevice extends Homey.Device { | ||
|
||
onInit() { | ||
const driver = this.getDriver(); | ||
this.log('Plejd Device (' + this.getName() + ') initialized'); | ||
this.log('id: ', this.getData().id); | ||
this.log('plejdId: ', this.getData().plejdId); | ||
this.log('count ', driver.getDevices().length); | ||
|
||
this.registerCapabilityListener("onoff", async value => { | ||
this.log(`Power is set to: ${value} for id ${this.getData().plejdId}`); | ||
if (value) { | ||
return await driver.turnOn(parseInt(this.getData().plejdId)); | ||
} else { | ||
return await driver.turnOff(parseInt(this.getData().plejdId)); | ||
} | ||
}); | ||
|
||
this.registerCapabilityListener("dim", async value => { | ||
this.log(`Brightness is set to ${value}`); | ||
|
||
const brightness = parseInt(255 * value); | ||
if (brightness == 0) { | ||
return await driver.turnOff(this.getData().plejdId); | ||
} else { | ||
return await driver.turnOn(this.getData().plejdId, brightness); | ||
} | ||
}); | ||
} | ||
|
||
async onAdded() { | ||
const driver = this.getDriver(); | ||
|
||
this.log('Adding device: ' + this.getName() + ' (' + this.getData().id + ')'); | ||
this.log('count ', driver.getDevices().length); | ||
|
||
if (driver.getDevices().length === 1) { | ||
await driver.connect(); | ||
} | ||
} | ||
|
||
async onDeleted() { | ||
const driver = this.getDriver(); | ||
|
||
this.log('device deleted: ' + this.getName()); | ||
this.log('count ', driver.getDevices().length); | ||
|
||
if (driver.getDevices().length === 0) { | ||
await driver.disconnect(); | ||
} | ||
} | ||
|
||
} | ||
|
||
module.exports = PlejdDevice; |
Oops, something went wrong.