GroveStreams SmartApp

@JasonBSteele
Grovestreams added a “step” checkbox to GS/ Dashboards/ YOURDASHNAME/ YOURGRAPHNAME/ settings/ data/ pick-stream/ go-to-far-right/ step-checkbox.
Pretty awesome they responded that quickly.

Anybody,
I’m not clear on the correct cycle" setting. For frequent updating streams it may be irrelevant. I have 1-2 steams that I would like to automatically or manually sample refrigerator power with an Aeon(energy smart?) Plug which reads KW + KWH. Since I do not have a MyDevice that automatically updates KW, I try manually sampling the fridgeplug every minute or so, until I fall asleep or see a shinything. That takes about 6 minutes. I’ve done this at irregular occasions about 3 times in 5 days.

So when I check the GroveStreams dashboard with “cycle” “auto-detect”, I get the long meaningless diagonal lines (but all my sample points appear). So I change the cycle to 5 minutes (and connect-gaps is unchecked), and the power gets correctly zeroed at the 5 minute point (end of window? 5 minutes from last update?) I think this has reflected the data best since I think most or all of my samples show up in the dashboard.
A minute duration would be better for my purpose but hey I’m not complaining.

When I pick cycle “1 hour” or more, usually some samples are dropped and the data trace disappears from dash, for an unknown reason. A few samples still appear.

  1. So… what does cycle mean? If I sample too infrequently in a 1+hour window, why would it not plot at least one value in there?

  2. Queuing requests per the above modifications, hasn’t appeared to reduce my notifications every hour that I am making too many feed PUTs. I’m not a java/groovy programmer so I haven’t figured how to fix this without deleting the stream. It’s probably my KW stream (AeonHEM v2) but checking debug, there are MANY events.

Is anybody queuing per above SmartApp edits, or using another method and eliminating the warnings? I absolutely do not want to abuse the service and make GroveStreams rethink access level. My Live Logging seems to indicate queuing is happening for AeonHEM and RefrigTemp, and processQueue is executing. Is the following snippet telling me that the Plug# events are not queuing?

b655-XXXETCXXX 11:57:59 AM: debug GroveStreams accepted event(s)
b655-XXXETCXXX 11:57:59 AM: debug Events: [[compId:AeonHEMv2b, streamId:power, time:1417366644352, data:820], [compId:SsMulti2-2AAAA-RefrigInterior, time:1417366662180, streamId:temperature, data:35]]
b655-XXXETCXXX 11:57:59 AM: debug processQueue
b655-XXXETCXXX 11:57:59 AM: trace energy from AeonKwPlug3-Refrig was provided with handleEnergyEvent…creating subscription
b655-XXXETCXXX 11:57:59 AM: trace energy from AeonKwPlug2-ErqPowerStrip was provided with handleEnergyEvent…creating subscription
b655-XXXETCXXX 11:57:59 AM: trace energy from AeonHEMv2b was provided with handleEnergyEvent…creating subscription
b655-XXXETCXXX 11:57:59 AM: trace power from AeonKwPlug3-Refrig was provided with handlePowerEvent…creating subscription
b655-XXXETCXXX 11:57:59 AM: trace power from AeonKwPlug2-ErqPowerStrip was provided with handlePowerEvent…creating subscription
b655-XXXETCXXX 11:57:59 AM: trace power from AeonHEMv2b was provided with handlePowerEvent…creating subscription
b655-XXXETCXXX 11:57:42 AM: debug Appending to queue [compId:SsMulti2-2AAAA-RefrigInterior, streamId:temperature, data:35, time:1417366662180]
b655-XXXETCXXX 11:57:42 AM: trace energy from AeonKwPlug3-Refrig was provided with handleEnergyEvent…creating subscription
b655-XXXETCXXX 11:57:42 AM: trace energy from AeonKwPlug2-ErqPowerStrip was provided with handleEnergyEvent…creating subscription
b655-XXXETCXXX 11:57:42 AM: trace energy from AeonHEMv2b was provided with handleEnergyEvent…creating subscription
b655-XXXETCXXX 11:57:42 AM: trace power from AeonKwPlug3-Refrig was provided with handlePowerEvent…creating subscription
b655-XXXETCXXX 11:57:42 AM: trace power from AeonKwPlug2-ErqPowerStrip was provided with handlePowerEvent…creating subscription
b655-XXXETCXXX 11:57:42 AM: trace power from AeonHEMv2b was provided with handlePowerEvent…creating subscription
b655-XXXETCXXX 11:57:24 AM: debug Appending to queue [compId:AeonHEMv2b, streamId:power, data:820, time:1417366644352]
b655-XXXETCXXX 11:57:24 AM: trace energy from AeonKwPlug3-Refrig was provided with handleEnergyEvent…creating subscription
b655-XXXETCXXX 11:57:24 AM: trace energy from AeonKwPlug2-ErqPowerStrip was provided with handleEnergyEvent…creating subscription
b655-XXXETCXXX 11:57:24 AM: trace energy from AeonHEMv2b was provided with handleEnergyEvent…creating subscription
b655-XXXETCXXX 11:57:24 AM: trace power from AeonKwPlug3-Refrig was provided with handlePowerEvent…creating subscription
b655-XXXETCXXX 11:57:24 AM: trace power from AeonKwPlug2-ErqPowerStrip was provided with handlePowerEvent…creating subscription
b655-XXXETCXXX 11:57:24 AM: trace power from AeonHEMv2b was provided with handlePowerEvent…creating subscription
b655-XXXETCXXX 11:56:48 AM: debug GroveStreams accepted event(s)

