This is a simple Plejd component for Home Assistant, interfacing with the bluetooth le protocol.
This component has been tested on the following platforms:
There's been reports that bluez version 5.37 is problematic while 5.48 works fine.
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.
$ adb backup com.plejd.plejdapp
$ dd if=backup.ab bs=1 skip=24 | zlib-flate -uncompress | tar -xv
$ cp apps/com.plejd.plejdapp/f/*/*.site site.json
When the site.json file has been recovered the cryptokey and the output addresses can be extracted:
$ cat site.json | jq '.PlejdMesh.CryptoKey' | sed 's/-//g'
$ cat site.json | jq '.PlejdMesh._outputAddresses' | grep -v '\$type' | jq '.[][]'
These steps can obviously be done manually instead of extracting the fields using jq and shell tricks.
Make sure the homeassistant user has permissions to use bluetooth, this might require putting it in the bluetooth group.
Run this as a custom component, put the files light.py, manifest.json and __init__.py in custom_components/plejd in your configuration.yaml add something like:
light:
- platform: plejd
crypto_key: !secret plejd
devices:
11:
name: bedroom
13:
name: kitchen_1
14:
name: kitchen_2
16:
name: bathroom
If you know that there are a lot of plejd devices nearby that is not part of your installation you can specify which
plejd ids home assistant is allowed to connect to using endpoints: ['AAAAAAAAAAAA', 'BBBBBBBBBBBB', ... ]
. You can
find the id for each plejd device in the ios/android app under devices->[plejd device]->about or in the extracted
site.json file under _outputAddresses
. For example, the following config would only allow connections to
A1B2C3D4E5F6
.
light:
- platform: plejd
crypto_key: !secret plejd
endpoints: ['A1B2C3D4E5F6']
devices:
11:
name: bedroom
13:
name: kitchen_1
14:
name: kitchen_2
16:
name: bathroom
Hass.io default installation script will map /usr/share/hassio/homeassistant to the /config directory inside the docker container. create a custom_components directory if it doesn't exist (it doesn't by default).
mkdir -p /usr/share/hassio/homeassistant/custom_components
Checkout the git repo and rename folder
cd /usr/share/hassio/homeassistant/custom_components
git clone https://github.com/klali/ha-plejd.git
mv ha-plejd plejd
Update your configuration.yaml file
light:
- platform: plejd
crypto_key: !secret plejd
devices:
11:
name: bedroom
13:
name: kitchen_1
14:
name: kitchen_2
16:
name: bathroom
Last step is to restart homeassistant service, in the homeassistant web ui, go to Configuration -> General -> Server management and hit restart.
Generally it is helpful to turn on debug logging for the component for any type of troubleshooting, this will show what the component receives and interprets from the plejd network. To do this add something like the following to your configuration:
logger:
logs:
custom_components.plejd: debug
Copyright 2019 Klas Lindfors <klali@avm.se>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.