[SOLVED] Charting a transformed value (D1 mini A0)

Hi, I have a D1 mini that controls my change over from the Utility to the Inverter in the event of a power outage.
The actual change over controls works as intended but i also have the battery voltage on the A0 pin of the D1. The raw input is 0-1024

String BatteryVDC “Battery Voltage [MAP(Batteryvoltage.map):%s]” (Backup,BackUpLights) {channel=“mqtt:topic:0e16f822:SENSOR”}

The Json transformation is done in the MQTT2.4 binding in paperUI and then i transform the value to a usable number using a Map transformation.


But now i would like to chart this transformed value but the chart is showing the input to the string instead of the output.


How would i change the transformed string to input into another “dummy” string that i could then chart as a usable value?

Apologies if this is trivial, iv’e tried a few things but i couldn’t get it to work.


Try creating the dummy item as a Number, rather than a string, item and use it for the chart.

Would you mind helping me write the rule to post the update from the string to the number?
I think i tried it but could have been a syntax error on my part.

Rough attempt from cell phone.:upside_down_face: Give it a try and post any errors if not working.

rule "Chart"
    Item BatteryVCD received update

Another attempt if the first doesn’t work:

rule "Chart"
    Item BatteryVCD changed
    var battery = BatteryVCD.state as Number

Also, don’t forget to craete the Proxy (dummy) item DummyBattery or whatever name you want.

Doesn’t such ommit the needed transformation?

After a second thoughts,:crazy_face: yep your correct.

Sorry, was away for the weekend.
So i tried a few things again;

  • I changed the transformation map to a dimensionless number.

  • I added the rule:
    Item BatteryVDC received update

but i got this error

Then i changed the rule to just send a broadcast notification when the item is updated and for sure my phone lit up.

So i know

  1. The rule fires on the update of the string (BatteryVDC)

  2. The Item BatteryVDC_Chart is defined correctly

The problem is with


Any help would be appreciated.

Presumably it is the .state of BatteryVDC you are interested in?

Yes it is but the state is transformed through a JSON path in the MQTT2 binding and then mapped with a MAPtransformation.
So the input of that string is 0-1024 but the transformed output is 0-14.99 (Volts DC)

I found another post also trying to change a string to a number i wrote a new rule

var Number conversion
var String get_voltage_register
rule “conversion”
Item BatteryVDC changed
get_voltage_register = BatteryVDC.state.toString();
conversion = Integer.valueOf(get_voltage_register);

No errors this time but i still get the input to the string, not the output of the string

BatteryVDC_Chart is what I guess you are showing us, it has a value of 5.00 V
You were expecting something else?

I can see a complication, in that you chose to make BatteryVDC_Chart as a Number:ElectricPotential type, rhat than just a Number.
That means you really ought to update it specifying the unit of measurement, otherwise it has to guess - V, mV, kV?

The postUpdate should accept a string for your Number, with UoM, try
BatteryVDC_Chart.postUpdate( BatteryVDC.state.toString + " | V")

So i found a way: Essentially i changed the the place that the transformation is done from the items file to a rule.


String BatteryVDC “Battery Voltage_Register value” {channel=“mqtt:topic:0e16f822:SENSOR” }
Number:ElectricPotential BatteryVDC_Chart “Battery Voltage [%.1f V]” (Backup)


rule “conversion”

Item BatteryVDC changed
val trans = transform(“MAP”, “Batteryvoltage.map”, BatteryVDC.state.toString);

And the chart now displays “BatterVDC_Chart” which is the transformed value


Now i just need to get the dynamic icon working.

Thank you for taking the time to help my guys, much appreciated.

1 Like