Variable isn't incrimenting


#1

1) Give a description of the problem
A variable that’s supposed to incriment, isn’t

2) What is the expected behavior?
I’m using the Weather API to get the hourly snowfall total and incrimenting a snow total variable, when 1 inch falls in one hour, its supposted to add that to the pervious snow total

3) What is happening/not happening?
The variable is not incrimenting, its just overwriting with the current hour’s snow total.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
11/16/2018, 5:04:56 AM +79ms
+390ms ║It has snowed 0.00 inches in the past hour
+406ms ║Nightly snowfall total is now: 0
11/16/2018, 4:04:57 AM +79ms
+383ms ║It has snowed 0.01 inches in the past hour
+397ms ║Nightly snowfall total is now: 0.01
11/16/2018, 3:04:58 AM +61ms
+364ms ║It has snowed 0.01 inches in the past hour
+379ms ║Nightly snowfall total is now: 0.01
11/16/2018, 2:04:58 AM +91ms
+850ms ║It has snowed 0.01 inches in the past hour
+864ms ║Nightly snowfall total is now: 0.01
11/16/2018, 1:04:59 AM +119ms
+380ms ║It has snowed 0.01 inches in the past hour
+394ms ║Nightly snowfall total is now: 0.01


#2

Nothing stands out when I looked at it. Only thing I’d suggest is to add a Log to console snowTotal and the decimal($weather.conditions....) before Line 35 just to see the data.


#3

This is because you hard coded a zero on line 17, which basically resets the variable each time it runs. You can change that line to this:

temp

(Just be aware that it will keep adding indefinitely unless you reset the number occasionally)


#4

I was thinking it would stay in the while loop until next day?


#5

I see what you mean. but from the log, it looks like it starts at the top (and resets to zero) each cycle.