Roof Heater - Add past 24h of Snow to the logic


#1

1) Give a description of the problem
I currently have a roof/gutter heater attached to a GE Smart Switch. Currently, I am turning it on if the temp is <38F and turning it off when it goes above 45F. I would like to add a logical AND for if there was more than 1" of snow reported in past 24h - not sure if this is possible.

I run a Wunderground PWS site and get the temp from what I upload via rapidfire updates and this is working fine - but it is inefficient as it turns on regardless of recent snowfall

Here is my working temp based solution

I’d love to add around line 27
AND
If SNOW_IN_PAST_24h > 1"

Not entirely sure (a) if this is available from the Weather API and how I would use it. I’ve looked and it appears that all the snow data is forecast related (Future) not past accumulation

Thoughts?


Weather Snow Piston
#2

@c1arkbar is the expert on all things weather but snow fall seems to be all forecast.

why dont you store the snow forecast from previous day and use that data over the next 24 hours along with the temperature data on whether the heater should be turned on?

not suggesting that will be perfect but at least better than just checking temperature alone.


#3

$weather.yesterday.history.observations.snow

This will return a data set over the past 24 hours like below. I have not had any snow here so mine are all zeros.

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

More info on the yesterday attribute of the weather can be found here. This has not been added to the Weather API yet. But to get you started you just need to use this as a base

$weather.yesterday.history.observations

Then you can add anything you find under the observations table on the above website to get the info you want.

If you just want to limit the data then you would add an [index] after observations.

Hope this helps!


#4

@c1arkbar
So if I am groking this right, I could create a variable $yesterdaySnow and do

$yesterdaySnow = sum($weather.yesterday.observations.snow)

then add a condition of

AND
$yesterdaySnow is greater than 1

If that is correct I could probably add

$todaySnow = $weather.hourly.observations.snow

and then add the two variables for the past 2d of snow

Am I groking this right and going up the right path?


#5

It looks right to me. I can’t test the adding function right now because all mine are 0s. So I don’t know if that part is working or not.

I think you are definitely heading in the correct direction tho


#6

Well (un)fortunately we are getting some snow this week here in North East PA so I may get a chance to test it out … I could fake it out by doing something along the lines of

$yesterdaySnow = sum($weather.yesterday.observations.snow)
$yesterdaySnow = sum($yesterdaySnow + 1)

just to see if the logic turns on the switch and remove the increment after I get some snow … :mountain_snow: :snowflake:


#7

Here is a screenshot of what I am going with until i get some of the white stuff to do a true validation … if anything looks inefficient or completely wonky I’d appreciate a heads up … or a smack to the back of the noggin :slight_smile:

If this ends up being a viable solution, I’ll mark it solved


#8

dont think sum is list aware.


#9

This was also my concern. Tried the function with the temperature data instead. It unfortunately does not work. Always returns a 0

You can add them up yourself however. You can use a for loop to go through adding them up.


#10

Well :poop:

I’ll have to try and hack together a for loop for this then … meh - if only Wunderground API would have a simple X snow fell yesterday and Y snow fell today

Edit: Ok, how exactly would this work via the Dashboard/IDE - I know how to make the for loops show (advanced statements) but I am having a hellova time working through what to put where in the IDE … meh


#11

Create a blank integer variable and one to accumulate your totals.

Start at 0
End at 23
Step 1

Use variable above for counting

Then your action would be setting the variable and adding it to itself.

$weather.yesterday.history.observations[countingVariable].snow


#12

Thanks – will do that when I get home … any way of doing the hourly observation for today, I would have done something along the lines of

var todaySnow = 0;
for (var i = 0; i < weather.hourly.observations.snow.length; i++){
todaySnow += $weather.hourly.observations.snow[i];
}


#13

It depends when you want to run this piston. In reality you only need to store current observations and at the end of the day you would swap that info into the yesterday variable.

One idea that comes to mind is having a piston that runs every hour and grabs the current condition for snow and saves it to a variable.

Then at midnight or whenever empty today’s variable into yesterday’s variable.


#14

Any luck coming up with a piston for this? I need to do the same thing! If so, please post the piston

Thanks


#15

Not yet … have to find a couple hours to work out how to implement the logic with the WebCore interface :wink:


Ok, I am a good hack, but my understanding of WC is still growing and having trouble with this one … if anyone has a sample that does something similar with the weather API (adding up lists, etc) I’d love a pointer in the right direction


#16

Maybe this is too simple… But I think your syntax is incomplete. I believe you need to add units to the end of the weather requests…
I tried it, and we did receive snow yesterday here in Michigan, and did not get teh correct result…

Returns
Returns the forecasted amount of snow for the day. Add .cm or .in to the end for metric and imperial respectively.


#17

For the yesterday calls I do not think it is needed as we were receiving the data … (i’ve tried it just to be sure)

Wunderground has a forecast call that I tried playing with, assuming the syntax would be along the lines of

$weather.forecast.simpleforecast.snow_allday

which does not seem to return anything either - wondering if Wunderground is experiencing issues again or am I just losing my mind :wink:

For the time being I am going to leave it with Temp control only (and right now in the North East it will just be on … as hell froze over) and look for another snow related API outside of Wunderground to call and see if I can get something more stable/usable

If anyone finds a way to do this with the WC Wunderground calls please do post it here :slight_smile:


#18

Ok so assuming the yesterday call is working and actually receives data (just found this thread and I didn’t have snow yesterday…)

This expression will remove all non-digit characters from the list of snowfall totals, essentially making the string a 23 digit long number:

replace($weather.yesterday.history.observations.snow,"/\\D/","")

So you will get something like “00000000000000001000000” if you had an inch of snow at 5PM the day before. So in order to see if there was snow yesterday, just check if that expression evaluates to greater than zero. If someone needs a piston example let me know, I am working on one and I’ll post it if there is desire.


#19

Here is a piston, slightly different than my initial solution above, but this probably works better for the real world. EDIT: My previous piston posted here was ineffiecent, didnt realize I could enumerate the api call. This piston will directly sum up the total snowfall for the previous day and put it in the variable “SnowfallTotal”

You could have the piston save SnowfallTotal to a global variable every morning (It’s set to run at 1AM right now) and then use that in any other piston where you need the number.

EDIT: Also @JohnHoke, the snow forecast call looks like:

$weather.forecast.forecast.simpleforecast.forecastday[i].snow_allday

where “i” in the brackets is the day you want (0 for today up to 3 for 3 days from now). I you leave the brackets off it returns four forecast days in an array


#20

@xomnia Thank you!

Here is what I have done so far … perhaps not the most pretty or elegant - but it works :slight_smile:

I created 1 Piston to generate the global variables (Living up here :mountain_snow: I may have other uses for the snow totals)

Then I use them to control the heater in this piston

Previously I was testing for temperature as well, but that is no longer necessary with this as if it snowed in the past 48h chances are I need to turn the heater on :snowman_with_snow:

If there is anything else that can improve this … I’m all ears

Thanks again!