I’d appreciate some input.

Your log shows queuing at work; so, it’s good; but I do still get the occasional API warning myself from grovestreams. I start wondering if the limit they are imposing is just at the IP level, and not per IP, per account; if that’s the case, it would imply that all smartapps running on the same ST cloud instance would end up “competing” one with the other. I’ll ask that question to grovestreams, as it would seem a major limitation in their current approach to avoid usage abuse.

About your other question on cycles and such, I would definitely ask the question on their forum; they seem to be very responsive, as you noted.

FYI, I asked to clarify the 10 seconds API limit here: http://forum.grovestreams.com/topic/154/once-call-every-10-seconds-is-allowed/

OK, the GroveStreams guys have confirmed that they are actually enforcing the rule at the IP level only right now, which of course causes troubles to SmartThings app. They are apparently changing things (see the thread on their forum mentioned above if interested in details), but I went ahead in the meanwhile and changed things in the queue processing function to use the workaround they suggested:

def processQueue() {
    def url = "https://grovestreams.com/api/feed?api_key=${channelKey}"
    def header = ["X-Forwarded-For": location.id]
    if (state.queue != []) {
        log.debug "Events: ${state.queue}"
        try {
            httpPutJson(["uri": url, "header": header, "body": state.queue]) { 
                response -> 
                if (response.status != 200 ) {
                    log.debug "GroveStreams logging failed, status = ${response.status}"
                } else {
                    log.debug "GroveStreams accepted event(s)"
                    state.queue = []
                }
            }
        } catch(e) {
            def errorInfo = "Error sending value: ${e}"
            log.error errorInfo
        }
    }
}
1 Like

It makes more sense to me to use app.id instead of location.id to avoid the same issue in case you have multiple apps that log data to GroveStreams.

Sure, it makes perfect sense; I used location.id because I run a single application per location to take care of the event submission, but app.id seems to offer a more generic approach.

Can you clarify what does “Charge per transaction” mean? Is it 10,000 free transactions per month? If so, that would mean less than 14 transactions per hour on average.

That seems to be a question better asked to the GroveStreams folks on their forum.
I expect I will incur a charge in a month due to the number of transactions; but, considering the charge they publish, I should be able to run 200,000 transactions for $1…

Hi, I’m the founder of GroveStreams. If you’re not a business and trying to land within the free amounts of GS but end up with an invoice, send me an email and I’ll cancel your invoice so that you can try to adjust your usage before the next invoice arrives.

We’d love to put a SmartThings GroveStreams example on our website to make it easier for SmartThings folks to get up and running faster. If anyone has time for putting a few steps together with some sample code, let me know. We can try and work something out. Thanks!

12 Likes

As someone noted in another thread regarding spaces, long node names seemed to create a problem for queuing also, so “AeonKwPlug2-ErqPowerStrip” did not queue, but “AKP2E” does queue. EDIT - well I think it queued but now cannot replicate. Yet “SsMoTmp2-CR123-MainHall” does queue. Nuts.

  1. So I am not sure if there is a recommended max length for device name.

  2. even with queuing, probably each update item is a “transaction” right? Where are the GroveStream statistics that count transactions? I don’t mind paying for my load but can’t tell what it is. OOPS I see it is in the top-right under my name/ ACCOUNT.

  3. these GroveStreams log warnings have stopped: “API Exception: Feed PUT call limit has been exceeded”. Seems like my log events are still pretty frequent so I think GS may have loosened the warning filter.

Queuing is working for some devices, any ideas why the AeonKwPlugs don’t queue? They are also Energy and Power events. I’d like to reduce the plugs sample frequency but don’t know how.

