Coder Social home page Coder Social logo

node-red-contrib-plejd's Introduction

node-red-contrib-plejd

A set of Node-RED nodes for interacting with Plejd.

Q&A

Q1 Why can’t Node-RED connect to Plejd?

  • Check if the Plejd mesh is not connected to another bluetooth device. The Plejd app for example

Q2 Why can I not use the Plejd app when node-red-contrib-plejd is running?

  • It’s because only one device can be connected to the BLE mesh at the time.

Install

Run the following command in the user directory of your Node-RED install. This is usually ~/.node-red.

npm install node-red-contrib-plejd

Gathering crypto and device information

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.

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
  1. 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
  1. 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'
  1. 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).

Usage

connection

All nodes needs to be configured with a Plejd connection. The only setting for the connection is the crypto key.

Input Node

Return state changes of Plejd devices in msg.payload. Example input:

{id: 11, state: 'on', dim: 255}

Output node

Change state of a Plejd device in the mesh by using msg.payload:

{id: 12, state: 'off', dim: 255}

{id: 13, state: 'on', dim: 100}

Thanks

Big thanks to @klali and his https://github.com/klali/ha-plejd component for Home assistant, this project would not have been possible without it.

node-red-contrib-plejd's People

Contributors

emilohman avatar radhus avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

radhus

node-red-contrib-plejd's Issues

Cannot read property 'register' of null

I get error 23 Oct 18:28:20 - [error] [plejd out:89657622.d564] TypeError: Cannot read property 'register' of null when running Node-Red
Also, when I try to inject a msg I get error 23 Oct 18:31:11 - [error] [plejd out:89657622.d564] TypeError: Cannot read property 'toString' of undefined

Can't find site.json file

Hi I followed the steps described in this contrib. Works fine till I come to this step "cp apps/com.plejd.plejdapp/f//.site site.json"
When I try to execute this one it sais that site.json does not exist. Anyone know what I am doing wrong? Im not a master on linux so pls help me here

Error: error:0607F08A:digital envelope routines:EVP_EncryptFinal_ex:data not multiple of block length

Hi,

I receive this error after I've setup one flow of Plejd.

I run node-red v1.0.0 on my MacBook Pro Mojave v10.14.4 and node-red-contrib-plejd v.0.0.7

Below is my node-red log and my flow ....

What am I missing? I also receive similar error while sending to Plejd out.

2 Oct 21:48:29 - [info] Starting flows 2 Oct 21:48:29 - [info] Started flows 2 Oct 21:48:29 - [info] Server now running at http://127.0.0.1:1880/ 2 Oct 21:48:31 - [info] [plejd:Plejd IN] Plejd setup is complete 2 Oct 21:48:37 - [error] [plejd out:Plejd OUT] Error: error:0607F08A:digital envelope routines:EVP_EncryptFinal_ex:data not multiple of block length FATAL ERROR: error:0607F08A:digital envelope routines:EVP_EncryptFinal_ex:data not multiple of block length 1: 0x10003d035 node::Abort() [/usr/local/bin/node] 2: 0x10003d23f node::OnFatalError(char const*, char const*) [/usr/local/bin/node] 3: 0x10003d1f5 node::OnFatalError(char const*, char const*) [/usr/local/bin/node] 4: 0x100045d77 napi_create_function [/usr/local/bin/node] 5: 0x10634e641 Napi::Error::Fatal(char const*, char const*) [/Users/jamelnacef/.node-red/node_modules/@abandonware/noble/lib/mac/native/binding.node] 6: 0x106359c45 ThreadSafeCallback::Impl::static_async_callback(uv_async_s*) [/Users/jamelnacef/.node-red/node_modules/@abandonware/noble/lib/mac/native/binding.node] 7: 0x1009b5cc3 uv__async_io [/usr/local/bin/node] 8: 0x1009c60fb uv__io_poll [/usr/local/bin/node] 9: 0x1009b6139 uv_run [/usr/local/bin/node] 10: 0x100044831 node::Start(v8::Isolate*, node::IsolateData*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) [/usr/local/bin/node] 11: 0x100043d3c node::Start(uv_loop_s*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) [/usr/local/bin/node] 12: 0x100043886 node::Start(int, char**) [/usr/local/bin/node] 13: 0x100001034 start [/usr/local/bin/node] Abort trap: 6

Exported flow below:

[{"id":"b31b9b1d.f07798","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"fe25e1e1.7e9e48","type":"plejd in","z":"b31b9b1d.f07798","name":"Plejd IN","plejd":"e54ad567.ad56f","x":150.5,"y":221,"wires":[["f25a2621.98131"]]},{"id":"f25a2621.98131","type":"debug","z":"b31b9b1d.f07798","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":622.5,"y":221,"wires":[]},{"id":"ee3079ba.5931d8","type":"plejd out","z":"b31b9b1d.f07798","name":"Plejd OUT","plejd":"e54ad567.ad56f","x":614.5,"y":333,"wires":[]},{"id":"fac3693d.c78bd8","type":"inject","z":"b31b9b1d.f07798","name":"","topic":"","payload":"{id: 12, state: 'on', dim: 255}","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":185.5,"y":334,"wires":[["e6508e1a.e71f28"]]},{"id":"e6508e1a.e71f28","type":"function","z":"b31b9b1d.f07798","name":"code","func":"msg.payload = {id: 16, state: 'on', dim: 255}\nreturn msg;","outputs":1,"noerr":0,"x":365.5,"y":335,"wires":[["ee3079ba.5931d8"]]},{"id":"e54ad567.ad56f","type":"plejd","z":"","name":"Plejd IN","cryptoKey":"C5DD22D1AB2CF7CC37F0A7245EBF810D"}]

Stability issues

I'm trying this Node out and must say I'm impressed. Even though it is a little hackish to get the key it was really easy to get started. Great work!
However in my case it doesn't seem to stable and I don't know why. All of a sudden it stops working and I can see this in the log:

Sep 28 15:00:26 iot-open Node-RED[282]: 28 Sep 15:00:26 - [error] [plejd out:25275d42.408b32] TypeError: callback is not a function

Sometimes restarting Node-RED solves it and sometimes I need to restart the machine (a Raspberry Pi). Do you know about this and is there a way to fix it?

Keep up the good work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.