Cannot format state '1' to format '%d': d != java.lang.String

on opening PaperUI or HABPanel I get These WARNINGs in my openhab.log:

i combed through my items-config and opened every page in my BasicUI - I can’t get to the items to which These WARNings refer to… Some idea how to approach these?

2018-01-14 15:10:08.362 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '1' to format '%d': d != java.lang.String
2018-01-14 15:10:08.385 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '2' to format '%d': d != java.lang.String
2018-01-14 15:10:08.396 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '2' to format '%d': d != java.lang.String
2018-01-14 15:10:08.408 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '1' to format '%d': d != java.lang.String
2018-01-14 15:10:08.419 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '1' to format '%d': d != java.lang.String
2018-01-14 15:10:08.945 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '1' to format '%d': d != java.lang.String
2018-01-14 15:10:08.958 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '2' to format '%d': d != java.lang.String
2018-01-14 15:10:08.971 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '2' to format '%d': d != java.lang.String
2018-01-14 15:10:08.981 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '1' to format '%d': d != java.lang.String
2018-01-14 15:10:08.991 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '1' to format '%d': d != java.lang.String

No bindings or items that use transformation service at all?

many of them - but they are in BasicUI - and therefore must throw warnings there, too? and I clicked through every page in UI! :wink:

hmm. I digged a bit deeper and it seems, it’s my “HVAC mode” items:

they come via 5.005 (decimal factor) from the KNX - therefore should be integers - not strings?

Number RTR_EG_WoZi_HVAC_mode	 "Betriebsart Wohnzimmer [MAP(heating_de.map):%d]"	<temperature>	(gRTR, EG_WoZi, gRTR_EG_WoZi)		[ "homekit:HeatingCoolingMode" ]	{ knx="5.005:8/5/1+<5.005:8/5/11" }
Number RTR_OG_Schlafen_HVAC_mode "Betriebsart Schlafzimmer [MAP(heating_de.map):%d]"	<temperature>	(gRTR, OG_Schlafen, gRTR_OG_Schlafen) 	[ "homekit:HeatingCoolingMode" ]	{ knx="5.005:8/5/3+<5.005:8/5/13" }
...

heating_de.map:

1=Komfort
2=Standby
3=Nacht
4=Frost
5=Party
-=unbekannt
NULL=unbekannt
UNDEF=unbekannt

at present, these are the only items, which states are 2 (or better ‘2’):

2018-02-01 08:04:58.505 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '2' to format '%d': d != java.lang.String
2018-02-01 08:04:58.525 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '2' to format '%d': d != java.lang.String
2018-02-01 08:04:58.539 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '2' to format '%d': d != java.lang.String
2018-02-01 08:04:58.553 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '2' to format '%d': d != java.lang.String
2018-02-01 08:04:58.568 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '2' to format '%d': d != java.lang.String
2018-02-01 08:04:58.581 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '2' to format '%d': d != java.lang.String

Is there a way to see the items’ values including their type? I assume, since they’re “Number”, it shouldn’t be String…?

d != java.lang.String

This part of the error message indicates you are trying to format a String as a decimal number, so it looks like your understanding of the problem is correct - the item state is actually a String with a character representing a number, not an actual Number variable.

What happens if you use this instead for your label:

[MAP(heating_de.map):%s]

I’d rather have my KNX values put in openHAB correctly. In this case, it’s just a key value for heating status in my rooms, which I don’t need for some kind of calculation (as of yet)…
But yes, of course this one works; before this log excerpt I changed 'RTR_EG_WoZi_HVAC_mode' for %s and left 'RTR_OG_Schlafen_HVAC_mode' with %d:

2018-02-02 08:05:24.710 [ome.event.ItemCommandEvent] - Item 'RTR_EG_WoZi_HVAC_mode' received command 1
2018-02-02 08:05:25.038 [vent.ItemStateChangedEvent] - RTR_EG_WoZi_HVAC_mode changed from 2 to 1
2018-02-02 08:05:25.049 [vent.ItemStateChangedEvent] - RTR_EG_WoZi_setTemp changed from 19.0 to 21.1
2018-02-02 08:05:32.037 [ome.event.ItemCommandEvent] - Item 'RTR_OG_Schlafen_HVAC_mode' received command 1
2018-02-02 08:05:32.409 [vent.ItemStateChangedEvent] - RTR_OG_Schlafen_setTemp changed from 19.29 to 20.29
==> /var/log/openhab2/openhab.log <==
2018-02-02 08:05:32.435 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '1' to format '%d': d != java.lang.String
==> /var/log/openhab2/events.log <==
2018-02-02 08:05:32.442 [vent.ItemStateChangedEvent] - RTR_OG_Schlafen_HVAC_mode changed from 2 to 1
2018-02-02 08:05:37.994 [ome.event.ItemCommandEvent] - Item 'RTR_EG_WoZi_HVAC_mode' received command 2
2018-02-02 08:05:38.541 [vent.ItemStateChangedEvent] - RTR_EG_WoZi_HVAC_mode changed from 1 to 2
2018-02-02 08:05:38.725 [vent.ItemStateChangedEvent] - RTR_EG_WoZi_setTemp changed from 21.1 to 19.0
2018-02-02 08:05:38.733 [ome.event.ItemCommandEvent] - Item 'RTR_OG_Schlafen_HVAC_mode' received command 2
2018-02-02 08:05:39.208 [vent.ItemStateChangedEvent] - RTR_OG_Schlafen_setTemp changed from 20.29 to 19.29
==> /var/log/openhab2/openhab.log <==
2018-02-02 08:05:39.235 [WARN ] [.core.transform.TransformationHelper] - Cannot format state '2' to format '%d': d != java.lang.String
==> /var/log/openhab2/events.log <==
2018-02-02 08:05:39.246 [vent.ItemStateChangedEvent] - RTR_OG_Schlafen_HVAC_mode changed from 1 to 2

But that’s not exactly what I am hoping for. This one is just a quick&dirty Workaround, I’d like to understand:

  • did I configure something incorectly?
  • is there a bug in the KNX-binding for dpt 5.005?

No, I think the error message is misleading…

The Item state is of type number (the Item itself is of type number, the binding will only give numbers)

But the MAP service wants a string to map to another string. So you have to pass the state as a string, and that’s what %s will do.

2 Likes

ok. if that’s all, then I’ll settle my case! :wink:
Thanks!

@Udo_Hartmann, if the map transformation only takes String as an input, but many bindings may return Number (such as this one), perhaps it would be interesting to create a feature request so the transform starts support at least numeric input?

Why to do that? There is no reason to send a number to the transform service. You could use another service (Scale) which makes use of number input (e.g. 0 to 25 -> low 26 to 50 -> medium 50 to 100 -> high) but for map transformation there is no reason to use numbers as input.

The Scale transformation is better suited for converting continuous input (e.g. temperature) into discreet values (cold, warm, hot).

In this case, it looks like the input is already a discreet mode value (Betriebsart), so the purpose is just to convert from a numerical/fixed code into a String representation. This probably can be done with Scale too, but it looks clumsier than the Map transform in this case.

Yes, but my point is: Why would one need a map transformation which is able to deal with numerical input?
As map does a mapping, this is useless.

at least I don’t! :wink:
as i could use the Number-items’ states for calculation and use MAP with %s - everything’s fine for me! :wink:
and i also can’t think of a scenario, where a MAP-Transformation via numbers will be better suited as string?