AM43 blinds control through MQTT

Hi,

Bought these relative cheap BLE-only blinds drivers from aliexpress:

As the BLE range is not that great, I wrote a small Node application which runs on a Rpi 3B+ close to the blinds. It accepts commands through Mqtt and implements mqtt cover discovery for Home-Assistant integration.
At this point I was only able to reverse engineer open,close and stop command, but actually that’s enough for me :slight_smile:

Project Link:

5 Likes

Can you help. i have tried to install this and i get the error below.

am43ctrl
internal/modules/cjs/loader.js:583
throw err;
^

Error: Cannot find module ‘/usr/local/lib/node_modules/am43-ctrl/node_modules/@abandonware/bluetooth-hci-socket/lib/binding/binding.node’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (/usr/local/lib/node_modules/am43-ctrl/node_modules/@abandonware/bluetooth-hci-socket/lib/native.js:6:15)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)

On which hardware/OS are you running? Mayb try to reinstall non-globally using ‘sudo npm install https://github.com/binsentsu/am43-ctrl’ into directory of choice…

How did you manage to reverse engineer BLE communications? I’m looking at doing something similar for another product (SwitchRobot) that runs on BLE-only and doesn’t come with a hub.

i am using a Pi zero w, I tried it none-globally still get the same issue

Enable Bluetooth snoop logging in developer options of android phone. After performing communication to device through app, you can inspect the snooped logs through WireShark.

1 Like

Don’t have a pi zero w here, but maybe this link can get you in de right direction:
https://www.brokoko.eu/ble-with-noble-on-raspi-zero/

So i have tried this also on a Pi3 and i get the error below.

pi@raspberrypi:~ $ am43ctrl
/usr/local/lib/node_modules/am43-ctrl/src/am43.js:26
static busyDevice = null;
^

SyntaxError: Unexpected token =
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)

not sure what i am doing wrong

Try following steps:

  • make a new directory in your /home/pi
  • cd into newly created directory
  • run npm install https://github.com/binsentsu/am43-ctrl
  • cd into node_modules/.bin
  • run by using: sudo ./am43ctrl … like in readme.

Thanks. I also found this very useful resource for BLE reverse engineering.

thank you for your reply. i have tried that and now i get another error.
I have now trired this on a Pi3b and Pi 4 both new installs

internal/modules/cjs/loader.js:805
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: libnode.so.64: cannot open shared object file: No such file or directory
at Object.Module._extensions…node (internal/modules/cjs/loader.js:805:18)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/home/pi/.npm-global/lib/node_modules/am43-ctrl/node_modules/@abandonware/bluetooth-hci-socket/lib/native.js:6:15)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)

Looks like something with your node installation…
For what it’s worth: I installed node by using this tutorial (linux binaries ArmV7 for RPI3B+)


Running version 12.14.1 at this moment.
RPI running on raspbian stretch.
Util installation like described in previous post.

How might you get this to work with Hass.io running on a RPi 3b+?

Don’t know if it’s possible if your running home-assistant through it’s dedicated operating system (HassOS), because this hasn’t full blown capabilities of a raspbian image. But if you run Hass.io on a generic linux host (they call it Home Assistant Supervised nowadays), you can just self install nodeJS and install the package through npm like described on github page.

This is awesome. Thanks for putting this together. Can someone tell me how I can get the MAC address of the devices? I don’t have an android device, so I can’t use nrfconnect :(. Any help would be super appreciated!

You Can run “blescan” from command line on the pi and it will list them.
If you set the name in the app it’s easier to see

Thanks! I’ll try that today. Appreciate the fast reply.

Worked a treat. I spent ages trying to figure out why I was getting “noble warning: unknown peripheral 0289a1xxxxxx”. Turns out, I needed to do “hciconfig hci0 reset” to get it working.

Thanks so much @jjtyper - and @binsentsu for creating this!

1 Like

I got everything up and running last night, although today I’m struggling to connect, my logs are full of:

2020-03-29T15:48:30.245Z am43:02b0b69xxxx AM43 connected for data reading
2020-03-29T15:48:30.279Z am43:02b0b69xxxx disconnected for data reading
2020-03-29T15:48:30.279Z am43:02b0b69xxxx Reading data unsuccessful, retrying in 1 second…

How far is the unit from the blinds? The BLE range of these devices does not reach far. This warning can occur sometimes, but not constantly.