AM43 blinds control through MQTT

It does do MQTT auth now, I just updated to support this, plus another couple of tweaks.

Thanx for the update. I loaded the script into my ESP32 and had it running for a while. Unfortunately it stops very frequently however the BLEClient.cpp file was patched as advised. Could you please post yours, just to make sure I did it right?
I also recorded a few log files and can send it to you if it helps.

Yeah the ble stack can be a little unstable, particularly when scanning.

If you raise an issue in GitHub with the logs I will take a look at it.

@buxtronix Very cool project. I see you have planned ESPHome support on your todo list. Any idea when this could be finished? I’d like to know if I need to order a new ESP32 or if I can use my existing one which is located close to my blinds anyway :wink: Thanks!

I’ve already started playing with getting a working BLE client working in ESPhome.
The logic is fairly easy to implement, though I’m seeing a bunch of instability and crashes when BLE is enabled so trying to debug that.

2 Likes

Very nice! Let me know if you need me to test :slight_smile:

Thanx for the update. I loaded the script into my ESP32 and had it running for a while. Unfortunately it stops very frequently however the BLEClient.cpp file was patched as advised. Could you please post yours, just to make sure I did it right?
I also recorded a few log files and can send it to you if it helps.

I think I’ve finally managed to resolve all of the general instability around ESP32 and BLE that has been causing troubles for this and other projects.

Please see the update in AM43 controller keeps stopping · Issue #2 · buxtronix/am43 · GitHub and give it a go. My ESP32 devices have been very stable since I made the changes.

Help me figure it out, when installing I get the following:

Summary

npm install *****************/am43-ctrl

[email protected] install /home/sergio/node_modules/usb
prebuild-install --verbose || node-gyp rebuild

prebuild-install info begin Prebuild-install version 5.3.5
prebuild-install info looking for cached prebuild @ /home/sergio/.npm/prebuilds /470134-usb-v1.6.3-node-v72-linux-arm.tar.gz
prebuild-install http request GET https://github.com/tessel/node-usb/releases/do wnload/v1.6.3/usb-v1.6.3-node-v72-linux-arm.tar.gz
prebuild-install http 404 https://github.com/tessel/node-usb/releases/download/v 1.6.3/usb-v1.6.3-node-v72-linux-arm.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=12.18.2 runtime =node arch=arm libc= platform=linux)
make: вход в каталог «/home/sergio/node_modules/usb/build»
CC(target) Release/obj.target/libusb/libusb/libusb/core.o
CC(target) Release/obj.target/libusb/libusb/libusb/descriptor.o
CC(target) Release/obj.target/libusb/libusb/libusb/hotplug.o
CC(target) Release/obj.target/libusb/libusb/libusb/io.o
CC(target) Release/obj.target/libusb/libusb/libusb/strerror.o
CC(target) Release/obj.target/libusb/libusb/libusb/sync.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/poll_posix.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/threads_posix.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_usbfs.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_udev.o
…/libusb/libusb/os/linux_udev.c:40:10: fatal error: libudev.h: Нет такого файла или каталога
#include <libudev.h>
^~~~~~~~~~~
compilation terminated.
make: *** [libusb.target.mk:148: Release/obj.target/libusb/libusb/libusb/os/linu x_udev.o] Ошибка 1
make: выход из каталога «/home/sergio/node_modules/usb/build»
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node
modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_proces s.js:275:12)
gyp ERR! System Linux 5.4.49-v7l+
gyp ERR! command “/usr/local/bin/node” “/usr/local/lib/node_modules/npm/node_mod ules/node-gyp/bin/node-gyp.js” “rebuild”
gyp ERR! cwd /home/sergio/node_modules/usb
gyp ERR! node -v v12.18.2
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN saveError ENOENT: no such file or directory, open ‘/home/sergio/package .json’
npm WARN enoent ENOENT: no such file or directory, open ‘/home/sergio/package.js on’
npm WARN sergio No description
npm WARN sergio No repository field.
npm WARN sergio No README data
npm WARN sergio No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/usb):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: prebuild-ins tall --verbose || node-gyp rebuild
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

