Item formation BUG?

Hejo Community,

I just got an issue. I use java script transformation to calculate W to Kw and I want to display the Kw on the .sitemap
But the following happens.

Number C2MW97	"Wirkleistung L1 [JS(WtoKW.js):%f]"	(StraBaWe2OGUVBF05, g_MYSQL, gINFLUX)	{modbus="C2MW97:0"}

Displays like this

That is OK. but when adding this

Number C2MW97	"Wirkleistung L1 [JS(WtoKW.js):%f Kw]"	(StraBaWe2OGUVBF05, g_MYSQL, gINFLUX)	{modbus="C2MW97:0"}

This happens

Without the java script transformation

Number C2MW97	"Wirkleistung L1 [%f Kw]"	(StraBaWe2OGUVBF05, g_MYSQL, gINFLUX)	{modbus="C2MW97:0"}


Did someone encounter this Issue before ?

Possible solution would be to add the Kw to the JavaScript

(function(i){
        return (i/1000).toFixed(2)+" Kw";
})(input)

Resulting in:

But is this behavior wanted? If someone could answer that question I would create and Issue if necessary

I just noticed the karaf Console is full of [WARN] Messages.

13:41:30.288 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW99, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:30.394 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW107, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:30.828 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW97, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:31.288 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW98, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:31.500 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW110, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:32.051 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW112, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:32.883 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW109, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:33.674 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW108, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:39.153 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW99, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:39.269 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW107, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:39.714 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW97, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:40.177 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW98, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:40.398 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW110, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:40.941 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW112, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:41.761 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW109, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:42.580 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW108, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:48.067 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW99, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:48.627 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW97, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:49.084 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW98, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:49.311 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW110, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:49.859 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW112, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:51.484 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW108, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:56.980 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW99, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:57.582 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW97, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:58.031 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW98, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:58.251 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW110, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:58.796 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW112, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:41:59.613 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW109, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:00.412 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW108, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:05.905 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW99, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:06.019 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW107, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:06.466 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW97, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:06.922 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW98, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:07.133 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW110, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:07.682 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW112, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:09.313 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW108, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:14.798 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW99, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:14.914 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW107, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:15.359 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW97, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:15.822 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW98, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:16.040 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW110, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:16.583 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW112, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:16.840 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW111, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:18.227 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW108, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:23.781 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW99, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:24.323 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW97, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:24.786 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW98, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:24.998 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW110, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:25.540 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW112, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:26.372 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW109, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:27.170 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW108, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}
13:42:32.652 [WARN ] [pse.smarthome.core.items.GenericItem] - failed notifying listener '[org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener@3a24a381, C2MW99, f != java.lang.String]' about state update of item java.util.IllegalFormatConversionException: f != java.lang.String: {}

Looks like its ONLY the C2 Modbus Slave
EDIT
Its not only C2 Modbus Slave others report this too

WTF?!

After editing

Number C2MW97	"Wirkleistung L1 [JS(WtoKW.js):%f]"	(StraBaWe2OGUVBF05, g_MYSQL, gINFLUX)	{modbus="C2MW97:0"}

to

Number C2MW97	"Wirkleistung L1 [%f]"	(StraBaWe2OGUVBF05, g_MYSQL, gINFLUX)	{modbus="C2MW97:0"}

Save
and edit back to

Number C2MW97	"Wirkleistung L1 [JS(WtoKW.js):%f]"	(StraBaWe2OGUVBF05, g_MYSQL, gINFLUX)	{modbus="C2MW97:0"}

no more WARN aper

13:54:21.162 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'converted.items'
13:54:21.415 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'converted.items'
13:54:53.535 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'converted.items'

The NaN is coming from the JavaScript. I can’t say whether it is wanted but it appears to me that everything after the : and before the closing ] gets passed to the JS transform. This means in your JavaScript i=730 Kw which is Not a Number so cannot be divided by 1000.

What happens if you use [JS(WtoKW.js):f] Kw?

I can’t comment on the warnings. My first impressions is that they were a coincidence and reinitializing your Items (i.e. editing any of the .items files) fixed a transient problem.

Number C2MW97	"Wirkleistung L1 [JS(WtoKW.js):f] kW"	(StraBaWe2OGUVBF05, g_MYSQL, gINFLUX)	{modbus="C2MW97:0"}

will deliver

Same with

Number C2MW97	"Wirkleistung L1 [JS(WtoKW.js):f kW]"	(StraBaWe2OGUVBF05, g_MYSQL, gINFLUX)	{modbus="C2MW97:0"}

and

Number C2MW97	"Wirkleistung L1 [JS(WtoKW.js):f]"	(StraBaWe2OGUVBF05, g_MYSQL, gINFLUX)	{modbus="C2MW97:0"}

Only this is working so far

Number C2MW97	"Wirkleistung L1 [JS(WtoKW.js):%f]"	(StraBaWe2OGUVBF05, g_MYSQL, gINFLUX)	{modbus="C2MW97:0"}

Oops, you need the % before the f in all cases. That was a typo on my part. So try:

"Wirkleistung L1 [JS(WtoKW.js):%f] kW"

No this wont work either :disappointed:
Until now I will stick tot he java script transformation.
And the WARN…

f != java.lang.String: {}

Is coming from the

%f

I changed all items to

%s

I will monitor the result and report back

(function(i){
        return (i/1000).toFixed(2)+" kW";
})(input)

(i/1000).toFixed(2).toFixed(2) this returns a float but with the +" kW" makes the whole return a string.
This is my point of view

Yes, doing it in the JS transform will certainly work. If seems like it should work outside of the JS transform but if it is passing the kW to the transform I guess that is a limitation. I’ll try to remember that and update the docs when I get to updating the Items docs again.