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
Items:
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.
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.
@rossko57
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”
when
Item BatteryVDC changed
then
get_voltage_register = BatteryVDC.state.toString();
conversion = Integer.valueOf(get_voltage_register);
BatteryVDC_Chart.postUpdate(conversion)
end
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")
when
Item BatteryVDC changed
then
val trans = transform(“MAP”, “Batteryvoltage.map”, BatteryVDC.state.toString);
BatteryVDC_Chart.postUpdate(trans)
end
And the chart now displays “BatterVDC_Chart” which is the transformed value