Display mysql with two lines in one graph

Hi there,

i am pretty new to Node-RED but with a lot of searching and testing i got pretty far. My Goal is now to query data from a MariaDB inserted by Node Red earlier. The table looks like this:
image

The data inserted are heating related: current temperature (Temperatur) and Valve (Ventil) and i would love to have the graph showing both as separate line within the same graph.
My sql query sends me back an object containing the rows expected:
image

Google told me to create a "change" Node to format the data but i assume it was designed for a table where one row contains ALL the data to display at once which is not the case for me as it is in two seperate rows. I was hoping the following would do it but this is unfortunately not doing the trick:

(
  $series := [
    { "Temperatur": "Wert", "label": "Wert1 label" },
    { "Ventil": "Wert", "label": "Wert2 label" }
  ];
  $xaxis := "timestamp";
  [
    {
      "series": $series.label,
      "data": $series.[
        (
          $yaxis := $.field;
          $$.payload.{
            "x": $lookup($, $xaxis),
            "y": $lookup($, $yaxis)
          }
        )
      ]
    }
  ]
)

I believe i have to edit the change node, split the data in two topics and connect this to the graph to display it - but i have no clue how the function need to look like. I know i can query the database twice and select upfront the right rows but i would like to save bandwith and "split" based on a single query. Can anyone help? Appreciate any feedback!

Hi @oma, welcome to the forum.

this topic has been covered many many times - search the forum.

Here is one such solution

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.