Syntax for API GET to InfluxDB


#1

1) Give a description of the problem
I need help with the correct syntax for retrieving data via api calls to InfluxDB. I currently write sensor data to influxdb and I’m planning on using the “Values Tiles” piston to create an easy device type handler. I’m not familiar with how to write device handlers properly, so this seems like an easier lift

2) What is the expected behaviour?
JSON data returned from calls.

3) What is happening/not happening?
Nothing, I’m uncertain exactly how to write my queries.

4) Post a Green Snapshot of the pistonimage
None yet

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

documentation:
https://docs.influxdata.com/influxdb/v1.7/guides/querying_data/

I also read this: https://influxdbcom.readthedocs.io/en/latest/content/docs/v0.7/api/reading_and_writing_data/

Now I just need to know how to write this in webcore


#2

Well, I don’t READ data from InfluxDB, but I write annotations. Maybe this will get you pointed in the right direction at least.

I expect it would be similar, but using a GET and sending the query string as a parameter. Worry first about getting a result (e.g. log $response) to see what the response looks like, then figure out how to get the actual value you want out of the JSON.


#3

I have the curl syntax, but I’m struggling to get this into webcore. The format is:

curl -G http://localhost:8086/query?pretty=true -u user:password --data-urlencode “db=plant_data” --data-urlencode “q=SELECT last(“temperature”) FROM “monitor_reading” WHERE (“monitor” = ‘Lime’) AND time >= now() - 12h GROUP BY time(1m), “monitor” fill(none) Limit 1"”


#4

define 2 variables

define
string db = ‘plant_data’;
string q = ‘SELECT last(“temperature”) FROM “monitor_reading” WHERE (“monitor” = ‘Lime’) AND time >= now() - 12h GROUP BY time(1m), “monitor” fill(none) Limit 1’;
end define

then in your make web request
url = http://localhost:8086/query?pretty=true -u user:password (using your actually IP address since the call is from the hub)
send variables q and db

Not sure about the username:password as part of the URL; might have to play with the AuthoriZation part of the web call…if possible remove the authorization on the influxdb side, get it to work in webcore, then put it back on and figure that part out.


#5

So it seems as though the user/pass can be passed as data-urlencode as well, but when i configure it, it’s not working. I’ve disabled authentication for now.

curl -G http://localhost:8086/query --data-urlencode "u=todd" --data-urlencode "p=influxdb4ever" --data-urlencode "q=SHOW DATABASES"

I can get that syntax to work in curl, but switching to webcore is currently not working even when I set u and p to string variables.


#6

You are using the actual IP address of your influxdb host in webcore, and not localhost, correct?


#7

Correct. This is a weird one. The query seems to determine whether or not the request is successful or not.

Works: SELECT last(“moisture”) FROM “monitor_reading” WHERE (“monitor” = ‘Lime’) AND time >= now() - 10m GROUP BY time(1m), “monitor” fill(none)

Doesn’t work: SELECT last(*) FROM “monitor_reading” WHERE (“monitor” = ‘Lime’) AND time >= now() - 10m GROUP BY time(1m), “monitor” fill(none)

The first just returns a single value and httpresponsecode of 200, the second returns 408. Both work with curl…


#8

I seem to be having inconsistent results with this, one minute its working, the next it’s 408… See logs:

