[OBSOLETE] LutronPro Caseta v1.0

Any chance that anyone can help me with my *.service file in order to get this running as a daemon with systemd on my Raspberry Pi 3? I use the systemd service daemons when I can so that if I need to restart the pi then everything will boot up on its own but I’m having trouble with this one because it’s not liking my OAuth code when I run it as a daemon (but it works fine when I just run it from the terminal command on the same system with “/usr/bin/node /home/pi/Downloads/lutronpro-master/runNodeServer.js”). Here is what my lutronpro.service file looks like so far. I must be missing something simple. I’m pretty new to all this:

[Unit]
Description=runNodeServer.js daemon - For Lutron Pico Remotes
After=syslog.target network-online.target

[Service]
Type=simple
User=pi
ExecStart=/usr/bin/node /home/pi/Downloads/lutronpro-master/runNodeServer.js
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

@njschwartz @BHO Thanks for the advice. I’ve got my Pro hub on order and it’ll be here on Monday. I’m totally in this for the Pico remote functionality because I’ve got 8 Pico remotes that I want to use for some automated windows that I built with @jetpuf SmartThings Automated Blinds project. (Super cool if you want to check it out). And like I said, I’ve got the virtual pico remote working perfectly to control the blinds with your project and WebCoRe pistons but it’s just not working with the real pico even though ST is picking up on the Pico. I think the Pro hub should fix all that. Can’t wait to add these remotes to the project so my wife will be cool with our robotic windows (she hates Alexa).

Awesome I’ll take a look at the update this weekend thanks

@njschwartz looks like its working however when i release after a held event it returns a null. Is that what you were expecting or should it send a released?

1ecfb3e4-02fd-47cc-9288-d42cedeb48f3 5:59:12 PM: debug In button event 4null
1ecfb3e4-02fd-47cc-9288-d42cedeb48f3 5:59:12 PM: debug 4
1ecfb3e4-02fd-47cc-9288-d42cedeb48f3 5:59:12 PM: debug In button event 4held
1ecfb3e4-02fd-47cc-9288-d42cedeb48f3 5:59:12 PM: debug 4
1ecfb3e4-02fd-47cc-9288-d42cedeb48f3 5:59:11 PM: debug In button event 4held
1ecfb3e4-02fd-47cc-9288-d42cedeb48f3 5:59:11 PM: debug 4
1ecfb3e4-02fd-47cc-9288-d42cedeb48f3 5:59:10 PM: debug In button event 4held

Also can you share with me your piston to control a light with it?

Cheers

Any updates on getting this to work or a guide for Windows? :slight_smile:

I seem to be successful using pm2 and ITS auto-restart feature to bring this app back up after pi shutdown and reboot. No cert problems… so far. There seems to be a number of other useful features in pm2 including flexible logging options and watchdogging and general process supervision for node stuff, so you might have a look.

Let’s see, what did I do? This was on a Pi Zero running Raspbian latest stable:
sudo npm install pm2 -g
pm2 start ~/lutronpro/runNodeServer.js (note this was already set up and working previously!)
pm2 startup
—>> (then copy-and-paste-and-run the generated startup setting script)
pm2 save

and I think that was it. To show live logging for this app again, just:
pm2 log runNodeServer

and you can set up file watchdogging to restart if, for example, ~/lutronpro/runNodeServer.js is updated. And lots of other stuff I haven’t yet played with. But the important thing is, it seems to restart successfully after reboot.

2 Likes

I need some more help PLEASE guys. I’m sorry I can’t get this going. I got my Pro hub in today and I went through the process of removing the regular hub from my account and adding the pro hub and then adding all my picos and switches and then I updated my IP addresses and OAuth code in the runNodeServer.js file and then I enabled Telnet Support under Integration in the Lutron app and then I get the following error in terminal when I run it:

pi@jacobwtyler:~ $ node /usr/lib/node_modules/lutronpro/runNodeServer.js
Listening on port 5000…
appCert exists! YEAH!!
192.168.55.28
About to exit with code: 1
events.js:163
throw er; // Unhandled ‘error’ event
^

Error: socket hang up
at TLSSocket.onHangUp (_tls_wrap.js:1120:19)
at Object.onceWrapper (events.js:293:19)
at emitNone (events.js:91:20)
at TLSSocket.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)

I have no idea what I might have done different. I tried changing the email address and getting new OAuth code and I tried removing the npm lutronpro installation and reinstalling it too. I had it working with the standard hub although I believe it was throwing some similar errors up before loading successfully.

I will share it in just a bit. And I’ll check into the released event too. :smile:

