It is currently April 16th, 2024, 6:10 am

How to use the Histogram with two measures correctly?

Get help with creating, editing & fixing problems with skins
yankee
Posts: 1
Joined: December 10th, 2020, 8:39 am

How to use the Histogram with two measures correctly?

Post by yankee »

Hi,

I am trying to visualize the electricity production from my photovoltaic generator and the electricity consumption of my house using a histogram. Here is what I got:
screenshot-openwb-rong.png
The idea is quite simple: Display electricity I produce and consume myself in yellow, electricity I produce and feed into the grid in green and electricity I consume from the grid in red. It seems, that the histogram is the perfect fit.

In the image above, the current production is 712W, the current consumption is 1072W. So I am clearly in the area where I consume more electricity than I produce, so I should not see any green, but should see some red. Also while these values do change of course, in the time frame shown in the histogram, I believe production was always lower than consumption.

While I am writing this electricity generation increases and with the moment that production becomes greater than consumption, suddenly the colors all changed and it looks better now:
screenshot-openwb-better.png
But why?

Here is my skin:

Code: Select all

; General
; =======

[Rainmeter]
Update=10000
BackgroundMode=2
SolidColor=000000

[Metadata]
Name=MqttPlugin Basic Example
Author=yankee
Information=PV Consumption & Production with data from OpenWB
License=MIT License
Version=0.0.1

[Variables]
colorExport=0,128,0
colorImport=255,0,0
colorSelfConsumption=255,255,0
barWidth=120
maxProduction=75000
maxConsumption=4000

[mqttServer]
Measure=Plugin
Plugin=MqttClient
Server=MY_MQTT_SERVER
OnMessage=[!Update][!Redraw]

; Measures
; ========

[powerImport]
Measure=Plugin
Plugin=MqttClient
ParentName=mqttServer
Topic=openWB/evu/W

[pvConsumption]
Measure=Plugin
Plugin=MqttClient
ParentName=mqttServer
Topic=openWB/pv/W

[powerProduction]
Measure=Calc
Formula=pvConsumption * -1
MinValue=0
MaxValue=#maxProduction#

[powerConsumption]
Measure=Calc
Formula=powerImport + powerProduction
MinValue=0
MaxValue=#maxConsumption#

[isImport]
Measure=Calc
Formula=powerConsumption < powerProduction ? 0 : 1
IfBelowValue=1
IfBelowAction=[!SetOption consumptionBar BarColor #colorExport#][!Redraw]
IfAboveValue=0
IfAboveAction=[!SetOption consumptionBar BarColor #colorImport#][!Redraw]


; Meters
; ======

[background]
Meter=Shape
Shape=Rectangle 0,0,130,200 | Fill Color 0,0,0

[graph]
Meter=Histogram
AutoScale=1
MeasureName=powerProduction
MeasureName2=powerConsumption
PrimaryColor=#colorExport#
SecondaryColor=#colorImport#
BothColor=#colorSelfConsumption#
X=5
Y=0
W=#barWidth#
H=100

[productionLabel]
Meter=STRING
MeasureName=powerProduction
X=5
Y=110
H=10
W=#barWidth#
FontColor=FFFFFF
Text="Produktion: %1 W"

[productionBar]
Meter=BAR
MeasureName=powerProduction
X=5
Y=130
W=#barWidth#
H=10
BarOrientation=Horizontal
BarColor=#colorExport#
SolidColor=150,150,150,255

[consumptionLabel]
Meter=STRING
MeasureName=powerConsumption
X=5
Y=150
H=10
W=#barWidth#
FontColor=FFFFFF
Text="Verbrauch: %1 W"

[consumptionBar]
Meter=BAR
MeasureName=powerConsumption
X=5
Y=170
H=10
W=#barWidth#
BarOrientation=Horizontal
BarColor=#colorImport#
SolidColor=150,150,150,255
So the manual for histogram unfortunately does not really explain how this graph works. But I noticed that it says:
The measure(s) used must be able to return percentual values.
So maybe it does not work with absolute values and actually just the scaling is all wrong. So I added:

Code: Select all

[powerConsumptionRelativeToProduction]
Measure=Calc
Formula=powerConsumption
MinValue=0
MaxValue=#maxProduction#
and then used that as "MeasureName2" for the histogram, so that both values will have the same min&max values. But this does not seem to have any effect at all. Then I wonder, why the measures need to be able to return percentual values, if these are not used?
You do not have the required permissions to view the files attached to this post.