3/26/2020, 5:52:33 PM +110ms
+1ms ╔Received event [Evans St].time = 1585270353917 with a delay of -807ms
+295ms ║RunTime Analysis CS > 30ms > PS > 207ms > PE > 57ms > CE
+298ms ║Runtime (41296 bytes) successfully initialized in 207ms (v0.3.110.20191009) (296ms)
+299ms ║╔Execution stage started
+312ms ║║Cancelling statement #2’s schedules…
+345ms ║║Sending internal web request to: 10.1.100.25:8086/query
+348ms ║║Executed virtual command httpRequest (28ms)
+349ms ║║Requesting a wake up for Thu, Mar 26 2020 @ 5:52:53 PM PDT (in 20.0s)
+354ms ║╚Execution stage complete. (55ms)
+355ms ║Setting up scheduled job for Thu, Mar 26 2020 @ 5:52:53 PM PDT (in 19.995s), with 1 more job pending
+363ms ╚Event processed successfully (363ms)
3/26/2020, 5:52:03 PM +95ms
+0ms ╔Received event [Evans St].wc_async_reply = httpRequest with a delay of 0ms
+106ms ║RunTime Analysis CS > 13ms > PS > 40ms > PE > 53ms > CE
+108ms ║Runtime (41299 bytes) successfully initialized in 40ms (v0.3.110.20191009) (107ms)
+109ms ║╔Execution stage started
+110ms ║╚Execution stage complete. (1ms)
+111ms ║Setting up scheduled job for Thu, Mar 26 2020 @ 5:52:33 PM PDT (in 30.711s)
+121ms ╚Event processed successfully (120ms)
3/26/2020, 5:51:52 PM +146ms
+1ms ╔Received event [Evans St].time = 1585270313452 with a delay of -1306ms
+156ms ║RunTime Analysis CS > 43ms > PS > 70ms > PE > 43ms > CE
+159ms ║Runtime (41309 bytes) successfully initialized in 70ms (v0.3.110.20191009) (156ms)
+160ms ║╔Execution stage started
+172ms ║║408
+176ms ║║Executed virtual command log (5ms)
+181ms ║║[:]
+184ms ║║Executed virtual command log (3ms)
+187ms ║║Error retrieving JSON data part null
+192ms ║║Executed virtual command setVariable (3ms)
+195ms ║║Error retrieving JSON data part null
+199ms ║║Executed virtual command setVariable (3ms)
+202ms ║║Error retrieving JSON data part null
+206ms ║║Executed virtual command setVariable (2ms)
+209ms ║║Error retrieving JSON data part null
+212ms ║║Executed virtual command setVariable (2ms)
+215ms ║║Error retrieving JSON data part null
+220ms ║║Executed virtual command setVariable (2ms)
+223ms ║╚Execution stage complete. (64ms)
+225ms ║Setting up scheduled job for Thu, Mar 26 2020 @ 5:52:33 PM PDT (in 41.547s)
+233ms ╚Event processed successfully (233ms)
3/26/2020, 5:51:33 PM +92ms
+0ms ╔Received event [Evans St].time = 1585270293917 with a delay of -826ms
+332ms ║RunTime Analysis CS > 24ms > PS > 256ms > PE > 53ms > CE
+334ms ║Runtime (41310 bytes) successfully initialized in 256ms (v0.3.110.20191009) (333ms)
+335ms ║╔Execution stage started
+344ms ║║Cancelling statement #2’s schedules…
+355ms ║║Sending internal web request to: 10.1.100.25:8086/query
+358ms ║║Executed virtual command httpRequest (7ms)
+359ms ║║Requesting a wake up for Thu, Mar 26 2020 @ 5:51:53 PM PDT (in 20.0s)
+363ms ║╚Execution stage complete. (28ms)
+365ms ║Setting up scheduled job for Thu, Mar 26 2020 @ 5:51:53 PM PDT (in 19.996s), with 1 more job pending
+373ms ╚Event processed successfully (373ms)
3/26/2020, 5:50:37 PM +888ms
+0ms ╔Received event [Evans St].wc_async_reply = httpRequest with a delay of 1ms
+116ms ║RunTime Analysis CS > 18ms > PS > 44ms > PE > 53ms > CE
+118ms ║Runtime (41299 bytes) successfully initialized in 44ms (v0.3.110.20191009) (117ms)
+119ms ║╔Execution stage started
+129ms ║║200
+132ms ║║Executed virtual command log (3ms)
+136ms ║║{“results”:[{“statement_id”:0,“series”:[{“name”:“monitor_reading”,“tags”:{“monitor”:“Lime”},“columns”:[“time”,“last_battery”,“last_conductivity”,“last_light”,“last_moisture”,“last_temperature”],“values”:[[“2020-03-27T00:46:00Z”,94,139,780,36,14.5]]}]}]}
+139ms ║║Executed virtual command log (2ms)
+145ms ║║Executed virtual command setVariable (3ms)
+151ms ║║Executed virtual command setVariable (3ms)
+157ms ║║Executed virtual command setVariable (3ms)
+163ms ║║Executed virtual command setVariable (3ms)
+169ms ║║Executed virtual command setVariable (3ms)
+172ms ║╚Execution stage complete. (52ms)
+173ms ║Setting up scheduled job for Thu, Mar 26 2020 @ 5:51:33 PM PDT (in 55.857s)
+186ms ╚Event processed successfully (185ms)

Piston:


#9

I’m stumped on this one. I’m assuming I there is some async issues I’m not seeing here, but it works one call, then it doesn’t again…

