FHEM Forum

FHEM => English Corner => Thema gestartet von: Wallyllama am 23 März 2021, 06:09:23

Titel: Scaling data in svg plot. ( unit conversion )
Beitrag von: Wallyllama am 23 März 2021, 06:09:23
I have a bme280 tenp/pressure/humidity sensor reporting via MQTT. I graph them with gplot. Sofar, so good. The problem is pressure is reported in Pascals. I could modify the code that reads the me, but I'm hoping there is a way to app,y a scale to each reading as the gis made. made. For example multiplying Pascals by 0.00296 gives in hes of mercury, or dividingb by100 gives hPa,
Titel: Antw:Scaling data in svg plot. ( unit conversion )
Beitrag von: xenos1984 am 23 März 2021, 07:17:49
You can use the fourth parameter in a plot data entry to specify a function, which is applied to each data point. For example, if your plot line reads


#FileLog 4:pressure:0:


you can divide each pressure value by 100 like this:


#FileLog 4:pressure:0:($fld[3]*0.01)
Titel: Antw:Scaling data in svg plot. ( unit conversion )
Beitrag von: rudolfkoenig am 23 März 2021, 08:51:38
The function field is also present in the SVG-Editor, it is the last text-input field in the row.
Note: $fld[ x ] is a perl array, the index starts with 0.
Titel: Antw:Scaling data in svg plot. ( unit conversion )
Beitrag von: Wallyllama am 24 März 2021, 14:51:57
perfect! thank you, I knew it would be somewhat obvious once i knew the answer.  :)    oh and sorry about duplicating this. I don't see that I can delete the other one.   :(
Titel: Aw: Scaling data in svg plot. ( unit conversion )
Beitrag von: EmCeBeh am 24 März 2023, 01:36:54
I am trying to accomplish the same thing, but I am using dbLogging.

Readings come from a KM200, so they have these weird names with slashes.

Here is the excerpt from the Gplot file.
But I am still getting the normal value

    #DBLogging LANiMB:/heatSources/workingTime/totalSystem::(fld[1]*0.001)
    plot "<IN>" using 1:2 axes x1y1 title 'Central Heating' ls l2 lw 1 with steps

Also this did not work:

    #DBLogging LANiMB:/heatSources/workingTime/totalSystem::
    plot "<IN>" using 1:(2/1000) axes x1y1 title 'Central Heating' ls l2 lw 1 with steps


I know this is a 2-year old thread, but it seemed fitting to ask here, googling will lead you here.
Titel: Aw: Scaling data in svg plot. ( unit conversion )
Beitrag von: betateilchen am 25 März 2023, 17:40:45
Please do not modify the plot... line unless you really know, what you do.

$fld is not available in plots based on DbLog. Instead you have to adjust the value itself, which is available as $val.

E.g. like this to divide by 100:

#DbLog LANiMB:/heatSources/workingTime/totalSystem:::$val=$val/100