How to design piston that’ll capture minimum/maximum data


#1

So here are two pistons that myself and another member of a Facebook group came up with for trying to capture min and max temperatures on a daily basis. Nothing historical but simple push notification and piston state representation. Problems are I’m not sure what the correct information is partly because they’ve both been giving different temperatures each day. Which way is best? Is there an easy way to confirm/find out for sure besides scrolling through each temperature in device history?

PISTON A

PISTON B


#2

Just to note I went through data for yesterday and neither one captured the correct information. Can anyone please tell me the right way to do this?

High for yesterday was 73.9 and low was 71.7 yet this is how the pistons reported it. (B on top, A on bottom).


#3

You need to compare it against something for the high temp.

IF motionSensor temp rises AND
motionSensor’s temp is > tempHigh
set tempHigh = motion sensor’s temp

EDIT:, The “B” piston looks like it should work. Just make it a float variable (aka ‘decimal’)


#4

@allrak Yeah I was wondering if the integer was causing issues. Should I change it to dynamic? For now I’ve changed it to decimal.


#5

Change it to decimal and give it a try.


#6

@allrak Can I ask one more question - do you use Fuel Streams? I was wondering if you could use this method to add data to fuel Stream? Currently I add it based on a timer.


#7

I don’t really use fuel streams, I’m more of an influxdb/grafana person. But there’s no reason it shouldn’t write to a fuel stream in the IF code block.

IF temp sensor's temp rises above (highTemp)
  then
     set variable (highTemp) = temp sensor's temp
     write data point (highTemp) to fuel stream <whatever>

keep in mind, you’ll have multiple datapoints written per day to the fuel stream. (highTemp) will change throughout the day


#8

@allrak since I’ve got you right here can I ask you an off topic question. How can I change the format of this number to only allow so many decimal places? Maybe three X.XXX?

Here’s the piston.


#9

webcore


#10

In your expression box, you’ll need to wrap it like this:
(round([zooz - Sump Pump : voltage],2))


#11

@allrak can I trouble you again? Maybe this is or isn’t the same as my last question but is there a way to make this so when it says zero it doesn’t up this way? I’d like it to either show as “0” or even “0.0”.


#12

so when you’re setting the piston state, you’re literally adding strings (text) together (even if that text is a ‘number’), hence the “000”.
Go numeric on that thing…

sum([zooz - Sump Pump : power], [Bedroom - Fan : power])

Lots of stuff you can do with the built-in functions:
https://wiki.webcore.co/Functions#sum

EDIT: or just remove the quote before Bedroom Air and after Christmas Lights


#13

@allrak removed the quotes but then lost the “W” at the end.


#14

Went with the sum() and it worked out well. Thanks again for your help.


#15

It sounds like your piston is running smoothly, but for others who may find this thread later, we also have the max() and min() commands to get the highest/lowest number from a list. I use this technique with the barometric pressure, since the current pressure means nothing without also knowing the previous data.

temp


#16

@WCmore tell me more about this because I’m about to hit you up on the other piston we were working on.


#17

I don’t think max() or min() is the solution to your piston.
(It requires a stored list of numbers to work)

I use it for my barometric pressure, because I am using PHP to draw a graph, and I want to “zoom in” based on the lowest and highest numbers from the previous 3 days.

temp

This piston is quite complex because I have to store the previous 70 data points (one per hour).