b655-XXX 6:16:01 PM: debug GroveStreams accepted event(s): b655-XXX 6:16:01 PM: debug Events: [[compId:AeonHEMv2b, time:1418080535608, streamId:energy, data:383.852], [compId:AeonHEMv2b, streamId:power, time:1418080537505, data:2288], [compId:SsMulti2-2AAAA-RefrigInside, time:1418080558957, streamId:temperature, data:43]] b655-XXX 6:16:01 PM: trace energy from AEP3BT was provided with handleEnergyEvent...creating subscription b655-XXX 6:16:01 PM: trace energy from AeonKwPlug2-ErqPowerStrip was provided with handleEnergyEvent...creating subscription b655-XXX 6:16:01 PM: trace energy from AeonHEMv2b was provided with handleEnergyEvent...creating subscription b655-XXX 6:16:01 PM: trace power from AEP3BT was provided with handlePowerEvent...creating subscription b655-XXX 6:16:01 PM: trace power from AeonKwPlug2-ErqPowerStrip was provided with handlePowerEvent...creating subscription b655-XXX 6:16:01 PM: trace power from AeonHEMv2b was provided with handlePowerEvent...creating subscription b655-XXX 6:15:58 PM: debug Appending to queue [compId:SsMulti2-2AAAA-RefrigInside, streamId:temperature, data:43, time:1418080558957]

We redid the 10 second limit algorithm about 6 days ago: http://forum.grovestreams.com/topic/155/10-second-feed-put-limit-algorithm-change/

A question above asked what a cycle is. It describes repeating time intervals. For example, a “One Day” cycle defines the start time and end time of every day. When you select a cycle to view in GS, you also need to select the statistic for the cycle you are viewing in case more than one sample arrived in the cycle. So if “Sum” was the selected statistic, GS would sum all of the samples that land in each Day cycle. When you select a cycle within a dashboard widget, you are telling the widget that you wish to view that cycle stream - so if Day is selected, you will view a graph with daily values (one value per day).

Cycles are useful for zooming in and out, setting alerts on things like the “Daily Sum”, or within derivation calculations. A smart plug might record kWh once an hour, but you also want to monitor your past and current monthly cost each hour. You could use the “Month” cycle with the Sum statistic within a derivation formula to do the current month cost calculation - we do this in our sandbox if you need to see an example.

I’m a novice on both sides of this equation… Can someone help me debug this message:

41d5c09a-3251-4f6a-8d63-6cc48b0dea61 4:48:53 PM: error Error sending value: groovyx.net.http.HttpResponseException: Forbidden
41d5c09a-3251-4f6a-8d63-6cc48b0dea61 4:48:53 PM: debug Events: [[compId:TOMS TED, streamId:energy, time:1418766023031, data:652542], [compId:TOMS TED, time:1418766023076, streamId:power, data:2310]]

And of course nothing ends up on grovestream.

I created 2 streams, under a component called “home energy monitor”, one “power” and one “energy” (I cloned the code on the energy monitor above).
I added that component to an API key called TED Streams and copied that key back to smartthings into the api key in preferences. Obviously I went wrong somewhere with authorizing or linking things.

Thanks

Not sure exactly what you did, but the process is usually quite simple: you don’t need to create components or even streams manually in GroveStreams. Just create a GroveStreams organization, get its key (you don’t choose the key, you ask GroveStreams what the API key is in Admin > API Keys; select the Feed PUT API Key entry and choose “View Secret Key”) and use that information as the API key when you set up the ST app.
At that point components and streams should get automatically create as the app starts feeding events.

Wait, that’s far too easy! Works now. :stuck_out_tongue_winking_eye:

Ok, another one, it seems to only write one value (energy) despite putting two (energy & power) into the queue:

5:40:47 PM: debug GroveStreams accepted event(s)
5:40:47 PM: debug Events: [[compId:TOMS TED, time:1418769644363, streamId:energy, data:654432]]
5:40:44 PM: debug Appending to queue [compId:TOMS TED, streamId:energy, data:654432, time:1418769644363]
5:40:44 PM: debug Appending to queue [compId:TOMS TED, streamId:power, data:660, time:1418769644353]

…sounds like there is something wrong in the code you are using, and you are not really appending to the queue, but replacing it each time… do you have some spurious “state.queue = []” code? If you do, make sure it’s only in the initialize() code, and maybe with a “if (state.queue == null)…” check first.

Hi Mike, I’d be happy to help out with this. Feel free to let me know more about what you are after either in this thread or PM.

Hi, sorry for the delay.

The extra value just showed up the next day. No idea why.

Here is a dashboard example via GroveStreams: single-family-house-dashboard-updated

I wouldn’t mind seeing somebody else’s examples - FYI you can create temporary Dashboard keys and custom Dashboards for public viewing, that you can delete without affecting your private Dashboards.

UPDATED EXAMPLE LINK:

2 Likes

I’ve just posted about @mmills and myself writing a tutorial for integrating SmartThings with GroveStreams GroveStreams SmartThings QuickStart

1 Like