Please, just examine the channel type to find out what you’re dealing with.
No, your JS will not work as it is; as we’ve already discussed if you are trying to feed output into a Number:Energy you need to add units if you want a predictable result.
Longer story.
So far as I can make out from actually reading the Fronius binding docs
inverterdatachannelpac
is a plain ordinary number type channel.
This will gives us numeric updates with no units.
So far as I can make out from actually reading the Fronius binding docs, it represents the power not the energy. I think you know that too from the Item naming and labelling.
So Number:Energy
would never be the appropriate Item type.
Assuming you want instead to redefine your Item to use the more appropriate Number:Power
Item type, let’s press on.
So you link the number channel to Number:Power Item, what happens? The channel updates it with a plain number, say 5000, that’s all. But that Item type demands a unit. So it will stick on a default unit, if it can find one in your Item’s state description. It doesn’t matter if you gave it W or kW or horsepower, you will get 5000 of them.
You know the plain number actually means Watts I assume? But you’d prefer a display in kW. That’s fine.
But you can’t do it automatically in this set up because you have chosen mis-matched channel type and Item type. It can’t happen because the system does not know that plain 5000 means 5000W, it’s just a number.
You have to take action to tell it that 5000 means 5000W.
That’s what transforms are for, great.
(function(i) {
return i + " W";
})(input)
Now the 5000 update gets massaged into 5000 W, just what a Number:Power Item likes to see.
But you wanted to see kW? It’s okay, that’s just what.state presentation is for. Put kW in pattern. Auto conversion, sorted.