ComEd RRTP Rate Monitor

devicetype

(Chris Means) #1

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?


(John) #2

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.


(Chris Means) #3

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?

(John) #4
  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.


(Chris Means) #5
  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.

(John) #6
  1. That’s a limitation.

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

Good luck!


(Matt Talaga) #7

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:


(Chris Means) #8

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