3/26/2020, 6:28:04 PM +57ms
+1ms ╔Received event [Evans St].time = 1585272484968 with a delay of -911ms
+207ms ║RunTime Analysis CS > 71ms > PS > 78ms > PE > 57ms > CE
+210ms ║Runtime (41416 bytes) successfully initialized in 78ms (v0.3.110.20191009) (209ms)
+211ms ║╔Execution stage started
+223ms ║║Cancelling statement #2’s schedules…
+241ms ║║Sending internal web request to: 10.1.100.25:8086/query
+244ms ║║Executed virtual command httpRequest (10ms)
+255ms ║║Requesting a wake up for Thu, Mar 26 2020 @ 6:28:24 PM PDT (in 20.0s)
+260ms ║╚Execution stage complete. (50ms)
+262ms ║Setting up scheduled job for Thu, Mar 26 2020 @ 6:28:24 PM PDT (in 19.995s), with 1 more job pending
+270ms ╚Event processed successfully (270ms)
3/26/2020, 6:27:23 PM +63ms
+1ms ╔Received event [Evans St].time = 1585272444190 with a delay of -1128ms
+156ms ║RunTime Analysis CS > 30ms > PS > 64ms > PE > 62ms > CE
+159ms ║Runtime (41424 bytes) successfully initialized in 64ms (v0.3.110.20191009) (156ms)
+160ms ║╔Execution stage started
+172ms ║║408
+173ms ║║Executed virtual command log (2ms)
+178ms ║║[:]
+179ms ║║Executed virtual command log (1ms)
+182ms ║║Error parsing JSON data [:]
+183ms ║║Executed virtual command parseJson (2ms)
+186ms ║║Error retrieving JSON data part null
+191ms ║║Executed virtual command setVariable (3ms)
+194ms ║║Error retrieving JSON data part null
+198ms ║║Executed virtual command setVariable (3ms)
+202ms ║║Error retrieving JSON data part null
+208ms ║║Executed virtual command setVariable (3ms)
+212ms ║║Error retrieving JSON data part null
+216ms ║║Executed virtual command setVariable (3ms)
+220ms ║║Error retrieving JSON data part null
+224ms ║║Executed virtual command setVariable (3ms)
+227ms ║╚Execution stage complete. (68ms)
+229ms ║Setting up scheduled job for Thu, Mar 26 2020 @ 6:28:04 PM PDT (in 41.677s)
+237ms ╚Event processed successfully (237ms)
3/26/2020, 6:27:04 PM +50ms
+0ms ╔Received event [Evans St].time = 1585272424968 with a delay of -918ms
+116ms ║RunTime Analysis CS > 15ms > PS > 53ms > PE > 47ms > CE
+118ms ║Runtime (41423 bytes) successfully initialized in 53ms (v0.3.110.20191009) (117ms)
+119ms ║╔Execution stage started
+127ms ║║Cancelling statement #2’s schedules…
+136ms ║║Sending internal web request to: 10.1.100.25:8086/query
+139ms ║║Executed virtual command httpRequest (6ms)
+140ms ║║Requesting a wake up for Thu, Mar 26 2020 @ 6:27:24 PM PDT (in 20.0s)
+144ms ║╚Execution stage complete. (26ms)
+145ms ║Setting up scheduled job for Thu, Mar 26 2020 @ 6:27:24 PM PDT (in 19.995s), with 1 more job pending
+153ms ╚Event processed successfully (153ms)
3/26/2020, 6:26:19 PM +535ms
+0ms ╔Received event [Evans St].wc_async_reply = httpRequest with a delay of 0ms
+113ms ║RunTime Analysis CS > 16ms > PS > 46ms > PE > 51ms > CE
+115ms ║Runtime (41421 bytes) successfully initialized in 46ms (v0.3.110.20191009) (114ms)
+116ms ║╔Execution stage started
+128ms ║║200
+129ms ║║Executed virtual command log (1ms)
+135ms ║║{“results”:[{“statement_id”:0,“series”:[{“name”:“monitor_reading”,“tags”:{“monitor”:“Lime”},“columns”:[“time”,“last_battery”,“last_conductivity”,“last_light”,“last_moisture”,“last_temperature”],“values”:[[“2020-03-27T01:20:00Z”,94,141,592,36,13.7],[“2020-03-27T01:25:00Z”,94,141,304,36,13.4]]}]}]}
+136ms ║║Executed virtual command log (1ms)
+138ms ║║Executed virtual command parseJson (0ms)
+145ms ║║Executed virtual command setVariable (2ms)
+151ms ║║Executed virtual command setVariable (3ms)
+157ms ║║Executed virtual command setVariable (3ms)
+164ms ║║Executed virtual command setVariable (3ms)
+170ms ║║Executed virtual command setVariable (2ms)
+172ms ║╚Execution stage complete. (56ms)
+174ms ║Setting up scheduled job for Thu, Mar 26 2020 @ 6:27:04 PM PDT (in 45.26s)
+259ms ╚Event processed successfully (260ms)


#10

I don’t know anything about influxDb, however a couple of thoughts,

Can you confirm the problem is not the db? could it be that the database is sometimes failing to return the data.

Is it worth putting a wait after the DB call, before trying to parse the returned data.

It almost looks as though the db request is an async request, but not sure if this could be the case.


#11

408 is timeout. How long does that query run with curl? Smartthings has an inherent 10 second timeout that cannot be changed.

Perhaps you’ll have to break it up into multiple calls that are faster. instead of select last(*) that times out you could do last(moisture) in one query, last(battery) in another, last(fertiziler) in another, etc. More code but might be more reliable.

Or maybe a different syntax. SELECT LAST(field_name), * from test_result GROUP BY *


#12

When running these queries with curl, it’s almost instantaneous, and I never have any delays. The returned JSON is not that big, see example:

{
"results": [
    {
        "statement_id": 0,
        "series": [
            {
                "name": "monitor_reading",
                "tags": {
                    "monitor": "Lime"
                },
                "columns": [
                    "time",
                    "last_battery",
                    "last_conductivity",
                    "last_light",
                    "last_moisture",
                    "last_temperature"
                ],
                "values": [
                    [
                        "2020-03-27T00:46:00Z",
                        94,
                        139,
                        780,
                        36,
                        14.5
                    ]
                ]
            }
        ]
    }
]

}

That can’t be too much text for webcore/ST to process is it?


#13

I guess I could break it up, but I would love to understand why this is working one minute and not the next. I have 6 of these sensors, and each has 5 attributes I’m interested in. Making 35 seperate API calls (even if it’s a local server) doesn’t seem like the best approach here.

My semi educated guess is that I’m running into some sort of async/call back issue here. Is there a method for setting variables based on callback in webcore?


#14

