Thanks, I had update = 10000 because mqtt value is updated every 10sec. AutoScale would be a great option but it does not work in my case... I have slightly changed my code to change the labale based on a negative net consumption (sell to the grid) and positive consumption (buy from the grid). Thanksbalala wrote: ↑March 20th, 2022, 4:57 pm See the added MeasureName and AutoScale options as well as the replaced Text option of the [mqttOutput] meter.
With the AutoScale=2 option, the meter will show the consumption into W if it is below 1000 W = 1 kW, or in kW, if it is above.
Additional note: Update=10000 in the [Rainmeter] section is definitely not a good approach. It means you get the skin updated once on every 10 seconds. To can use the skin to see the real consumption, I'd tend to recommend to use the default Update=1000.
Code: Select all
[Rainmeter]
Update=1000
[Style1]
FontColor=255,255,255
FontFace=Segoe UI
FontSize=15
AntiAlias=1
[mqttServer]
Measure=Plugin
Plugin=MqttClient
;Connection Details
Server=192.168.1.126
Port=1883
Username
Password=
;Update the meter when the client connects:
OnConnect=[!UpdateMeter mqttOutput][!Redraw]
;Update the meter as soon as a message arrives:
OnMessage=[!UpdateMeter mqttOutput][!Redraw]
;Subscribe to kostal/Grid_P
[mqttTopic1]
Measure=Plugin
Plugin=MqttClient
ParentName=mqttServer
Topic=kostal/Grid_P
;Label based on Net Consumption (Buy if > 0 / Sell if < 0)
IfCondition=[mqttTopic1]<0
IfTrueAction=[!SetOption MeterLabel Text "Sell:"]
IfFalseAction=[!SetOption MeterLabel Text "Buy:"]
;Format with thousands separators and no decimal => 2345.4 to 2'345
;https://forum.rainmeter.net/viewtopic.php?t=17379
;RegExpSubstitute=1
;Substitute="\d{1,3}(?=(\d{3})+\.)":"\0'","(\d*)\.(\d*)":"\1"
;DynamicVariables=1
[MeterOutput]
Meter=String
MeasureName=mqttTopic1
X=70
Y=5
W=350
H=30
MeterStyle=Style1
AutoScale=2
NumOfDecimals=0
Text=%1W
DynamicVariables=1
[MeterLabel]
Meter=String
X=5
Y=5
W=350
H=30
MeterStyle=Style1