fbacker / broadlink-mqtt-bridge

Bridge Broadlink RM Devices with MQTT and API for e.g. OpenHAB
41 stars 14 forks source link

NODE_ENV value of 'production' did not match any deployment config file names #49

Closed mountain-pitt closed 3 years ago

mountain-pitt commented 3 years ago

I have setup a new Raspberry Pi 4 with openhab 2.5.9 as per instructions from github. also installed Mosquitto. openhab is working correctly and Mosquitto aswell. I have installed broadlink-mqtt-bridge as per instruction. (New Install) Server starts then stops . I have created the local.json file as in previous installation on RPI 3 and restored commands folder from backup. Previous version of broadlink-mqtt-bridge on RPI 3 has been working. I have also setup a fresh install of openhab 2.5.9 on new RPI 3 and still get same errors accross both platforms

The Broadlink controls 30% of home automation. TV, Roller Blinds, Air Con, Heating. Since this upgrade no Broadlink control.

Below is screen capture of install and error on sudo service broadlinkbridge status

[06:40:26] openhabian@openhab:~$ sudo bash -c "$(curl -sL https://raw.githubusercontent.com/fbacker/broadlink-mqtt-bridge/master/installers/raspberry.sh)"


| "\ /" \ / " \ /""\ |" "|" | |" \ (" |" |/"| / ") (. |) :|: |// \ / \ (. __ :|| | || ||.\ \ (: |/ / |: \/|/ / / ) :/' /\ \ |: \ ) ||: | |: ||: . \ | / (| _ \ // (: (__/ /// ' \ (| (_\ ||\ | |. ||. \ . (// \ |: |_) :|: \ / / \ |: :( _|: \ /\ || \ \ |: | \ \ (_____/|_| \)"__(/ _(__/ ___(_|\|_(| _)

Version 2.4.0

Installing helper tools ... Check current Node installation ... Node currently installed. Checking version number. Minimum Node version: v10.13.0 Installed Node version: v12.18.4 No Node.js upgrade necessary. Check current NPM installation ... NPM currently installed. Checking version number. Minimum NPM version: 6.4.1 Installed NPM version: 6.14.6 No NPM upgrade necessary. Cloning ... Cloning into 'broadlink-mqtt-bridge'... remote: Enumerating objects: 37, done. remote: Counting objects: 100% (37/37), done. remote: Compressing objects: 100% (36/36), done. remote: Total 37 (delta 1), reused 33 (delta 0), pack-reused 0 Unpacking objects: 100% (37/37), done. Cloning Done! Upgrade ... HEAD is now at 80c6390 upgrade installer version rm: cannot remove './node_modules': No such file or directory Already up to date. Upgrade Done! Install packages npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"}) npm WARN broadlink-mqtt-bridge@1.0.0 No repository field.

added 325 packages from 213 contributors and audited 574 packages in 72.061s

6 packages are looking for funding run npm fund for details

found 0 vulnerabilities

Dependencies installation Done! Update System Services Broadlink rebooted and ready! [06:42:59] openhabian@openhab:~$

broadlinkbridge.service - Broadlink MQTT Bridge Loaded: loaded (/etc/systemd/system/broadlinkbridge.service; disabled; vendor preset: enabled) Active: active (running) since Thu 2020-09-24 07:19:36 AEST; 5s ago Main PID: 6874 (node) Tasks: 23 (limit: 1551) CGroup: /system.slice/broadlinkbridge.service ├─6874 npm ├─6885 sh -c node -r esm index.js └─6886 node -r esm index.js

Sep 24 07:19:36 openhab systemd[1]: Started Broadlink MQTT Bridge. Sep 24 07:19:38 openhab npm[6874]: > broadlink-mqtt-bridge@1.0.0 production /srv/openhab2-conf/broadlink-mqtt-bridge Sep 24 07:19:38 openhab npm[6874]: > node -r esm index.js Sep 24 07:19:39 openhab npm[6874]: WARNING: NODE_ENV value of 'production' did not match any deployment config file names. Sep 24 07:19:39 openhab npm[6874]: WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode Sep 24 07:19:40 openhab npm[6874]: LOGLEVEL: info

[07:20:32] openhabian@openhab:~$ sudo service broadlinkbridge status ● broadlinkbridge.service - Broadlink MQTT Bridge Loaded: loaded (/etc/systemd/system/broadlinkbridge.service; disabled; vendor preset: enabled) Active: active (running) since Thu 2020-09-24 07:20:30 AEST; 4s ago Main PID: 7016 (node) Tasks: 23 (limit: 1551) CGroup: /system.slice/broadlinkbridge.service ├─7016 npm ├─7030 sh -c node -r esm index.js └─7031 node -r esm index.js

Sep 24 07:20:30 openhab systemd[1]: Started Broadlink MQTT Bridge. Sep 24 07:20:32 openhab npm[7016]: > broadlink-mqtt-bridge@1.0.0 production /srv/openhab2-conf/broadlink-mqtt-bridge Sep 24 07:20:32 openhab npm[7016]: > node -r esm index.js Sep 24 07:20:34 openhab npm[7016]: WARNING: NODE_ENV value of 'production' did not match any deployment config file names. Sep 24 07:20:34 openhab npm[7016]: WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode Sep 24 07:20:34 openhab npm[7016]: LOGLEVEL: info [07:20:35] openhabian@openhab:~$ sudo service broadlinkbridge status ● broadlinkbridge.service - Broadlink MQTT Bridge Loaded: loaded (/etc/systemd/system/broadlinkbridge.service; disabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Thu 2020-09-24 07:20:38 AEST; 3s ago Process: 7016 ExecStart=/usr/bin/npm run production (code=exited, status=1/FAILURE) Main PID: 7016 (code=exited, status=1/FAILURE) [07:20:42] openhabian@openhab:~$

I keep checking sudo service broadlinkbridge status And it appears it keeps restarting and eventually goes dead.

I have re built both Raspberry Pi 3 and 4 several times and can not figure out the problem

fbacker commented 3 years ago

Lets try this and see what kind of log output we can get.

  1. Turn of current ```sudo service broadlinkbridge stop````
  2. Go into the application folder cd /srv/openhab2-conf/broadlink-mqtt-bridge
  3. run npm run production.

Please post the output.

Have you been running previous version of broadlink? The config file can be a little changed. What happens if you remove your 'local.json' config. Does it start then? Can you access anything at http://192.168.91.20:3000/

mountain-pitt commented 3 years ago
____  ____  ___  ____  / / / /   |  / __ )(_)___ _____
       / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  / / __ `/ __ \
      / /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ / / /_/ / / / /
      \____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/_/\__,_/_/ /_/
          /_/
              openHAB 2.5.8-1 (Release Build)

Looking for a place to get started? Check out 'sudo openhabian-config' and the documentation at https://www.openhab.org/docs/installation/openhabian.html The openHAB dashboard can be reached at http://openhab:8080 To interact with openHAB on the command line, execute: 'openhab-cli --help'

[16:58:59] openhabian@openhab:~$ sudo service broadlinkbridge status ● broadlinkbridge.service - Broadlink MQTT Bridge Loaded: loaded (/etc/systemd/system/broadlinkbridge.service; disabled; vendor preset: enabled) Active: inactive (dead) [16:59:59] openhabian@openhab:~$ npm run production. npm ERR! code ENOENT npm ERR! syscall open npm ERR! path /home/openhabian/package.json npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open '/home/openhabian/package.json' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent

npm ERR! A complete log of this run can be found in: npm ERR! /home/openhabian/.npm/_logs/2020-09-30T07_00_12_120Z-debug.log [17:00:12] openhabian@openhab:~$

mountain-pitt commented 3 years ago

This is a brand new install all fresh on Raspberry Pi 4, I left the json files as is. and have not created local.json local json needs MQTT id and password set and also I will be using port 3005 for GUI and 3001 port for logging (Default) port 3000 is default for Grafana which I am using. Looking at the output above NPM can not find a package.json ??

mountain-pitt commented 3 years ago

I coppied the package.json file to the home directoy and re ran npm run production results below

[17:20:08] openhabian@openhab:~$ npm run production

broadlink-mqtt-bridge@1.0.0 production /home/openhabian node -r esm index.js

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

Error: Cannot find module 'esm' Require stack:

npm ERR! A complete log of this run can be found in: npm ERR! /home/openhabian/.npm/_logs/2020-09-30T07_20_15_056Z-debug.log [17:20:15] openhabian@openhab:~$

mountain-pitt commented 3 years ago

Previous run attempt was executed from home directory not from /srv/openhab2-conf/broadlink-mqtt-bridge. Changed to /srv/openhab2-conf/broadlink-mqtt-bridge and RUN.

[05:52:06] openhabian@openhab:/srv/openhab2-conf/broadlink-mqtt-bridge$ npm run production

broadlink-mqtt-bridge@1.0.0 production /srv/openhab2-conf/broadlink-mqtt-bridge node -r esm index.js

LOGLEVEL: info 2020-09-30 19:53:18 [info]: Starting Broadlink MQTT NodeJS Application 2020-09-30 19:53:18 [error]: not happy Cannot read property 'length' of undefined { "stack": "TypeError: Cannot read property 'length' of undefined\n at /srv/openhab2-conf/broadlink-mqtt-bridge/src/actions/files.js:135:25" } 2020-09-30 19:53:18 [info]: Device found model: Broadlink RM2 Pro Plus v2, id: 34ea348efa7a, ip: 192.168.0.49 2020-09-30 19:53:43 [info]: Broadlink Discovery completed. Found 2 devices. 2020-09-30 19:55:00 [info]: Clear current devicelist and rescan 2020-09-30 19:55:00 [info]: Device found model: Broadlink RM2 Pro Plus v2, id: 34ea348efa7a, ip: 192.168.0.49

I can access the GUI now at 192.168.0.100:3005 The Log as the following

[05:52:06] openhabian@openhab:/srv/openhab2-conf/broadlink-mqtt-bridge$ npm run production

broadlink-mqtt-bridge@1.0.0 production /srv/openhab2-conf/broadlink-mqtt-bridge node -r esm index.js

LOGLEVEL: info 2020-09-30 19:53:18 [info]: Starting Broadlink MQTT NodeJS Application 2020-09-30 19:53:18 [error]: not happy Cannot read property 'length' of undefined { "stack": "TypeError: Cannot read property 'length' of undefined\n at /srv/openhab2-conf/broadlink-mqtt-bridge/src/actions/files.js:135:25" } 2020-09-30 19:53:18 [info]: Device found model: Broadlink RM2 Pro Plus v2, id: 34ea348efa7a, ip: 192.168.0.49 2020-09-30 19:53:43 [info]: Broadlink Discovery completed. Found 2 devices. 2020-09-30 19:55:00 [info]: Clear current devicelist and rescan 2020-09-30 19:55:00 [info]: Device found model: Broadlink RM2 Pro Plus v2, id: 34ea348efa7a, ip: 192.168.0.49 2020-09-30 19:55:15 [error]: MQTT failed on message 'Error: Topic is too short, should contain broadcast base e.g. 'broadlink/' with following device and action. e.g. broadlink/tv/samsung/power' 2020-09-30 19:55:25 [info]: Broadlink Discovery completed. Found 2 devices.

I attempt to PLAY or RECORD and error window, Reguested Device not found.

mountain-pitt commented 3 years ago

I STOP and Then RUN again and the following

[06:15:07] openhabian@openhab:/srv/openhab2-conf/broadlink-mqtt-bridge$ npm run production

broadlink-mqtt-bridge@1.0.0 production /srv/openhab2-conf/broadlink-mqtt-bridge node -r esm index.js

LOGLEVEL: info 2020-09-30 20:15:30 [info]: Starting Broadlink MQTT NodeJS Application TypeError: log is not a function at Broadlink.addDevice (/srv/openhab2-conf/broadlink-mqtt-bridge/node_modules/broadlinkjs-rm/index.js:214:7) at Broadlink.onMessage (/srv/openhab2-conf/broadlink-mqtt-bridge/node_modules/broadlinkjs-rm/index.js:183:10) at Socket.emit (events.js:314:20) at Socket.EventEmitter.emit (domain.js:486:12) at UDP.onMessage [as onmessage] (dgram.js:919:8) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! broadlink-mqtt-bridge@1.0.0 production: node -r esm index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the broadlink-mqtt-bridge@1.0.0 production script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/openhabian/.npm/_logs/2020-09-30T20_15_30_923Z-debug.log [06:15:30] openhabian@openhab:/srv/openhab2-conf/broadlink-mqtt-bridge$

fbacker commented 3 years ago

Please try to create the folder 'commands' inside /srv/openhab2-conf/broadlink-mqtt-bridge/ and restart. That should probably solve the startup issue.

When it comes to the start/record, Please make sure you are using full paths. Look at the error MQTT failed on message 'Error: Topic is too short, should contain broadcast base e.g. 'broadlink/' with ..... It means that topic should start with broadlink/. Read the documentation for help on structrure https://github.com/fbacker/broadlink-mqtt-bridge/wiki/Recording

mountain-pitt commented 3 years ago

the command dirctroy is there with previous command listed. When accessing via GUI you can see the commands etc. I select blinds/office/up and the correct fields are displayed on the right with broadlink\blinds\office as topic and message is up also it as the device set to scanned ID. Go to press PLAY and error comes up. Reguested device not found.

It does come up on the left of GUI found 2 devices . ! is listed as

1 . Broadlink RM2 Pro Plus v2 192.168.0.49 ID: 34ea348efa7a

  1. undefined 192.168.0.49 ID: undefined

If I select option 1 above thats when error comes up if i select option 2 and leave the device blank on the right side MQTT section blind goes up and down all working

Also the log section below can not be found error in GUI

fbacker commented 3 years ago

When no device is selected, it will send to every device it has found. Somehow it shows your device twice (same ip). If you don't specify any device in openhab it should work for you.

Based on your error it feels like you are running an older version.

I've made some adjustments. Please try to run the auto upgrade script again. When done it should run version 2.5.0. You can check the version in GUI (top left).

mountain-pitt commented 3 years ago

Have Upgraded to 2.5.0 (Showing top left GUI) Shows only one device on left

Broadlink RM2 Pro Plus v2 192.168.0.49 ID: 34ea348efa7a

It still sows found 2 devices in log below and the MQTT too short keeps poping up in log. I select the commands/blinds/office up with the device selected still comes up with device selected not found. If I leave the device blank all works . The ftail log is working now though. I stopped the service as above and RUN npm run production to see error as below

npm run production

broadlink-mqtt-bridge@1.0.0 production /srv/openhab2-conf/broadlink-mqtt-bridge node -r esm index.js

LOGLEVEL: info 2020-10-03 19:09:55 [info]: Starting Broadlink MQTT NodeJS Application Error: listen EADDRINUSE: address already in use :::3005 at Server.setupListenHandle [as _listen2] (net.js:1317:16) at listenInCluster (net.js:1365:12) at Server.listen (net.js:1451:7) at WebserverClass.startServer (/srv/openhab2-conf/broadlink-mqtt-bridge/src/web.js:293:17) at run (/srv/openhab2-conf/broadlink-mqtt-bridge/index.js:9:13) at Object. (/srv/openhab2-conf/broadlink-mqtt-bridge/index.js:15:1) at Generator.next () Emitted 'error' event on Server instance at: at emitErrorNT (net.js:1344:8) at processTicksAndRejections (internal/process/task_queues.js:80:21) at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:62:3) at /srv/openhab2-conf/broadlink-mqtt-bridge/node_modules/esm/esm.js:1:34535 at /srv/openhab2-conf/broadlink-mqtt-bridge/node_modules/esm/esm.js:1:34176 at process. (/srv/openhab2-conf/broadlink-mqtt-bridge/node_modules/esm/esm.js:1:34506) at Function. (/srv/openhab2-conf/broadlink-mqtt-bridge/node_modules/esm/esm.js:1:296856) at Function. (/srv/openhab2-conf/broadlink-mqtt-bridge/node_modules/esm/esm.js:1:296555) at Function. (/srv/openhab2-conf/broadlink-mqtt-bridge/node_modules/esm/esm.js:1:284879) at Object.apply (/srv/openhab2-conf/broadlink-mqtt-bridge/node_modules/esm/esm.js:1:199341) { code: 'EADDRINUSE', errno: -98, syscall: 'listen', address: '::', port: 3005 } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! broadlink-mqtt-bridge@1.0.0 production: node -r esm index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the broadlink-mqtt-bridge@1.0.0 production script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/openhabian/.npm/_logs/2020-10-03T19_09_55_458Z-debug.log [06:09:55] openhabian@openhab:/srv/openhab2-conf/broadlink-mqtt-bridge$

I did recreate local.json after upgrade with mqtt id and password also port 3005 as 3000 is running grafana

fbacker commented 3 years ago

address in use. Something already running on port 3005. Stop the service if it's running. If that doesn't help restart the rpi.

mountain-pitt commented 3 years ago

Have restarted RPI, the port conflict is cleared, still getting original problems MQTT topic too short. (this is in log even when no operation has been selected) Requested device not found. (if clear device name operation works)

mountain-pitt commented 3 years ago

I am going to do a complete rebuild of openhab on new sd card with latest and see if this fixes problems

fbacker commented 3 years ago

Don't know if that will fix the issue.

Can you post an image of the gui when you have selected the device and typed the topic.

fbacker commented 3 years ago

Might be that you have a too short path for the items you are going to use.

Try to move the files into a folder. For example this is my ceiling fan.

image

If I would run broadlink/fans I get too short.

fbacker commented 3 years ago

Another example is here. If i select the device. The device get id 780f7717ea86. Same as it is in the devices list. If I would change this id to something else it would complain that it can't find the device.

image

mountain-pitt commented 3 years ago

Have done a complete rebuild. Still getting selected device not found after selecting the device. MQTT Broadlink Bridge 1st

mountain-pitt commented 3 years ago

I noticed it is finding 2 devices, there is only one device on network. Could this be affecting operation?

fbacker commented 3 years ago

It's strange that it finds 2 devices but only shows when finding one. That's probably why you are getting the error.

Have you tried restarting the broadlink device? Wait until it has booted and then hit 'rescan devices'.

But if you only have one broadlink device it's fine to not select a device when you run the scripts. I'm doing that myself.

mountain-pitt commented 3 years ago

I noticed it is finding 2 devices, there is only one device on network. Could this be affecting operation?

mountain-pitt commented 3 years ago

Restarted. Still comes up with 2 devices found. Can run a command without device selected ok BUT you can not record any new commands. Needs to have a device selected. When selected still comes up with device not found etc on a record option

fbacker commented 3 years ago

Tried to look a little at the code. As long the device has the same mac address it shouldn't have any problems finding multiple of the same. Just overwrites it. Can we find any more logs if you set the config file to 'debug'.

"logging":{
    "level": "debug"
  }

Sidenote: I'm currently writing all my home automation logic from 'openhab' into 'home assistant'. Will run the broadlink implementation that exists in that system. That will result me abandoning this project.

fbacker commented 3 years ago

@mountain-pitt I finally got same issue that you have. After a while I think the problem is solved. Please upgrade to latest version.

NOTE: this will upgrade to v3, please read what that does. As major changes the installation script should be run from the parent directory of your broadlink installation (this makes it possible to install on any device, not just openhab rpi). It will also want base64 files, there's a converted to get bin -> txt files for the commands. But until v4 will be released, if it doesn't find the txt file it will automatically look for the bin file.