Grafana + InfluxDB + Node-Red

Is it possible to get values from this graph?

Weird, I get:
11%20PM

Are you storing numbers or strings to InfluxDB?

I don't know.
I create my object like this:

 msg.payload={
                  TIME:context.get('time_tick')||0, 
               AMBIENT:context.get('ambient')||0,
               BREWBOX:context.get('brewbox')||0,
            BREWBUCKET:context.get('brewbucket')||0,
              SETPOINT:context.get('setpoint')||0,
                  HEAT:context.get('heat')||0,
                  COOL:context.get('cool')||0}

and send it to influxdb. They are all numbers.
Can I specify a data type?

Feed them into a debug node and check if they are numbers, I can't see how you are defining them as they are context variables.

You were right, I was sending text. Now to workout how to send numbers.
Thanks,

Thanks ghayne, this looks much better:

This will convert text to numbers:
22%20PM

The $trim removes leading spaces.

Since this is in a function node already I think it can done by using, for example,
AMBIENT:Number(context.get('ambient'))
or the equivalent when writing it to the context.

1 Like

I convert C to F in a function just before the function I use to build my object. How I solved the text to number is on line 4.

var c = msg.payload;
var f;
f = (c*1.8)+32;
f.toFixed(2);
node.status({fill:"red",shape:"ring",text:f});
msg.topic = "ambient";
msg.payload = f;
return msg;

As the kids used to say, there must be a bazillion ways to do it.

Well, the toFixed(...) function returns a number as a truncated/formatted string ... which I think is the opposite of what Colin is suggesting.

As for converting temperature scales, the "bazillion+1" way I like is to use a range node, configured to map from 0 .. 100 to 32 .. 212 -- fwiw

I assume that will return a number, without fail. After living in a strict data type world js is a little squirrley for me.

And here is thought JS meant "JavaScript" -- not jittery squirrel :wink:

1 Like

hahahaha! I like your version better. :slight_smile:

The result of that will always be a number (except it could be NaN if it can't work it out). It will never be a string. As Shrikus says the the purpose of toFixed() is to convert a number to a string with the given number of digits (usually for display).
I suggest not removing digits from values unless it is just for display. If you remove digits before saving in a database then you will never be able to see the value to full precision. Grafana allows you to specify precision when displaying values. Also don't remove precision if the value is going to a control loop, you just make it harder for the controller to work out what to do by not giving it all the information that is available.

Almost there.
I would like to change my power series from F to % and to 2 decimal points for all values in the window. I'm not sure how to do that since I didn't assign F to it. Secondarily I'd like to get the right Y axis to show power so I can scale it better.
Any suggestions?

You can have two y axes, one on the left and one on the right and assign each channel to one or the other. Setup in the Axes tab.
None of mine have any unit information. Are you definitely just sending numeric values to influx. Put debug node on the input and check. Otherwise not sure where that is setup.
Number of decimal places is setup on the Legends tab.

Got it.

I have the retention set to 1d I think. That should be enough for a good graph.

Great. You can remove the shading under the lines (if you want to) by setting Fill to 0 on the Display tab.

If that is real data using the ranged cool output as previously discussed (so only 5% of actual cool is available) and it needs virtually full power (ie 5%) to maintain the setpoint then I think you need to increase the max cool power a bit. Possibly 7.5%, otherwise it might not be able to maintain the setpoint if your ambient goes up any more, plus, as it is, it would presumably take a long time to cool down on startup from ambient.

Yes, it is real data. The cool may be misleading. I didn't change the scale so 98% is actually 2% in a range of 0% to 5%. In the graph below "Power" is scaled from 0% to 5%. The scale on the graph should change once the 100% data passes 1d retention.

Last night the temperatures were steady so I set the setpoint to 64F which was about 1F below the brewbucket temp. I think I saw how to expand the graph from 6 hours but now I can't find it.
When I initially start a batch of beer it is just coming off the boil so the temperature, especially in summer, may be several degrees above the desired fermentation temp. My concern is that 5% or even 7.5% power may take to long to reach temp. The time between boil and fermentation temperature is a vulnerable time for infection and should be minimized, though in practice I've never lost a batch because of it.