Zwave JS UI Server Build and upgrade without docker

That was the same issue I ran into it wouldn’t start because npm was missing the NVM the ts node the response I got from the experts was what I am am doing is outside of their scope of help I stumbled on to the link to install it on my VM now just trying to get it to automatically start when I reboot, typical response is just use docker , since I also have a pi that I use to pair the security devices that the stick can’t do I will have to figure out how as well

node-zwave-js is just a library, there is no way to use it directly with HA.

You either need to install zwave-js-server, or zwavejs2mqtt, which use the library.

Aha! - a library. Seems I was trying to launch the unlaunchable :slight_smile:
In addition to avoding docker, I am trying to get rid if the reliance on MQTT at least for my zwave controller. After a bit of reading, I managed to get zwave-js-server installed from scratch like this, if this might help anyone:

Prerequisites:
#Install ts-node and typescript (info here)
sudo npm install -g ts-node
sudo npm install -g typescript
#install git tool if not present
sudo apt install git

Installation:
#go to homedir and pull down zwave-js-server.
cd
git clone [email protected]:zwave-js/zwave-js-server.git
cd zwave2mqtt

launch
ts-node src/bin/server.ts /dev/ttyACM0

It launches all well and good:

However I’m a little stuck on the following:

1) What port is the web admin interface supposed to run on?
According to this blog, it’s supposed to be port 8091, yet it might be a docker thing, not sure. I’m presuming that port 3000 isn’t it, as that’s the websockets port where HA would be talking to wave-js-server?

2) Where is the configuration file supposed to go and what is it supposed to look like?
The template linked in the repo is a bit lacking in detail. For exaple, how exactly is the network key supposed to be formatted? ddeeaaddbbeeaaff…etc or with 0x, spaces and/or commas? Would be very grateful if somebody could post an example

Any help appreciated

1 Like

zwave-js-server just exposes the zwave-js API over a websocket, it doesn’t provide a web admin interface by itself.

zwavejs2mqtt does provide such a web admin tool, in addition to the MQTT stuff. Despite its name, you can turn off / ignore the MQTT part and simply use it as a web admin tool. It uses zwave-js under the hood and also provides the websocket API that the new HA integration connects to.

Oh and despite everyone screaming Docker Docker Docker all around, you can also use it without (thankfully).

Well, that explains it then, bang your head against the wall enough times you’ll eventually have a window, lol I’ll give it a try! As there’s not much in terms of installation instructions, I presume it’s just a matter of pulling the repo and starting it with npm start?

As for docker…

Lol, yeah. Docker is a nice tool - for certain jobs. Not so much for others.

Well yeah you need to build it first. There’s some basic info in docs/getting-started, scroll past the Docker and Kubernetes sections to the end. The prepackaged version stuffs everything into a single large executable for x86-64 platforms so you don’t need NodeJS and deps. For ARM you can just use NPM.

got quite the education on this write up

Okay, so far so good. I pulled the zwave2mqtt, built and ran it as per below, however there seems to be a mismatch with some folders:

cd
git clone [email protected]:zwave-js/zwavejs2mqtt.git
cd zwavejs2mqtt
npm i
#get coffee
npm start

Server comes up nicely, however…

I guess it’s yelling at me above as the configuration has not been set through the web interface yet, however when I browse to the admin interface on port 8091 on a browser, I get this little gem.

Error: ENOENT: no such file or directory, scandir '/home/pi/zwavejs2mqtt/dist/static/css'
    at Object.readdirSync (fs.js:955:3)
    at findFiles (/home/pi/zwavejs2mqtt/lib/renderIndex.js:9:26)
    at module.exports (/home/pi/zwavejs2mqtt/lib/renderIndex.js:27:26)
    at Layer.handle [as handle_request] (/home/pi/zwavejs2mqtt/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/pi/zwavejs2mqtt/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/pi/zwavejs2mqtt/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/pi/zwavejs2mqtt/node_modules/express/lib/router/layer.js:95:5)
    at /home/pi/zwavejs2mqtt/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/home/pi/zwavejs2mqtt/node_modules/express/lib/router/index.js:335:12)
    at next (/home/pi/zwavejs2mqtt/node_modules/express/lib/router/index.js:275:10)
    at /home/pi/zwavejs2mqtt/node_modules/connect-history-api-fallback/lib/index.js:85:5
    at Layer.handle [as handle_request] (/home/pi/zwavejs2mqtt/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/home/pi/zwavejs2mqtt/node_modules/express/lib/router/index.js:317:13)
    at /home/pi/zwavejs2mqtt/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/home/pi/zwavejs2mqtt/node_modules/express/lib/router/index.js:335:12)
    at next (/home/pi/zwavejs2mqtt/node_modules/express/lib/router/index.js:275:10)

Checking the filesystem, that path does indeed not exist. For the giggles I tried creating the missing folder, but while I eliminated the error, all I’m getting is a blank web page. The only static folder in the package is under /home/pi/zwavejs2mqtt/static, yet it does not contain the css folder referenced above, only the website favicon. I’ve tried checking the install with npm doctor, and a npm clean-install. Neither seem to have any effect.

Update: Think I got it working, yay me. In /home/pi/zwavejs2mqtt there’s a script called package.sh. I ran it and answered yes to rebuild the package. After munching on this for a while it prompts for architecture. On my pi 3b+ it reports being arm71, so I chose the closest one: option 2: arm7:

image

However it seems to fail with a missing command pkg. Not sure what that’s about? Anyhow I noticed it had now created the missing dist/ folder and necessary files, so I took a chance and fired it up again with an ‘npm start’ lo and behold, the web interface is now up. PS: later I learned I might have accomplished the same with ‘npm build run’

ARM and x86-64 does stuff different on making zwave-js work

ARM and x86-64 does stuff different on making zwave-js work

The package.sh is for making prepackaged binaries for any supported arch, like the one they have on their site for x64. You don’t really need this. But as a side effect, package.sh also builds the application first. Did you call npm run build before npm i ? In any case, good to know it works for you. Did you manage the have the HA integration talk to it ?

‘your.service’ is a placeholder, you’re supposed to substitute it with the actual name of your service…

Yep - Captain Hindsight at your service sir; that’s what I should have done! :wink:
So yes, albeit rather haphazardly I got it up and running almost by accident.
Anyway I updated my notes above.

The HA integration works nicely. The trick for me was when adding the Z-wave JS integration to HA, not add the supervisor component. Otherwise it seems to assume that Zwave JS is running on HassOS and you never get prompted to enter your pi’s ip address:3000

I was working on getting ZwaveJS to run at boot. I understand some people like setting up a service, however I prefer pm2 as it provides a lot of cool monitoring and control features and I was using it for other things already. It should be said I don’t need to use the pm2 paid/cloud/plus components. This is how I set mine up if it’s useful to anyone:

#install pm2
sudo npm install -g pm2
#set it to run at start. running the below may echo a line out for you to run 
sudo pm2 startup

I have an pm2 configuration json file to launch some other things. This is also super convenient if I want to blow the entire configuration out and reload it. It happens.

pm2 start apps.json  # as below

However I’m still trying to figure out which script actually starts ZwaveJS (looks at first glance to be app.js in the zwavejs2mqtt folder, yet it doesn’t launch/initialize the package correctly; ascii logo never comes up and it never hails on the admin port).

Below is what my pm2 apps.json file looks like, where the ZwaveJS section does not work:

{
        "apps": [
                {
                        "name": "njsPC 6.1.1",
                        "script": "./dist/app.js",
                        "instances": 1,
                        "cwd": "/home/pi/controller.611"
                },
                {
                        "name": "njsPC Web 6.1.0",
                        "script": "./dist/Server.js",
                        "instances": 1,
                        "cwd": "/home/pi/webclient.610",
                        "env":  {
                                "NODE_ENV": "production node dist/Server.js"
                        }
                },
                {
                        "name": "ZwaveJS2MQTT",
                        "script": "./app.js",
                        "instances": 1,
                        "cwd": "/home/pi/zwavejs2mqtt"
                }

        ]
}

I did manage to work around this by going into the zwavejs2mqtt folder and launching it with pm2 directly:

pm2 --name zwavejs2mqtt start npm -- start
pm2 save # ensures the package spins up automagically at next boot

While this works, it still kinda irks my OCD that my configuration file is out of whack. If you have any suggestions on this I’m all ears. As you’ve probably figured out I’m flying by the seat of my pants here :wink:

I’m not at all familiar with pm2, but why is the script command for “ZwaveJS2mqtt” just the plain ./app.js? Shouldn’t it run npm start or node bin/www instead?

Yes, the startup script is bin/www, which imports app.js and calls startServer.

I’m not familiar with pm2 either.

@ MaxVonEvil, it’s great to know that the HA integration works well with it. I played around with the bare zwave-js API a little out of curiosity, but I haven’t dared the jump from a stable OZW 1.4 into a beta integration on a production system yet :slightly_smiling_face: Might do it sooner than planned though.

that is where I am at still on 1.4 just built a VM to be my zwavejs server and and new VM for a fresh HA once I get the bugs worked out of the zwavejs to behave like my production I will migrate

currently the issues that is stopping me

  1. ability to have it autostart on boot
  2. my Go control garage door openers to behave proper on HA through Zwavejs

Well, post your service log as pointed out above and we’ll see if there’s anything interesting in there that could help us find out why it doesn’t work for you.

For starters, try to run your service manually first:

sudo service thingy start
sudo service thingy status

replace thingy by the name of your service (without the .service extension).

ARM and x86-64 does stuff different on making zwave-js work

As I said in my reply, you needed to add your own service name to the log query. Try the commands I posted just above.

ARM and x86-64 does stuff different on making zwave-js work