Weird one for sure.
Does the “last()" version always give you a 408 and the “last(“moisture”)” version always work? Or does the "last()” version sometimes work/sometimes fail?

If it sometimes works then you could try a loop and try it 5 or 10 times until it succeeds.


#15

I use this query everytime now and it works one minute and sometimes on several calls in a row, then stops working (and will keep not working) before suddenly working again…

SELECT last(*) FROM “monitor_reading” WHERE (“monitor” = ‘Lime’) AND time >= now() - 10m GROUP BY time(1m), “monitor” fill(none)

For the sake of simplicity, I’m going to shrink the query to:

SELECT last(*) FROM “monitor_reading” WHERE (“monitor” = ‘Lime’)"

I’ll test and see what happens.


#16

There seems to be no rhyme or reason to when this works and when it does not. I added a wait (5 or 10 seconds) after the web request, and now it returns null for http status code regardless of if it is successful or not. I have nothing but time today, is there a webcore documentation I can dive into?

   3/27/2020, 11:24:03 AM +71ms
+1ms 	╔Received event [Evans St].time = 1585333443665 with a delay of -595ms
+682ms 	║RunTime Analysis CS > 540ms > PS > 86ms > PE > 56ms > CE
+685ms 	║Runtime (41965 bytes) successfully initialized in 86ms (v0.3.110.20191009) (682ms)
+686ms 	║╔Execution stage started
+701ms 	║║Cancelling statement #28's schedules...
+718ms 	║║Sending internal web request to: 10.1.100.25:8086/query
+722ms 	║║Executed virtual command [Plant - Lime Tree].httpRequest (9ms)
+723ms 	║║Requesting a wake up for Fri, Mar 27 2020 @ 11:24:23 AM PDT (in 20.0s)
+731ms 	║╚Execution stage complete. (45ms)
+733ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:24:23 AM PDT (in 19.992s), with 1 more job pending
+742ms 	╚Event processed successfully (742ms)
3/27/2020, 11:23:31 AM +198ms
+0ms 	╔Received event [Evans St].wc_async_reply = httpRequest with a delay of 0ms
+10246ms 	║RunTime Analysis CS > 20ms > PS > 10068ms > PE > 158ms > CE
+10247ms 	║Piston waited at a semaphore for 10013ms
+10250ms 	║Runtime (42050 bytes) successfully initialized in 10068ms (v0.3.110.20191009) (10249ms)
+10251ms 	║╔Execution stage started
+10252ms 	║╚Execution stage complete. (1ms)
+10253ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:24:03 AM PDT (in 22.215s)
+10264ms 	╚Event processed successfully (10264ms)
3/27/2020, 11:23:31 AM +118ms
+1ms 	╔Received event [Evans St].time = 1585333412460 with a delay of -1342ms
+143ms 	║RunTime Analysis CS > 30ms > PS > 50ms > PE > 62ms > CE
+146ms 	║Runtime (41965 bytes) successfully initialized in 50ms (v0.3.110.20191009) (143ms)
+147ms 	║╔Execution stage started
+164ms 	║║null
+166ms 	║║Executed virtual command [Plant - Lime Tree].log (2ms)
+173ms 	║║[:]
+174ms 	║║Executed virtual command [Plant - Lime Tree].log (2ms)
+178ms 	║║Error parsing JSON data [:]
+179ms 	║║Executed virtual command [Plant - Lime Tree].parseJson (2ms)
+183ms 	║║Error retrieving JSON data part null
+188ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (3ms)
+192ms 	║║Error retrieving JSON data part null
+198ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (3ms)
+201ms 	║║Error retrieving JSON data part null
+206ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (3ms)
+210ms 	║║Error retrieving JSON data part null
+215ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (3ms)
+220ms 	║║Error retrieving JSON data part null
+225ms 	║║Calculating (decimal) 0.0 * (decimal) 1.8 >> (decimal) 0.0
+229ms 	║║Calculating (decimal) 0.0 + (decimal) 32.0 >> (decimal) 32.0
+234ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (3ms)
+273ms 	║║Executed physical command [Plant - Lime Tree].getBattery([0]) (35ms)
+274ms 	║║Executed [Plant - Lime Tree].getBattery (37ms)
+295ms 	║║Executed physical command [Plant - Lime Tree].changeMoisture([0]) (18ms)
+296ms 	║║Executed [Plant - Lime Tree].changeMoisture (19ms)
+315ms 	║║Executed physical command [Plant - Lime Tree].changeFert([0]) (16ms)
+316ms 	║║Executed [Plant - Lime Tree].changeFert (18ms)
+338ms 	║║Executed physical command [Plant - Lime Tree].changeLight([0]) (18ms)
+339ms 	║║Executed [Plant - Lime Tree].changeLight (20ms)
+360ms 	║║Executed physical command [Plant - Lime Tree].changeTemp([32.0]) (18ms)
+362ms 	║║Executed [Plant - Lime Tree].changeTemp (20ms)
+368ms 	║╚Execution stage complete. (221ms)
+369ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:24:03 AM PDT (in 32.178s)
+378ms 	╚Event processed successfully (377ms)
3/27/2020, 11:23:22 AM +266ms
+1ms 	╔Received event [Evans St].time = 1585333403251 with a delay of -985ms
+174ms 	║RunTime Analysis CS > 43ms > PS > 87ms > PE > 44ms > CE
+177ms 	║Runtime (41964 bytes) successfully initialized in 87ms (v0.3.110.20191009) (176ms)
+178ms 	║╔Execution stage started
+192ms 	║║Executed virtual command [Plant - Lime Tree].wait (0ms)
+193ms 	║║Requesting a wake up for Fri, Mar 27 2020 @ 11:23:32 AM PDT (in 10.0s)
+200ms 	║╚Execution stage complete. (23ms)
+203ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:23:32 AM PDT (in 9.992s), with 1 more job pending
+211ms 	╚Event processed successfully (211ms)
3/27/2020, 11:23:03 AM +59ms
+0ms 	╔Received event [Evans St].time = 1585333383665 with a delay of -606ms
+146ms 	║RunTime Analysis CS > 30ms > PS > 62ms > PE > 54ms > CE
+149ms 	║Runtime (41964 bytes) successfully initialized in 62ms (v0.3.110.20191009) (148ms)
+150ms 	║╔Execution stage started
+160ms 	║║Cancelling statement #28's schedules...
+186ms 	║║Sending internal web request to: 10.1.100.25:8086/query
+190ms 	║║Executed virtual command [Plant - Lime Tree].httpRequest (22ms)
+191ms 	║║Requesting a wake up for Fri, Mar 27 2020 @ 11:23:23 AM PDT (in 20.0s)
+196ms 	║╚Execution stage complete. (45ms)
+197ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:23:23 AM PDT (in 19.995s), with 1 more job pending
+207ms 	╚Event processed successfully (207ms)
3/27/2020, 11:22:43 AM +73ms
+1ms 	╔Received event [Evans St].wc_async_reply = httpRequest with a delay of 0ms
+112ms 	║RunTime Analysis CS > 13ms > PS > 39ms > PE > 60ms > CE
+115ms 	║Runtime (41969 bytes) successfully initialized in 39ms (v0.3.110.20191009) (114ms)
+117ms 	║╔Execution stage started
+118ms 	║╚Execution stage complete. (2ms)
+120ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:23:03 AM PDT (in 20.473s)
+131ms 	╚Event processed successfully (130ms)
3/27/2020, 11:22:30 AM +84ms
+0ms 	╔Received event [Evans St].time = 1585333351519 with a delay of -1435ms
+158ms 	║RunTime Analysis CS > 39ms > PS > 76ms > PE > 42ms > CE
+160ms 	║Runtime (41965 bytes) successfully initialized in 76ms (v0.3.110.20191009) (159ms)
+161ms 	║╔Execution stage started
+174ms 	║║null
+175ms 	║║Executed virtual command [Plant - Lime Tree].log (2ms)
+180ms 	║║[:]
+181ms 	║║Executed virtual command [Plant - Lime Tree].log (1ms)
+184ms 	║║Error parsing JSON data [:]
+184ms 	║║Executed virtual command [Plant - Lime Tree].parseJson (1ms)
+187ms 	║║Error retrieving JSON data part null
+191ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+194ms 	║║Error retrieving JSON data part null
+198ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (3ms)
+200ms 	║║Error retrieving JSON data part null
+205ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+207ms 	║║Error retrieving JSON data part null
+211ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+214ms 	║║Error retrieving JSON data part null
+218ms 	║║Calculating (decimal) 0.0 * (decimal) 1.8 >> (decimal) 0.0
+220ms 	║║Calculating (decimal) 0.0 + (decimal) 32.0 >> (decimal) 32.0
+224ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+781ms 	║║Executed physical command [Plant - Lime Tree].getBattery([0]) (554ms)
+782ms 	║║Executed [Plant - Lime Tree].getBattery (556ms)
+802ms 	║║Executed physical command [Plant - Lime Tree].changeMoisture([0]) (16ms)
+802ms 	║║Executed [Plant - Lime Tree].changeMoisture (18ms)
+822ms 	║║Executed physical command [Plant - Lime Tree].changeFert([0]) (17ms)
+823ms 	║║Executed [Plant - Lime Tree].changeFert (19ms)
+842ms 	║║Executed physical command [Plant - Lime Tree].changeLight([0]) (16ms)
+843ms 	║║Executed [Plant - Lime Tree].changeLight (18ms)
+862ms 	║║Executed physical command [Plant - Lime Tree].changeTemp([32.0]) (17ms)
+863ms 	║║Executed [Plant - Lime Tree].changeTemp (18ms)
+867ms 	║╚Execution stage complete. (706ms)
+868ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:23:03 AM PDT (in 32.713s)
+876ms 	╚Event processed successfully (876ms)
3/27/2020, 11:22:21 AM +211ms
+0ms 	╔Received event [Evans St].time = 1585333342238 with a delay of -1027ms
+289ms 	║RunTime Analysis CS > 72ms > PS > 172ms > PE > 45ms > CE
+292ms 	║Runtime (41967 bytes) successfully initialized in 172ms (v0.3.110.20191009) (291ms)
+293ms 	║╔Execution stage started
+306ms 	║║Executed virtual command [Plant - Lime Tree].wait (0ms)
+307ms 	║║Requesting a wake up for Fri, Mar 27 2020 @ 11:22:31 AM PDT (in 10.0s)
+395ms 	║╚Execution stage complete. (102ms)
+406ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:22:31 AM PDT (in 9.903s), with 1 more job pending
+415ms 	╚Event processed successfully (414ms)
3/27/2020, 11:22:02 AM +75ms
+1ms 	╔Received event [Evans St].time = 1585333323665 with a delay of -1590ms
+133ms 	║RunTime Analysis CS > 19ms > PS > 51ms > PE > 62ms > CE
+135ms 	║Runtime (41965 bytes) successfully initialized in 51ms (v0.3.110.20191009) (134ms)
+136ms 	║╔Execution stage started
+146ms 	║║Cancelling statement #28's schedules...
+158ms 	║║Sending internal web request to: 10.1.100.25:8086/query
+161ms 	║║Executed virtual command [Plant - Lime Tree].httpRequest (7ms)
+162ms 	║║Requesting a wake up for Fri, Mar 27 2020 @ 11:22:22 AM PDT (in 20.0s)
+167ms 	║╚Execution stage complete. (31ms)
+168ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:22:22 AM PDT (in 19.995s), with 1 more job pending
+176ms 	╚Event processed successfully (176ms)
3/27/2020, 11:21:32 AM +65ms
+1ms 	╔Received event [Evans St].time = 1585333291604 with a delay of 461ms
+151ms 	║RunTime Analysis CS > 27ms > PS > 57ms > PE > 67ms > CE
+154ms 	║Runtime (41969 bytes) successfully initialized in 57ms (v0.3.110.20191009) (152ms)
+156ms 	║╔Execution stage started
+173ms 	║║null
+174ms 	║║Executed virtual command [Plant - Lime Tree].log (2ms)
+181ms 	║║[:]
+182ms 	║║Executed virtual command [Plant - Lime Tree].log (2ms)
+187ms 	║║Error parsing JSON data [:]
+189ms 	║║Executed virtual command [Plant - Lime Tree].parseJson (3ms)
+192ms 	║║Error retrieving JSON data part null
+197ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (3ms)
+200ms 	║║Error retrieving JSON data part null
+204ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+207ms 	║║Error retrieving JSON data part null
+212ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+214ms 	║║Error retrieving JSON data part null
+219ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (3ms)
+223ms 	║║Error retrieving JSON data part null
+229ms 	║║Calculating (decimal) 0.0 * (decimal) 1.8 >> (decimal) 0.0
+233ms 	║║Calculating (decimal) 0.0 + (decimal) 32.0 >> (decimal) 32.0
+237ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+712ms 	║║Executed physical command [Plant - Lime Tree].getBattery([0]) (469ms)
+713ms 	║║Executed [Plant - Lime Tree].getBattery (471ms)
+738ms 	║║Executed physical command [Plant - Lime Tree].changeMoisture([0]) (21ms)
+739ms 	║║Executed [Plant - Lime Tree].changeMoisture (23ms)
+763ms 	║║Executed physical command [Plant - Lime Tree].changeFert([0]) (21ms)
+765ms 	║║Executed [Plant - Lime Tree].changeFert (23ms)
+789ms 	║║Executed physical command [Plant - Lime Tree].changeLight([0]) (21ms)
+790ms 	║║Executed [Plant - Lime Tree].changeLight (23ms)
+814ms 	║║Executed physical command [Plant - Lime Tree].changeTemp([32.0]) (21ms)
+815ms 	║║Executed [Plant - Lime Tree].changeTemp (22ms)
+818ms 	║╚Execution stage complete. (663ms)
+819ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:22:03 AM PDT (in 30.781s)
+826ms 	╚Event processed successfully (826ms)
3/27/2020, 11:21:29 AM +331ms
+0ms 	╔Received event [Evans St].wc_async_reply = httpRequest with a delay of 0ms
+112ms 	║RunTime Analysis CS > 15ms > PS > 43ms > PE > 54ms > CE
+114ms 	║Runtime (41975 bytes) successfully initialized in 43ms (v0.3.110.20191009) (113ms)
+115ms 	║╔Execution stage started
+116ms 	║╚Execution stage complete. (1ms)
+117ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:21:31 AM PDT (in 2.156s), with 1 more job pending
+128ms 	╚Event processed successfully (127ms)
3/27/2020, 11:21:21 AM +273ms
+1ms 	╔Received event [Evans St].time = 1585333282336 with a delay of -1063ms
+313ms 	║RunTime Analysis CS > 127ms > PS > 136ms > PE > 49ms > CE
+316ms 	║Runtime (41974 bytes) successfully initialized in 136ms (v0.3.110.20191009) (313ms)
+317ms 	║╔Execution stage started
+329ms 	║║Executed virtual command [Plant - Lime Tree].wait (0ms)
+330ms 	║║Requesting a wake up for Fri, Mar 27 2020 @ 11:21:31 AM PDT (in 10.0s)
+335ms 	║╚Execution stage complete. (19ms)
+337ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:21:31 AM PDT (in 9.995s), with 1 more job pending
+345ms 	╚Event processed successfully (345ms)
3/27/2020, 11:21:02 AM +70ms
+0ms 	╔Received event [Evans St].time = 1585333263665 with a delay of -1596ms
+238ms 	║RunTime Analysis CS > 87ms > PS > 101ms > PE > 51ms > CE
+241ms 	║Runtime (41973 bytes) successfully initialized in 101ms (v0.3.110.20191009) (239ms)
+241ms 	║╔Execution stage started
+251ms 	║║Cancelling statement #28's schedules...
+262ms 	║║Sending internal web request to: 10.1.100.25:8086/query
+264ms 	║║Executed virtual command [Plant - Lime Tree].httpRequest (6ms)
+265ms 	║║Requesting a wake up for Fri, Mar 27 2020 @ 11:21:22 AM PDT (in 20.0s)
+270ms 	║╚Execution stage complete. (29ms)
+272ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:21:22 AM PDT (in 19.995s), with 1 more job pending
+280ms 	╚Event processed successfully (280ms)
3/27/2020, 11:20:20 AM +110ms
+1ms 	╔Received event [Evans St].time = 1585333221433 with a delay of -1323ms
+396ms 	║RunTime Analysis CS > 117ms > PS > 228ms > PE > 51ms > CE
+399ms 	║Runtime (41968 bytes) successfully initialized in 228ms (v0.3.110.20191009) (396ms)
+400ms 	║╔Execution stage started
+416ms 	║║null
+417ms 	║║Executed virtual command [Plant - Lime Tree].log (2ms)
+425ms 	║║{"results":[{"statement_id":0,"series":[{"name":"monitor_reading","columns":["time","last_battery","last_conductivity","last_light","last_moisture","last_temperature"],"values":[["1970-01-01T00:00:00Z",94,83,4795,43,12.6]]}]}]}
+426ms 	║║Executed virtual command [Plant - Lime Tree].log (1ms)
+429ms 	║║Executed virtual command [Plant - Lime Tree].parseJson (1ms)
+435ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+441ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+447ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+454ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+460ms 	║║Calculating (decimal) 12.6 * (decimal) 1.8 >> (decimal) 22.68
+462ms 	║║Calculating (decimal) 22.68 + (decimal) 32.0 >> (decimal) 54.68
+467ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (3ms)
+4458ms 	║║Executed physical command [Plant - Lime Tree].getBattery([94]) (3988ms)
+4459ms 	║║Executed [Plant - Lime Tree].getBattery (3990ms)
+4484ms 	║║Executed physical command [Plant - Lime Tree].changeMoisture([43]) (22ms)
+4485ms 	║║Executed [Plant - Lime Tree].changeMoisture (24ms)
+4509ms 	║║Executed physical command [Plant - Lime Tree].changeFert([83]) (21ms)
+4510ms 	║║Executed [Plant - Lime Tree].changeFert (23ms)
+4534ms 	║║Executed physical command [Plant - Lime Tree].changeLight([4795]) (20ms)
+4535ms 	║║Executed [Plant - Lime Tree].changeLight (23ms)
+4558ms 	║║Executed physical command [Plant - Lime Tree].changeTemp([54.0]) (20ms)
+4559ms 	║║Executed [Plant - Lime Tree].changeTemp (22ms)
+4562ms 	║╚Execution stage complete. (4163ms)
+4564ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:21:03 AM PDT (in 38.992s)
+4572ms 	╚Event processed successfully (4571ms)
3/27/2020, 11:20:12 AM +400ms
+1ms 	╔Received event [Evans St].wc_async_reply = httpRequest with a delay of 0ms
+106ms 	║RunTime Analysis CS > 14ms > PS > 39ms > PE > 53ms > CE
+108ms 	║Runtime (41969 bytes) successfully initialized in 39ms (v0.3.110.20191009) (106ms)
+109ms 	║╔Execution stage started
+111ms 	║╚Execution stage complete. (1ms)
+112ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:20:21 AM PDT (in 8.922s), with 1 more job pending
+124ms 	╚Event processed successfully (124ms)
3/27/2020, 11:20:12 AM +211ms
+1ms 	╔Received event [Evans St].wc_async_reply = httpRequest with a delay of 0ms
+121ms 	║RunTime Analysis CS > 22ms > PS > 45ms > PE > 54ms > CE
+124ms 	║Runtime (41969 bytes) successfully initialized in 45ms (v0.3.110.20191009) (123ms)
+125ms 	║╔Execution stage started
+126ms 	║╚Execution stage complete. (2ms)
+127ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:20:21 AM PDT (in 9.095s), with 1 more job pending
+139ms 	╚Event processed successfully (139ms)
3/27/2020, 11:20:11 AM +911ms
+0ms 	╔Received event [Evans St].wc_async_reply = httpRequest with a delay of 0ms
+116ms 	║RunTime Analysis CS > 19ms > PS > 46ms > PE > 52ms > CE
+119ms 	║Runtime (41969 bytes) successfully initialized in 46ms (v0.3.110.20191009) (118ms)
+120ms 	║╔Execution stage started
+121ms 	║╚Execution stage complete. (2ms)
+122ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:20:21 AM PDT (in 9.4s), with 1 more job pending
+136ms 	╚Event processed successfully (136ms)
3/27/2020, 11:20:11 AM +523ms
+0ms 	╔Received event [Evans St].wc_async_reply = httpRequest with a delay of 0ms
+113ms 	║RunTime Analysis CS > 16ms > PS > 42ms > PE > 56ms > CE
+115ms 	║Runtime (41969 bytes) successfully initialized in 42ms (v0.3.110.20191009) (114ms)
+116ms 	║╔Execution stage started
+117ms 	║╚Execution stage complete. (1ms)
+119ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:20:21 AM PDT (in 9.792s), with 1 more job pending
+129ms 	╚Event processed successfully (129ms)
3/27/2020, 11:20:11 AM +288ms
+0ms 	╔Received event [Evans St].wc_async_reply = httpRequest with a delay of 0ms
+129ms 	║RunTime Analysis CS > 25ms > PS > 47ms > PE > 57ms > CE
+131ms 	║Runtime (41969 bytes) successfully initialized in 47ms (v0.3.110.20191009) (130ms)
+132ms 	║╔Execution stage started
+143ms 	║║Executed virtual command [Plant - Lime Tree].wait (0ms)
+145ms 	║║Requesting a wake up for Fri, Mar 27 2020 @ 11:20:21 AM PDT (in 10.0s)
+149ms 	║╚Execution stage complete. (17ms)
+151ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:20:21 AM PDT (in 9.995s), with 1 more job pending
+163ms 	╚Event processed successfully (163ms)
3/27/2020, 11:20:03 AM +137ms
+0ms 	╔Received event [Evans St].time = 1585333203665 with a delay of -528ms
+642ms 	║RunTime Analysis CS > 275ms > PS > 305ms > PE > 61ms > CE
+645ms 	║Runtime (41967 bytes) successfully initialized in 305ms (v0.3.110.20191009) (644ms)
+646ms 	║╔Execution stage started
+660ms 	║║Cancelling statement #28's schedules...
+921ms 	║║Sending internal web request to: 10.1.100.25:8086/query
+925ms 	║║Executed virtual command [Plant - Lime Tree].httpRequest (252ms)
+927ms 	║║Requesting a wake up for Fri, Mar 27 2020 @ 11:20:24 AM PDT (in 20.0s)
+932ms 	║╚Execution stage complete. (286ms)
+934ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:20:24 AM PDT (in 19.995s), with 1 more job pending
+941ms 	╚Event processed successfully (941ms)
3/27/2020, 11:19:30 AM +76ms
+0ms 	╔Received event [Evans St].time = 1585333171196 with a delay of -1121ms
+261ms 	║RunTime Analysis CS > 81ms > PS > 139ms > PE > 42ms > CE
+264ms 	║Runtime (41973 bytes) successfully initialized in 139ms (v0.3.110.20191009) (263ms)
+265ms 	║╔Execution stage started
+278ms 	║║null
+279ms 	║║Executed virtual command [Plant - Lime Tree].log (1ms)
+284ms 	║║[:]
+285ms 	║║Executed virtual command [Plant - Lime Tree].log (1ms)
+288ms 	║║Error parsing JSON data [:]
+288ms 	║║Executed virtual command [Plant - Lime Tree].parseJson (1ms)
+291ms 	║║Error retrieving JSON data part null
+296ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+298ms 	║║Error retrieving JSON data part null
+302ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+305ms 	║║Error retrieving JSON data part null
+309ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (3ms)
+312ms 	║║Error retrieving JSON data part null
+316ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+319ms 	║║Error retrieving JSON data part null
+323ms 	║║Calculating (decimal) 0.0 * (decimal) 1.8 >> (decimal) 0.0
+325ms 	║║Calculating (decimal) 0.0 + (decimal) 32.0 >> (decimal) 32.0
+329ms 	║║Executed virtual command [Plant - Lime Tree].setVariable (2ms)
+2146ms 	║║Executed physical command [Plant - Lime Tree].getBattery([0]) (1814ms)
+2147ms 	║║Executed [Plant - Lime Tree].getBattery (1816ms)
+2175ms 	║║Executed physical command [Plant - Lime Tree].changeMoisture([0]) (23ms)
+2176ms 	║║Executed [Plant - Lime Tree].changeMoisture (26ms)
+2204ms 	║║Executed physical command [Plant - Lime Tree].changeFert([0]) (23ms)
+2205ms 	║║Executed [Plant - Lime Tree].changeFert (26ms)
+2230ms 	║║Executed physical command [Plant - Lime Tree].changeLight([0]) (22ms)
+2231ms 	║║Executed [Plant - Lime Tree].changeLight (23ms)
+2258ms 	║║Executed physical command [Plant - Lime Tree].changeTemp([32.0]) (23ms)
+2259ms 	║║Executed [Plant - Lime Tree].changeTemp (25ms)
+2264ms 	║╚Execution stage complete. (1999ms)
+2266ms 	║Setting up scheduled job for Fri, Mar 27 2020 @ 11:20:03 AM PDT (in 31.324s)
+2274ms 	╚Event processed successfully (2273ms)
3/27/2020, 11:19:21 AM +47ms

#17

I’d skip the wait, at least that long. If its more than 2-3 seconds the piston doesn’t actually wait. It schedules itself the run again in 10 seconds.

Try a loop. Something like this: