[OBSOLETE] LutronPro Caseta v1.0

Hi Nate still getting that error. Could be that all my screwing around messed it up. Dose anyone know the command to blow it out. So I can start again

@Buzzshot which error? The address in use one? If so do ā€˜killall -9 nodeā€™ then retry it. If something else post it here and Iā€™ll figure it out.

@jacobwtyler @mmohoney Glad it appears to be working. Let me know if thereā€™s any issues!

pi@raspberrypi:~ $ node runNodeServer.js
module.js:538
throw err;
^

Error: Cannot find module 'lutronproā€™
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/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)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)

pi@raspberrypi:~ $ killall -9 node
node: no process found

thanks for all the help nate.

I was getting that error when I installed lutronpro with the -g flag (global) which put the module in /usr/lib/node_modules/lutronpro instead of /home/pi/node_modules/lutronpro. I wish I knew more and could point it to the global install because thats where all my homebridge nodes run from but Iā€™m just too new to all this so when I reinstalled without the -g flag then it found it. Maybe someone can expand on this. I could be way off.

looked for the lutron folder in /user/lib/node but nothing in there for lutron

It would only be in there if you installed with the -g global flag. Assuming you didnā€™t then it will be inside a folder called node-modules which will be in whatever folder you were in when you ran ā€˜node install lutronproā€™. You need to put the runNodeServer.js file in the same folder you ran the install from (so that folder will contain the node-modules folder and the runNodeServer.js file). It should work then.

How does this look for the ramping on buttons 4 and 5? I couldnā€™t find the ā€œcurrent level + 10%ā€ option. How do I create the attribute where it says ā€œX2 Set variable {currentLevel} = Guest Bedroom Blinds Levelā€? This is for opening window blinds gradually with buttons 4 and 5 using the ramping option. Is there a better way of accomplishing this?

Guest BR Blinds Pico Piston Snapshot

For the most part what you have looks good. Itā€™s a little hard to tell because I donā€™t know the specifics of the blinds device. Does that adjustLevel piece work? If so great. If not you may need to do what I did and create a variable to hold the currentValue then do a little math to adjust the level.

I installed everything in the home Pi directory. And I tried placing the node file all over no such luck. Even in the node lutron folder as well.

Something is weird with your setup but weā€™ll get it straightened out. I sent you a message so we can connect directly and figure out whatā€™s up.

Has a spontaneous disconnect from the Lutron Bridge last night some time, leaving the app non-functional, but it very politely logged the event:

Device update recieved
likely a manual change
Received: shutting down the integration terminal
Disconnected from SmartBridgePro

What would initiate that? Sounds like it was instigated from the Lutron end. (First thing I thought of was the upcoming Smartthings firmware push, but thatā€™s not until tomorrow.)

Anyway, a manual restart (pm2 restart runNodeServer) was all it took to get going again.

So I tried the PM2 service that @BHO and @njschwartz recommended to me and it was still failing (I think because it wasnā€™t looking in the right area for my 4 cert files that are created). I just went ahead and figured out what I was doing wrong with the systemd service and I wanted to post what I did to get it working. Iā€™m pretty sure this is super basic stuff to most people but I went ahead and typed a pretty thorough step by step for dummies like myself that want to get it going. The ā€œWorkingDirectoryā€ line was the line that made the difference for me because it found the cert files that way so you may have to alter that line if your cert files are being stored somewhere else.

To create systemd service daemon for Lutron Pro Caseta Server:

  1. open terminal

  2. type ā€œsudo nano /etc/systemd/system/lutronpro.serviceā€

  3. copy and paste: (replace WorkingDirectory with the location of your runNodeServer.js file and cert files and replace ExecStart with ā€œusr/bin/node runNodeServer.js or whatever you named your *.js fileā€¦ I renamed mine to lutronpro.js)

     [Unit]
     Description=Node.js LutronPro Caseta Server
     After=syslog.target network-online.target
    
     [Service]
     Type=simple
     User=pi
     WorkingDirectory=/home/pi/LutronProCaseta
     ExecStart=/usr/bin/node lutronpro.js
     Restart=on-failure
     RestartSec=10
     KillMode=process
    
     [Install]
     WantedBy=multi-user.target
    
  4. CTRL+X to save, Y to confirm

  5. type ā€œsudo systemctl daemon-reloadā€

  6. type ā€œsudo systemctl enable lutronpro.serviceā€

  7. open a 2nd terminal window and type ā€œsudo journalctl -f -u lutronproā€ in order to monitor the log before you perform the next step so that you know it loads correctly. You can use this command to monitor your logs anytime you want (CTRL+C to get out of the log at any time).

  8. back in your 1st terminal window type ā€œsudo systemctl start lutronproā€

Notes: you can type ā€œsudo systemctl stop lutronproā€ to stop the server cleanly at any time and ā€œsudo systemctl disable lutronproā€ to disable this service daemon if you so desire. If you restart your Raspberry Pi, it should autostart the Lutron server now. If it crashes, it should attempt to restart after 10 seconds. This can be modified in the service file you created. If you make any changes to the service file, you need to type ā€œsudo systemctl daemon-reloadā€ again to pick up on the changes. Hope this helps someone. Cheers.

4 Likes

@njschwartz

Ok so I got it working however there is some behaviour that could change.

I have webcore to do the following

button 1 for setLevel to current
button 2 for turn off
button 4 dim up
button 5 dim down
button 3 set random color

Now here is the part that is not ideal. button 3 on push always goes through 2 random colours on every push. When looking at the logs it looks like with every button push event it sends it twice. So my if statement gets triggered twice on every push.

When looking at the logs I always see two pushed events right after each other

1ecfb3e4-02fd-47cc-9288-d42cedeb48f3 1:17:19 PM: debug In button event 1pushed
1ecfb3e4-02fd-47cc-9288-d42cedeb48f3 1:17:19 PM: debug 1
1ecfb3e4-02fd-47cc-9288-d42cedeb48f3 1:17:19 PM: debug In button event 1pushed
1ecfb3e4-02fd-47cc-9288-d42cedeb48f3 1:17:19 PM: debug 1

Now iā€™m wondering should it be sending a pushed and then released instead of two pushes

Similarly how on a held it sends a null when released instead of a released.

So i donā€™t need the released call but it would be nice to only get a single pushed event instead of 2

@njschwartz ok i found the bug why there was 2 pushed events. So it seems depending on the number of pico devices you have declared in the runNodeServer.js file is the number of pushed events that get sent per button push on all the pico remotes. Before I had 2 Picoā€™s so it would send 2 pushed events for a single push. Once I added a 3rd Pico it then sent 3 pushed events for a single push on any of the Pico remotes. When I removed all but 1 of the devices from the runNodeServer.js it then only sent 1 pushed event.

1 Like

I see the glitchā€¦I am kind of surprised this was never noticed before to be honest. lol I am working on a fix and will submit it shortly. Thanks for figuring it out! :slight_smile:

@huydnguyen I think I fixed that issue. Update to the latest code and give it a shot.

I also made manually fetching the authorization code no longer necessary. Instead you put your username and pw in the runNodeServer.js file and it will fetch it automatically and sign you in. I will update the instructions in the 1st post as well as the example file to reflect this.

1 Like

Does it update the smartapp update without having to restart the node server

K after installing i got

Error: Cannot find module 'url-search-paramsā€™
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)

did an npm install url-search-params

then I got ā€¦

ReferenceError: OAUTHCODE is not defined
at Object. (/usr/lib/node_modules/lutronpro/server.js:57:51)
at Module._compile (module.js:570:32)
at Object.Module._extensionsā€¦js (module.js:579:10)
at Module.load (module.js:487:32)

removed OAUTHCODE reference in the server.js last line

then it runs and goes to try and generate the certs and i see the following in the output

-1
no code, try again

Hey so sorry about that dependency I will fix that so you donā€™t have to do it manually. Did you delete the certs you were using? Just curious because it should have just used them. Since you need to regenerate the certs check out the updated runNodeServer.js file: https://github.com/njschwartz/lutronpro/blob/master/runNodeServer.js Itā€™s a pretty small change. You just need to enter your Lutron credentials and all should be well again. I should have not made two changes in the same update like thatā€¦made it kind of confusing. Sorry

When I did the npm update it removed the certs. I did enter my credentials and used your new runNodeServer.js. I had to remove the OAUTHCODE reference for it to work though.

I still get that message at the end of the out put saying ā€œtry againā€

1 Like