@mmohoney I’m very close on the windows front. I have to use a different package because for whatever reason I cannot run the openssl commands the same way I do I’m Linux based machines. Should have something ready soon.

@jacobwtyler @BHO. I agree that pm2 seems to be the easiest option. It’s what I have used and it works well.

@jacobwtyler I think your issues is you need new certs because the ones you are using are from the old hub. Delete then all and then restart the app and I’ll bet it works. Let me know!

How do I delete the certificates. I tried a bunch of stuff including installing lutronpro globally with -g and installing it as a super user with sudo and moving it to a new directory and eventually I got to this error now. It does give me a long string and looks to authenticate the OAuth the first time I run it but always ends with this error. Is it a permissions issue?

pi@jacobwtyler:~/node_modules/lutronpro $ sudo node runNodeServer.js
Listening on port 5000…
appCert exists! YEAH!!
192.168.55.28
fs.js:584
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^

Error: ENOENT: no such file or directory, open 'private.pem’
at Object.fs.openSync (fs.js:584:18)
at Object.fs.readFileSync (fs.js:491:33)
at Hub.initalize (/home/pi/node_modules/lutronpro/lutronpro.js:593:15)
at /home/pi/node_modules/lutronpro/lutronpro.js:686:21
at /home/pi/node_modules/lutronpro/lutronpro.js:51:4
at FSReqWrap.oncomplete (fs.js:114:15)

Sorry I should have given more details. So when the app runs it creates 4 cert files as part of setting up the initial connection. The files are private.pem, my-csr.pem, appCert, and localCert. These are create in the same folder where the lutronpro app is installed. This is likely inside a folder called node_modules/lutronpro. Find them and delete them all then rerun the app and let me know what happens.

So it does look like it should work as expected. I don’t have it send a released event because I didn’t see the point. Basically it will just send the held event over and over again until released and then it will stop sending that event. ST doesn’t need to know specifically that the button was released.

Below are a couple of pistons showing how to use the ramping feature. The 1st one is just a really simplified example of adjusting a light. You would need to add the dimming piece, but it should be pretty clear how. Also note that that piston uses button 1 to ramp up which I wouldn’t recommend due to the timeout issues I mentioned above. Use buttons 4 and 5 and it will work great. The second example is something I set up for my sonos. The volume levels are basically the same as you would use for dimming. Let me know if that helps or if you run into any issues.


1 Like

Hi nate thanks for pointing me to here.
i seen the post on friday but i am doing home renos so i only had time today to try it out.
I did the steps that wore posted but not 100% sure where i copy paste the runNodeServer.js to. as in which Dir. Also a little mixed up with runServer.js. Is it the same file or diffrent then Runnode?
Node installed fine

npm install lutronpro installed came up with

pi@raspberrypi:~ $ sudo npm install lutronpro
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.

not sure why but i tryed the rest of the steps

copyed the code and change the ip address runnodeServer and Oauthcode. when i fun it i get this error
I did try coping runnode to /home/pi/node_modules/lutronpro then ran it

module.js:538
throw err;
^

Error: Cannot find module 'node-forge’
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object. (/home/pi/node_modules/lutronpro/lutronpro.js:12:13)
at Module._compile (module.js:635:30)
at Object.Module._extensions…js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object. (/home/pi/node_modules/runNodeServer.js:1:79)
at Module._compile (module.js:635:30)
at Object.Module._extensions…js (module.js:646:10)
at Module.load (module.js:554:32)

Any help would be appreciated Thanks

@Buzzshot
Run npm install node-forge I had the same issue.

thank you for the quick reply i tried it but no dice. do i have to be in the lutron dir then type it?
this is what i get now

pi@raspberrypi:~ $ sudo node runNodeServer.js
Listening on port 5000…
events.js:183
throw er; // Unhandled ‘error’ event
^

Error: listen EADDRINUSE :::5000
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at Server.listen (net.js:1476:7)
at Function.listen (/home/pi/node_modules/express/lib/application.js:618:24)
at Object. (/home/pi/node_modules/lutronpro/lutronpro.js:572:5)
at Module._compile (module.js:635:30)
at Object.Module._extensions…js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object. (/home/pi/runNodeServer.js:1:79)
at Module._compile (module.js:635:30)

My files were under Home/pi and I deleted them but for some reason it only creates appCert and localCert and the log indicates a failure to find ‘private.pem’. Here is the log I keep getting:

pi@jacobwtyler:~ $ node runNodeServer.js
Listening on port 5000…
No certs will attempt to generate them this version
{ privateKey:
{ n: BigInteger { data: [Array], t: 74, s: 0 },
e: BigInteger { data: [Array], t: 1, s: 0 },
d: BigInteger { data: [Array], t: 74, s: 0 },
p: BigInteger { data: [Array], t: 37, s: 0 },
q: BigInteger { data: [Array], t: 37, s: 0 },
dP: BigInteger { data: [Array], t: 37, s: 0 },
dQ: BigInteger { data: [Array], t: 37, s: 0 },
qInv: BigInteger { data: [Array], t: 37, s: 0 },
decrypt: [Function],
sign: [Function] },
publicKey:
{ n: BigInteger { data: [Array], t: 74, s: 0 },
e: BigInteger { data: [Array], t: 1, s: 0 },
encrypt: [Function],
verify: [Function] } }
in get CSR
-----BEGIN CERTIFICATE-----
MIIDcTCCAlmgAwIBAgIBATANBgkqhkiG9w0BAQUFADB8MRkwFwYDVQQDExBMdXRy
b24gQ2FzZXRhIEFwMQswCQYDVQQGEwJVUzEVMBMGA1UECBMMUGVubnN5bHZhbmlh
MRQwEgYDVQQHEwtDb29wZXJzYnVyZzElMCMGA1UEChMcTHV0cm9uIEVsZWN0cm9u
aWNzIENvLiwgSW5jLjAeFw0xNzExMTQwMjQ3MDVaFw0xODExMTQwMjQ3MDVaMHwx
GTAXBgNVBAMTEEx1dHJvbiBDYXNldGEgQXAxCzAJBgNVBAYTAlVTMRUwEwYDVQQI
EwxQZW5uc3lsdmFuaWExFDASBgNVBAcTC0Nvb3BlcnNidXJnMSUwIwYDVQQKExxM
dXRyb24gRWxlY3Ryb25pY3MgQ28uLCBJbmMuMIIBIjANBgkqhkiG9w0BAQEFAAOC
AQ8AMIIBCgKCAQEAtyCS04SYdti/8NG8SIiaZZioJfXSbUARfp7o/C/v38FwlBv8
N6QJ5NwHWxvjQ+rixAiAyBv4lxOB3qBdXheNvR4mHrQSLsrmVZYhcPFJBZS4UGIo
vjMrshbipMCDHxao63Cp+5FTECWAGC/Q05JalUeja/VgfddruudMSFxMb++TxVSp
ebke+cwqvc/Jssem/JBDXJJ5LpaGzkvskp/EsCR7GFwJgYhVUfFUg761eofK1U63
9Jpwox9Q5vhVxXH4JCGzWLJnNZ846Erl+iW6vv30qmpf5eRgoKMYBSkBLPhYkF9n
hmLYE84aO5rT4B/ubzMkn4zNGqiQdDuX81IDCQIDAQABMA0GCSqGSIb3DQEBBQUA
A4IBAQCcPJkIbScA4Bc+dxl2aojeGSjJST5Dq8+HxN3tlpH2MPq6Ts6m58826wzo
CAia4UhFjGyxhrwNvPOYtjyn2zHh45TJIO1ZwC2yH0f9/SLtFS9JW6xpnqtx/sqP
FIiXrgQ04NmwDYHYwXWdr4g1tWW5b7VqZPnz7WelFvKwYZQoKa9w92tVAWhMyqho
eKXJnMXNr162tiiYb8JNEJIat/i1mSdCwEkTTmi/1x4R3hEEP5iAiBHj3r5vCXdD
C6WnPHuOT3NwRVUr5ML+iYFKDMIpagY4+qtxtAeMcWTYduREt5IlQxrBpYhPdrNI
jW1fM4XQr9guH3Vv7k7g2FTc+yns
-----END CERTIFICATE-----

