binsentsu / am43-ctrl

Node Util for controlling an AM43 Blinds Drive Cover, either over MQTT or via a HTTP API
44 stars 25 forks source link

Issue with Installation #9

Closed reesion closed 4 years ago

reesion commented 4 years ago

Hi,

I am running Hass.io on Ubuntu v18.04. I have tried to install this and getting a mixture of issues with nodejs and npm. I finally get it installed with no issue but having issue running it.

Any idea what is happening?

root@rsha01:~# am43ctrl internal/modules/cjs/loader.js:807 return process.dlopen(module, path.toNamespacedPath(filename)); ^

Error: The module '/usr/local/lib/node_modules/am43-ctrl/node_modules/@abandonware/bluetooth-hci-socket/lib/binding/binding.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 57. This version of Node.js requires NODE_MODULE_VERSION 64. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install). at Object.Module._extensions..node (internal/modules/cjs/loader.js:807: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:692:17) at require (internal/modules/cjs/helpers.js:25: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:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) root@rsha01:~# nodejs -v v10.19.0 root@rsha01:~# npm -v 6.13.4 root@rsha01:~#

binsentsu commented 4 years ago

Looks like the bluetooth-hci-socket library was compiled against another node version. Make sure that commands 'node -v' and 'sudo node -v' return the same node version. You can always recompile: go to dir 'x/am43ctrl/node_modules/@abandonware/bluetooth-hci-socket' and run 'x/am43ctrl/node_modules/.bin/node-pre-gyp rebuild'

reesion commented 4 years ago

I recompiled but now getting a different error.

root@rsha01:/# node -v v8.17.0 root@rsha01:/# sudo node -v v8.17.0 root@rsha01:/# am43ctrl /usr/lib/node_modules/am43-ctrl/src/am43.js:26 static busyDevice = null; ^

SyntaxError: Unexpected token = at createScript (vm.js:80:10) at Object.runInThisContext (vm.js:139:10) at Module._compile (module.js:617:28) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) at Module.require (module.js:597:17) at require (internal/module.js:11:18) at Object. (/usr/lib/node_modules/am43-ctrl/index.js:7:14)

binsentsu commented 4 years ago

Try reinstalling now with following steps

create a directory in which you install non-globally. 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.

reesion commented 4 years ago

Getting the same error as well.

root@rsha01:/home/reesion/blinds/node_modules/.bin# sudo ./am43ctrl /home/reesion/blinds/node_modules/am43-ctrl/src/am43.js:26 static busyDevice = null; ^

SyntaxError: Unexpected token = at createScript (vm.js:80:10) at Object.runInThisContext (vm.js:139:10) at Module._compile (module.js:617:28) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) at Module.require (module.js:597:17) at require (internal/module.js:11:18) at Object. (/home/reesion/blinds/node_modules/am43-ctrl/index.js:7:14)

binsentsu commented 4 years ago

Mayb try with a more recent version of node? Must say I haven't tested it with node 8. Running it myself with node 12.14.1 on a rpi3

reesion commented 4 years ago

ok that worked. I've installed node v12.16.1.

When i try to setup to connect to mqtt in my HA, it just stuck at scanning for 1 device?

I am fairly new to HA and everything. What am i missing or what shall i do next?

root@rsha01:~# am43ctrl 02:0D:BF:12:8C:53 --url mqtt://192.168.1.142 -u user -p pwd am43* scanning for 1 device(s) [ '020DBF128C53' ] +0ms

binsentsu commented 4 years ago

Use lowercase in your Mac adress parameter

reesion commented 4 years ago

I've just tested and it is still stuck in scanning?

am43* scanning for 1 device(s) [ '020dbf128c53' ] +0ms

I can't see any new device under my MQTT integration Any idea?

binsentsu commented 4 years ago

try running the command with sudo: sudo am43ctrl ... Normally super user is needed to access the ble hardware. Also check that the blind controller is not to far from your ble adapter, as the range of these devices is not that great.

reesion commented 4 years ago

I managed to get the device added and it is now showing under my HA via MQTT. However, the buttons does not work?

binsentsu commented 4 years ago

Is the battery percentage visible? From the device page you should see the different entities. image

reesion commented 4 years ago

Yes it is visible and i can see the device. However, it doesn't seem to be responding when i press the buttons?

image

binsentsu commented 4 years ago

Please check the logging in the console of am43ctrl. It should contain some hints.

T-REX-XP commented 4 years ago

Hi. I have got a similar error: Position is undefined((

Снимок экрана 2020-03-30 в 20 56 48

Here is the MQTT message from the topic homeassistant/cover/02dcbc648c06/state:

{
    "id": "02dcbc648c06",
    "lastconnect": "2020-03-30T17:51:29.965Z",
    "lastaction": null,
    "state": "CLOSED",
    "battery": 92,
    "light": 0,
    "position": 100
} 

Here is my env: nodejs -v 12.16.1

binsentsu commented 4 years ago

Hi, from the screenshot, I can see that position is working. The down button is disabled, so the cover knowns it's closed. The current released version does not implement the set_position_topic, that's why the slider bar is disabled. I implemented this feature last week and it's currently undergoing some testing at my place. If you want, you can already test it. It's available in branch feature-position. With this enabled, you can open/close the blind to x% from the home-assistant GUI or automation.

T-REX-XP commented 4 years ago

Yep. Thanks for the quick support.

binsentsu commented 4 years ago

stale