[Alpha] Harmony hub instant status updates using node.js app


#42

Got the same thing, unfortunately.


#43

Are you doing this inside a directory? So I have a /share/harmony directory where I install everything.


#44

Just inside of /home/pi. I will create a folder and try inside of there.
EDIT: Created a harmony folder, changed into that directory, ran the command. Same errors.

Also, to verify, I'm not supposed to download something before running that right? It is my understanding that npm would just go out and download what is needed.


#45

Hmmm this should just work. Very odd you are having issues.

One last item:

  • Change into a directory that PI has write/execute
  • run: "npm install harmonyhubjs-client --save" without sudo or su
    • this should deploy the client into that directory

#46

That's exactly what I'm doing, for the most part. I tried while logged in with Pi and after sudo.

See output for both tries below. You will see that I tried to run the command while in the /home/pi/harmony directory.

First try, after sudo:

root@weewx:/home/pi/harmony# npm install harmonyhubjs-client --save
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN pi No description
npm WARN pi No repository field.
npm WARN pi No README data
npm WARN pi No license field.

  • harmonyhubjs-client@1.1.10
    updated 1 package in 6.168s

Second try while only being logged in as Pi

pi@weewx:~/harmony $ npm install harmonyhubjs-client --save
npm WARN checkPermissions Missing write access to /home/pi/node_modules/harmonyhubjs-client
npm WARN checkPermissions Missing write access to /home/pi/node_modules
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN pi No description
npm WARN pi No repository field.
npm WARN pi No README data
npm WARN pi No license field.

npm ERR! path /home/pi/node_modules/harmonyhubjs-client
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/home/pi/node_modules/harmonyhubjs-client'
npm ERR! { [Error: EACCES: permission denied, access '/home/pi/node_modules/harmonyhubjs-client']
npm ERR! stack:
npm ERR! "Error: EACCES: permission denied, access '/home/pi/node_modules/harmonyhubjs-client'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/home/pi/node_modules/harmonyhubjs-client' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2018-11-29T16_21_20_565Z-debug.log


#47

You don't have write access to the /home/pi/node_modules

Do the following:

  1. sudo rmdir -r /home/pi/node_modules
  2. sudo mkdir -m 1777 /share
  3. sudo mkdir /share/harmony
  4. cd /share/harmony
  5. npm install harmonyhubjs-client --save

#48

Further, but not completely sure if it fully installed? Also, thank you for your help!

pi@weewx:/share/harmony $ npm install harmonyhubjs-client --save
npm WARN deprecated node-xmpp-stanza@1.1.0: use @xmpp/xml package https://www.npmjs.com/package/@xmpp/xml
npm WARN deprecated node-xmpp-jid@2.3.0: use @xmpp/jid package https://www.npmjs.com/package/@xmpp/jid
npm WARN saveError ENOENT: no such file or directory, open '/share/harmony/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/share/harmony/package.json'
npm WARN harmony No description
npm WARN harmony No repository field.
npm WARN harmony No README data
npm WARN harmony No license field.

  • harmonyhubjs-client@1.1.10
    added 125 packages from 226 contributors in 17.962s
    pi@weewx:/share/harmony $ ls -la
    total 48
    drwxr-xr-x 3 pi pi 4096 Nov 29 10:42 .
    drwxrwxrwt 3 root root 4096 Nov 29 10:39 ..
    drwxr-xr-x 120 pi pi 4096 Nov 29 10:42 node_modules
    -rw-r--r-- 1 pi pi 33192 Nov 29 10:42 package-lock.json

#49

That is the correct "error" messages you want to see. Now just copy the code and it should work. In @destructure00's code you will need to modify line #1 with what I posted earlier. Let me know your progress. :slight_smile:


#50

Wow, I think I finally got it running! I'll have to test once I'm home. Next step is getting it to run as a service.

I'll let you know how my testing goes this evening.

Thank you so much for the help!


#51

Things are working!

On to the next task - running it as a service. I have the .service file created and located in /etc/systemd/system. The service appears to start, but I am seeing this:

pi@weewx:~ $ sudo service harmonynode status
● harmonynode.service - Harmony Node.JS
Loaded: loaded (/etc/systemd/system/harmonynode.service; disabled)
Active: active (running) since Thu 2018-11-29 20:30:15 CST; 1min 54s ago
Main PID: 31013 (node)
CGroup: /system.slice/harmonynode.service
└─31013 /usr/bin/node /share/harmony/node_modules/harmonyhubjs-client/client.js EliteHub

Nov 29 20:30:15 weewx systemd[1]: Started Harmony Node.JS.
Nov 29 20:30:17 weewx node[31013]: Found IP adress 192.168.5.36 for hub EliteHub
Nov 29 20:30:17 weewx node[31013]: Starting Client...
Nov 29 20:30:22 weewx node[31013]: Lost connection to hub (Thu Nov 29 2018 20:30:22 GMT-0600 (CST))
Nov 29 20:30:22 weewx node[31013]: Restarting...

Any idea why it loses its connection?


#52

I haven't been able to figure that one out. I have two Harmony hubs, one loses connection a couple times a day and the other maybe once or twice a week. Not sure what the difference is, but I added the logic to reconnect. Previously it would just end the process.


#53

So am I safe to assume that it actually did restart and reconnect after? It hasn't updated saying connected or anything when I check the service status.


#54

I have mine running in a LXTerminal window and it logs to console, here's what I normally see:

I can't comment on running this as a service since I haven't taken that step yet. Maybe @aaron can answer that one.

Which post did you pull the code from?


#55

I believe post 25. It's possible I'm missing the reconnect logic you added.

EDIT: Just checked my client.js file. I see the harmonyClient.end line in there. Doesn't seem like it is working though. Just reviewed my syslog and it just stops after it says restarting.


#56

I'm going to have to defer to @aaron, sorry. I know just enough to be dangerous but not quite enough to be helpful :rofl:


#57

You don’t need to use system.d. Leverage forever-service. Much easier to use.


#58

I know this is probably asking quite a lot, but would anyone be willing to provide a walkthrough on how to get this installed and set up on a fresh Raspberry Pi? I'm just savvy enough to follow directions, but not quite enough to piece together exactly what I need to do based on the info from this thread.


#59

Great question! @destructure00 and myself are working on some documentation for this. Might be a week as I am very busy with work and family responsibilities.

I would follow this article on getting node.js setup correctly:

Then you should be able to follow my steps above.


#60

I managed to get node installed, but got lost shortly after that.


#61

@murray.sean.d

So where you at in this process?