ComEd RRTP Rate Monitor

I’ve written my first Device Type, and would welcome feedback and suggestions.

The code is here: https://github.com/cmeans/SmartThings/blob/master/devicetypes/ComEd-Rate-Meter/rate_meter.groovy

The API it consumes is documented here (and there are no restrictions on its use): https://hourlypricing.comed.com/hp-api/

If you use Commonwealth Edison Residential Real Time Pricing then the rate you pay per kWh varies constantly based upon demand. This device will monitor the changes in that rate, and allow you to use it as a trigger to turn off other devices, send an alert or whatever.

I only purchased my SmartThings hub last week (was using another Kickstarter product, but it was not a friendly platform), so I’m very new at development in this space. I am a programmer by profession, so Groovy etc. is familiar, but obviously, all the extras that SmartThings bring will take me a while to learn.

The rate changes about every five minutes, so it would be nice to stay up on the changes, I’m unclear if my implementation is appropriate…I realize that I shouldn’t be polling too much.

I have noticed that I get the error:

java.util.concurrent.TimeoutException: Execution time exceeded 20 app execution seconds: 238188856992526

A lot…but the calls to the REST API do not take anywhere near that long.

I originally wrote this in NodeJS (it’s currently running on a Raspberry Pi 2), and it reports changes to IFTTT which then controls some Phillips Hue Lightstrips. I also have an Amazon Echo Skill (in certification) for a voice request version (just reports the current rate).

For this implementation…what have I done wrong :slight_smile: what can I do better?

You’ve probably done nothing wrong. That is the ST rate limiting error. AND, it can occur because their system is slowing down and have nothing to do with your app/device at all.

OK.

I’ve noticed three things I’d like to change/fix:

  1. In the Things list, the display of the rate is in all caps. It looks nice, however, I’m displaying a unit value kWh, which I’d like to have the correct capitalization…do I have any control over that?
  2. In the Notifications / Activity Feed, it just shows the numeric value without my units…how do I get the unit on there?
  3. This current implementation (which I just changed recently) no longer seems to be polled. How do I get that working within the SmartThings API?
  1. I have a similar device. The main tile capitalizes the units (incorrectly). Other value tiles capitalize correctly.

  2. I haven’t looked at the code, but in my device I append the unit and it works for me.

  3. You could use Pollster, but honestly ANYTHING tied to scheduling blows up (not if, but when - whether it’s this hour or next). I created an Arduino scheduler that hasn’t failed me yet (I subscribe to the frequency that I want). I would subscribe to some device that changes in the frequency that you want.

1 Like
  1. The details panel rendering is fine, it’s the Things list where it’s in all caps for the unit.
  2. Are you still able to hook into published events for the Energy Meter value? Seems like if you add text to the value that might break a trigger value monitor.
  3. OK, I’ll try that.
  1. That’s a limitation.

  2. I use the values. Haven’t had an issue.

Good luck!

Thanks Chris. I am new to SmartThings myself. I was able to add your ComEd Hourly Device type which is great by the way. Now I just need to come up with something that I can use to Automate it. :slight_smile:

1 Like

Great to hear.

I mostly use it to manage my Nest (setting it to ECO mode when the rate gets higher than I like, and back once the rate is reasonable). For visual cues I also have a routine that sets the color of two Philips Hue lightstrips based on the current price average, though currently I’m using a Ruby script that I wrote…haven’t gotten around to creating a rule in SmartThings, though that should be relatively easy.

Do let me know how you get on.

-Chris

Hi Chris, GA
It looks like 4 days a go the script stopped working on my device. Not sure what happend. I deleted it and copy pasted and pusblished new code from you github and crated new device but not woking still.

Then I tried it in virtual device on IDE and it shows this error.
41e47470-ef21-4f65-a0f6-e2a139d594f4 1:13:59 PM: error something went wrong: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

41e47470-ef21-4f65-a0f6-e2a139d594f4 1:08:59 PM: error something went wrong: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Thanks for the heads-up. Seems like my Alexa Skill has suffered the same fate.

I’ll take a look soon and see if I can determine what’s up exactly.

-Chris

Amazing. Wanted to also thank you Chris for this amazing code. Recently pricing was 230 per/kwh and that prompted me to look for a solution and your code has been working amazingly to change nest.

:slight_smile:

I’ve seen some high prices too…though I don’t recall seeing 230/kwh…yuk.

FYI: I just retested and my SmartThings and Alexa Skill both seem to be working, so I’m guessing it was a problem at their end…or on the network.

Can you confirm you’re good?

It stopped working. Please can i know how to get it back and working?