{“remote_signs_app_certificate_signing_request”:"-----BEGIN CERTIFICATE-----\r\nMIIDcTCCAlmgAwIBAgIBATANBgkqhkiG9w0BAQUFADB8MRkwFwYDVQQDExBMdXRy\r\nb24gQ2FzZXRhIEFwMQswCQYDVQQGEwJVUzEVMBMGA1UECBMMUGVubnN5bHZhbmlh\r\nMRQwEgYDVQQHEwtDb29wZXJzYnVyZzElMCMGA1UEChMcTHV0cm9uIEVsZWN0cm9u\r\naWNzIENvLiwgSW5jLjAeFw0xNzExMTQwMjQ3MDVaFw0xODExMTQwMjQ3MDVaMHwx\r\nGTAXBgNVBAMTEEx1dHJvbiBDYXNldGEgQXAxCzAJBgNVBAYTAlVTMRUwEwYDVQQI\r\nEwxQZW5uc3lsdmFuaWExFDASBgNVBAcTC0Nvb3BlcnNidXJnMSUwIwYDVQQKExxM\r\ndXRyb24gRWxlY3Ryb25pY3MgQ28uLCBJbmMuMIIBIjANBgkqhkiG9w0BAQEFAAOC\r\nAQ8AMIIBCgKCAQEAtyCS04SYdti/8NG8SIiaZZioJfXSbUARfp7o/C/v38FwlBv8\r\nN6QJ5NwHWxvjQ+rixAiAyBv4lxOB3qBdXheNvR4mHrQSLsrmVZYhcPFJBZS4UGIo\r\nvjMrshbipMCDHxao63Cp+5FTECWAGC/Q05JalUeja/VgfddruudMSFxMb++TxVSp\r\nebke+cwqvc/Jssem/JBDXJJ5LpaGzkvskp/EsCR7GFwJgYhVUfFUg761eofK1U63\r\n9Jpwox9Q5vhVxXH4JCGzWLJnNZ846Erl+iW6vv30qmpf5eRgoKMYBSkBLPhYkF9n\r\nhmLYE84aO5rT4B/ubzMkn4zNGqiQdDuX81IDCQIDAQABMA0GCSqGSIb3DQEBBQUA\r\nA4IBAQCcPJkIbScA4Bc+dxl2aojeGSjJST5Dq8+HxN3tlpH2MPq6Ts6m58826wzo\r\nCAia4UhFjGyxhrwNvPOYtjyn2zHh45TJIO1ZwC2yH0f9/SLtFS9JW6xpnqtx/sqP\r\nFIiXrgQ04NmwDYHYwXWdr4g1tWW5b7VqZPnz7WelFvKwYZQoKa9w92tVAWhMyqho\r\neKXJnMXNr162tiiYb8JNEJIat/i1mSdCwEkTTmi/1x4R3hEEP5iAiBHj3r5vCXdD\r\nC6WnPHuOT3NwRVUr5ML+iYFKDMIpagY4+qtxtAeMcWTYduREt5IlQxrBpYhPdrNI\r\njW1fM4XQr9guH3Vv7k7g2FTc+yns\r\n-----END CERTIFICATE-----\r\n"}
6919ee288d5e63afa204c6d0a68eb607d1d506e15a02f28a3a2f02aa4431ec2b
{“access_token”:“6919ee288d5e63afa204c6d0a68eb607d1d506e15a02f28a3a2f02aa4431ec2b”,“token_type”:“bearer”,“refresh_token”:“9016aedfd01abd7e954c4d56c66708d5120890357cc72ad4debe84a36fc32363”,“scope”:“public alexa ifttt”,“created_at”:1510627626}
undefined
undefined
192.168.55.28
fs.js:646
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^

Error: ENOENT: no such file or directory, open 'private.pem’
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at Hub.initalize (/home/pi/node_modules/lutronpro/lutronpro.js:593:15)
at /home/pi/node_modules/lutronpro/lutronpro.js:686:21
at Request._callback (/home/pi/node_modules/lutronpro/lutronpro.js:159:4)
at Request.self.callback (/home/pi/node_modules/request/request.js:186:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request. (/home/pi/node_modules/request/request.js:1163:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage. (/home/pi/node_modules/request/request.js:1085:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)

@Buzzshot @mmohoney @jacobwtyler Sorry about that all of you…I have been working on making fixes and getting this working in windows which is why it had that dependency that didn’t get installed and why it is acting a little wonky. I accidentally published my testing code to the live npm. I will be publishing a fix tonight that should solve all these little issues. I apologize guys for the trouble. This update should fix all of your issues and make it work on Windows platforms as well.

Also @Buzzshot if you see that error ‘Error: listen EADDRINUSE :::5000’ that means that even though it quit the server is still locking up that address. I should really handle that and kill it gracefully. :confused: Anyway, just type ‘killall -9 node’ and then rerun the runNodeServer.js file and it should fix that error. :slight_smile:

Ok all do an npm update lutronpro which should download the latest version which fixes this mess. If you had some cert files already created go ahead and delete them (appCert and localCert) and then run the runNodeServer.js file. Let me know if there are still issues and I will look into it, but I have tested it on both Windows and a raspberry Pi.

@mmohoney Give this a shot on windows and let me know! Thanks!

@njschwartz that fixed all my issues.

@njschwartz

Nice! I am just about to leave but did an update and the devices appear! I will setup my pistons tonight and get a full test in.Thanks for the hard work!