[NO LONGER WORKING] Curb Energy Monitor Integration

This is very interesting… and almost definitely a bug on my side. Please stand by and I’ll let you know when I have a fix. In the mean time you should be able to safely delete the duplicates. If they get re-added automatically let me know.

Using the work that @jh0 has done, my dashboard works again :slight_smile:.

On the off-chance anyone is interested, https://github.com/Dianoga/node-curb is the library I’ve put together. It’s fairly limited at this point as I only really need live circuit data.

If there is interest, I can try actually documenting some of it…

1 Like

I just pushed a fix that should correct your issue. The fix is only on the node.js server, so no need to update in the ST IDE.
Uninstall the CurbBridge app in the ST mobile app to delete all of the devices, install it again and re-run the node.js program. Let me know if you have more issues.

Hi,

Trying to test out your latest code, keep getting the following error when trying to authorize the app from the web page, any ideas?

Error
500: Internal Server Error
URI
/oauth/authorize
Reference Id
35c48496-4f62-4ca5-a69e-0eac76917cfa

Thanks

Hi @KJ61, I’ve seen this before intermittently with no clear explanation. Yesterday, SmartThings was having an outage, so you might just try again today. Also, double check that the Curb Bridge SmartApp shows up in the ST Mobile App under your installed SmartApps. If these suggestions don’t get you anywhere, try again with the live logging page up and see if any errors are reported there.

That’s awesome, ty! Would love to see it documented, as well as on npmjs if possible!

This works great! Just how I imagined it when I funded my Curb 2 years ago.

It’s using a lot less CPU on my server compared to Round 1 and the response to changes are quick, even for ST.

1 Like

Hi,

Tried yesterday and today. This time it seems to log in , it gets to the ST web page with out the error.
In the server screen I’m getting the following.
C:\curbbridge>node .
Server running at http://127.0.0.1:8000/
Get: /
Get: /stAuthorize.js
Post
Sending request to: https://graph.api.smartthings.com/oauth/token?grant_type=aut
horization_code&redirect_uri=http://localhost:8000/authSuccess.html&client_id=kr
isjordan@xxxxxxxl.com&code=undefined&client_secret=cdbdcc94-fbf8-4533-87
78-xxxxxxxxxxx
Something went wrong: 401
Response: {“error”:“unauthorized”,“error_description”:null}

Any ideas?

Thanks
Kris

Looks like you might be skipping a step during authentication. Or perhaps something is going wrong early in the process.

First, put in the ST ClientID at the top and click “Connect to SmartThings”. Then a new frame will appear which will have you log in to ST and authorize for your location. If this part is successful, you will see “Authorization Success” in the frame where you logged in to ST and the console will print “Got ST Auth Code: abc123”

Next step is to fill out the remaining fields and click “Submit”

Let me know if you still have trouble.

Hi,

If it use firefox, I get the errors from my first post. IE produces the following after logging in.

Interesting… I had only ever tested with Chrome. I don’t have a computer IE, but firefox does seem to perform a little bit differently for me.

Things to try:

  • If you have access to chrome, give that a shot.
  • Firefox with “private mode” turned on so that there aren’t any caching shenanigans.

Here is what I get while running in Firefox:

Server running at http://127.0.0.1:8000/
Get: /
Get: /stAuthorize.js
Get: /authSuccess.html?code=abc123
Got ST Auth Code: abc123
Post
Sending request to: https://graph.api.smartthings.com/oauth/token?grant_type=authorization_code&redirect_uri=http://localhost:8000/authSuccess.html&client_id=xxxxxxxx-5f7a-4a9d-b4e0-xxxxxxxxxxxx&code=abc123&client_secret=xxxxxxxx-cfee-4449-9372-xxxxxxxxxxxx
...

Make sure you’re following the steps on github to the T and let me know the first place where things don’t appear right or the console output diverges. We’ll get you sorted! Thanks for the patience.

I’ve just pushed a small update to the app which separates the two stages of authentication into two separate pages to make the process a bit more intuitive. No functional changes, but might make initial setup go more smoothly.

Hi Again,

I got logged in using IE, I clicked the 3 bars in the top right, under developer tools selected locations.
Under locations there is only one, don’t see any to click for authorize. Treid Chrome and firefox both give me the
Error
500: Internal Server Error
URI
/oauth/authorize
Reference Id
35c48496-4f62-4ca5-a69e-0eac76917cfa

after logging in.

I think this means that SmartThings does not recognize the Client ID you have provided. If I put in a purposely put in an incorrect ID, I get this page. Is that what you’re seeing?

Can you double check that the SmartApp in the IDE has OAuth enabled? Also you can try refreshing the client secret which might help…

Another thing to check is if you go to your location page and click smartapps, you should see exactly one instance of CurbBridge (dev) in the Other category.

HI,

Thanks for all the help. I started from scratch and all is working.

1 Like

how different is it from @jh0 Justin’s code ? or does it complement his effort ?

thanks

Justin,

new code installed… now i see only 21 devices (18 + the 3 others (MAIN 1, MAIN 2 and Other.)

Quick question: I see a graph below each device. Where is it pulling the data from ? as i see a graph that goes back almost 20+ hours…

thanks

Glad the new version fixed your problems!

The historical data comes directly from Curb. They provide an API to get historical usage over varying time windows. Currently, I have it set for 24 hours at 5 minute intervals, but allowing it to be configured is planned for the future. The graph is rendered using a bit of JavaScript that Google distributes as part of their chart tools. This rendering occurs within a tiny embedded browser in the ST app, so have no fear: your data never leaves the app.

This graphing feature uses an htmlTile, which is an undocumented part of the ST API. As such, it is not supported and appears to still have some bugs (doesn’t always load correctly), but hopefully support improves with future app updates from SmartThings.

1 Like

Is it possible to have node.js autostart after reboot?

I also had a case where the node.js command windows appeared running but I wasn’t getting updates.

Lastly, would it be possible to run on AWS. I believe the package would install but how would the opening into a browser for authentication works.

Overall it works great.

I’ve had success adding the node server to the startup scripts for the machine so that it runs automatically on boot. How to do this depends on your OS, but a quick google for “custom boot script -os name-” should get you heading in the right direction.

I don’t see any reason why you can’t run the node server on AWS (or any other machine with node.js). An easy way to solve the auth problem is to complete the authentication on a “normal” machine and then copy your CurbBridgeData.json file to the headless machine. I do this with my raspberry pi since I don’t have a monitor on it and x forwarding is painful.

PS: Don’t invest too much effort here because I expect to release a new version of CurbBridge that runs entirely in the SmartThings cloud very soon… no node.js server required.