3 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

The component from @buxtronix is working great here! Thanks again.

The only thing I’m noticing, is that I need to charge the battery every x weeks with the power adapter.
I was hoping to be able to use the solar power charger only.
Can anyone confirm that using the solar adapter only is working for them indefinitely?
Could this component cause the larger battery drain? Some text in your Github repo suggests that the BLE connection drains the battery faster. Any ideas?

Also, any news on the ESPHome part?

Battery might be an issue yeah. Though I have mine mains powered.

The ESPHome port is coming along nicely. I took some time first to implement a generic BLE component so other types of device can be supported. The PR is open:

With this in, I’m now working on the am43 cover, which is pretty easy now that the heavy lifting of BLE connection management is dealt with.

2 Likes

Whats the status on this? The PR seems to be stalled… Hope it works out :slight_smile:

Still waiting for the PR to get merged. Maintainers haven’t been addressing too many PRs lately.

I’ve finished the AM43 ESPHome component and it’s been working solidly for a few weeks. Waiting for the BLE pr to merge first before I submit am43.

With automations, I get very good battery life by only connecting on demand. Full solar power now without having to plug in the charger.

3 Likes

Hi, when i run the script nothings happend i get only a message scanning for 2 devices.

./am43ctrl 02b62c22d6bc --mqtt-url 1883 mqtt://192.168.178.5 -u username -p password -topic
am43* scanning for 2 device(s) [ ‘02b62c22d6bc’, ‘mqtt//192.168.178.5’ ] +0ms

My AM43 is setup and I’m waiting for the PR to get merged :slight_smile:

Hi, to ./am43ctrl manual works fine.

when i made the service script i must downgrade the node modle version. how can i do that?

Error: The module '/home/pi/node_mod
Oct 08 13:37:46 raspberrypi am43ctrl[1115]: was compiled against a different Nod
Oct 08 13:37:46 raspberrypi am43ctrl[1115]: NODE_MODULE_VERSION 83. This version
Oct 08 13:37:46 raspberrypi am43ctrl[1115]: NODE_MODULE_VERSION 64. Please try r
Oct 08 13:37:46 raspberrypi am43ctrl[1115]: the module (for instance, using `npm
Oct 08 13:37:46 raspberrypi am43ctrl[1115]:     at Object.Module._extensions..no
Oct 08 13:37:46 raspberrypi am43ctrl[1115]:     at Module.load (internal/modules
Oct 08 13:37:46 raspberrypi am43ctrl[1115]:     at tryModuleLoad (internal/modul
Oct 08 13:37:46 raspberrypi am43ctrl[1115]:     at Function.Module._load (intern
Oct 08 13:37:46 raspberrypi am43ctrl[1115]:     at Module.require (internal/modu
Oct 08 13:37:46 raspberrypi am43ctrl[1115]:     at require (internal/modules/cjs
Oct 08 13:37:46 raspberrypi am43ctrl[1115]:     at Object.<anonymous> (/home/pi/
Oct 08 13:37:46 raspberrypi am43ctrl[1115]:     at Module._compile (internal/mod
Oct 08 13:37:46 raspberrypi am43ctrl[1115]:     at Object.Module._extensions..js
Oct 08 13:37:46 raspberrypi am43ctrl[1115]:     at Module.load (internal/modules
Oct 08 13:37:46 raspberrypi systemd[1]: am43ctrl.service: Main process exited, c
Oct 08 13:37:46 raspberrypi systemd[1]: am43ctrl.service: Failed with result 'ex
Oct 08 13:37:46 raspberrypi systemd[1]: am43ctrl.service: Service RestartSec=100

@buxtronix
Is the AM43 ESPHome component on github ? if not care to share ? Would like to use it before it gets merged :slight_smile:

Thanks

If anyone needs the first project ( nodejs based ) as a hassio addon here it is:

Tested and works ok :slight_smile:

Any update? What about esphome?

Still not merged, the maintainer seems to have gone MIA. I will look at putting up a fork with my changes including am43.

2 Likes

Ok, i’m waiting. thx