Exception while formatting value 'OFF' of item ... with format '%.2f %%': {}

Hi,

while working with my config files I got this strange behaviour - someone here perhaps could explain me what’s going wrong?

I’ve got a Homematic HM-LC-Dim1T-FM dim actor, and I defined two items via items config file; the both are labeled as “Bad Wandlicht”, and that’s what they should show up in sitemap.

Dimmer Badezimmer_1_Wandlicht
  "Bad Wandlicht"
  <light>
  (gSK_HS_2, gBad, gLampen)
  { channel="homematic:HM-LC-Dim1T-FM:ccu2:MEQxxxxxxx:1#LEVEL" }

Switch Badezimmer_1_Wandlicht_Toggle
  "Bad Wandlicht"
  <light>
  (gBad)
  { channel="homematic:HM-LC-Dim1T-FM:ccu2:MEQxxxxxxx:1#LEVEL" }

Relevant part of my sitemap file goes here:

    // Badezimmer Wandleuchten
    Slider item=Badezimmer_1_Wandlicht
      visibility=[Badezimmer_1_Wandlicht_Toggle=="ON"]
    Switch item=Badezimmer_1_Wandlicht_Toggle
      visibility=[Badezimmer_1_Wandlicht=="0"]
      mappings=[ON="Ein"]

What happens when using this sitemap is this:

2017-11-05 19:01:08.762 [vent.ItemStateChangedEvent] - Badezimmer_1_Wandlicht_Toggle changed from ON to OFF

==> /var/log/openhab2/openhab.log <==
2017-11-05 19:01:08.761 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value 'OFF' of item Badezimmer_1_Wandlicht_Toggle with format '%.2f %%': {}
java.util.IllegalFormatConversionException: f != java.lang.String
        at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4302) [?:?]
        at java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:2806) [?:?]
        at java.util.Formatter$FormatSpecifier.print(Formatter.java:2753) [?:?]
        at java.util.Formatter.format(Formatter.java:2520) [?:?]
        at java.util.Formatter.format(Formatter.java:2455) [?:?]
        at java.lang.String.format(String.java:2940) [?:?]
        at org.eclipse.smarthome.core.library.types.OnOffType.format(OnOffType.java:24) [98:org.eclipse.smarthome.core:0.9.0.201710240931]
        at org.eclipse.smarthome.ui.internal.items.ItemUIRegistryImpl.getLabel(ItemUIRegistryImpl.java:365) [137:org.eclipse.smarthome.ui:0.9.0.201710240931]
        at org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener.constructSitemapEvents(PageChangeListener.java:191) [118:org.eclipse.smarthome.io.rest.sitemap:0.9.0.201710240931]
        at org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener.constructSitemapEvents(PageChangeListener.java:184) [118:org.eclipse.smarthome.io.rest.sitemap:0.9.0.201710240931]
        at org.eclipse.smarthome.io.rest.sitemap.internal.PageChangeListener.stateChanged(PageChangeListener.java:156) [118:org.eclipse.smarthome.io.rest.sitemap:0.9.0.201710240931]
        at org.eclipse.smarthome.core.items.GenericItem$1.run(GenericItem.java:229) [98:org.eclipse.smarthome.core:0.9.0.201710240931]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:?]
        at java.lang.Thread.run(Thread.java:745) [?:?]

And that’s the part I can’t understand: I never told to use this “%.2f %%” format - where does it take this information from? The only possibility to avoid this error message is to explicitly set the label to something like “Bad Wandlicht [%s]” - but I think it has to work without too, hasn’t it? I have lots of other items and no problems so far… I already deleted the items and re-created them with another item name, restarted openHAB etc, but when it comes up, it recognizes this item again and throws the error…

44

  • openhab-2.2.0~20171104020304-1 on Rasbian Jessie, RP 3
  • oracle-java8-jdk 8u65

Cheers,
Marianne

Hi,

as mentioned on twitter, I think, the Switch Badezimmer_1_Wandlicht_Toggle linked to the Homematic-Channel “LEVEL” is the problem.
The LEVEL-Channel returns a value between 0 and 100, where 0 means OFF and a value > 0 ON. I don’t know, if the HUE- oder TRADFRI-Bindings do some magic and this will also work with a mapping to a switch (I remember, there was a discussion about that in den Tradfri-Thread).

What you can do is the following:

item-File:

Dimmer Badezimmer_1_Wandlicht { channel="homematic:HM-LC-Dim1T-FM:ccu2:MEQxxxxxxx:1#LEVEL" }

sitemap-File:

Slider item=Badezimmer_1_Wandlicht visibility=[Badezimmer_1_Wandlicht>"0"]
Switch item=Badezimmer_1_Wandlicht visibility=[Badezimmer_1_Wandlicht=="0"] mappings=[ON="Ein"]

Also possible in the sitemap-File is the following mapping:

Text item=Badezimmer_1_Wandlicht

This works not so smooth as excepected, because the controls are jumping around due to the following behaviour:

http://docs.openhab.org/addons/bindings/homematic/readme.html

All channels have two configs:

delay: delays transmission of a command to the Homematic gateway, duplicate commands are filtered out
receiveDelay: delays a received event from the Homematic gateway, duplicate events are filtered out (OH 2.2)
The receiveDelay is handy for dimmers and rollershutters for example. If you have a slider in a UI and you move this slider to a new position, it jumps around because the gateway sends multiple events with different positions until the final has been reached. If you set the receiveDelay to some seconds, these events are filtered out and only the last position is distributed to openHab. The disadvantage is of course, that all events for this channel are delayed.

Maybee this helps to solve the problem.

Hi Jens,

it took a long time, but here we go again :slight_smile:

I tested with my rollershutter. So I defined a rollershutter item and a switch item for the LEVEL.

 Rollershutter rWintergarten_Fenster
  "Rollladen Kippfenster"
  {channel="homematic:HM-LC-Bl1PBU-FM:ccu2:NEQ1561998:1#LEVEL"}

Switch sWintergarten_Fenster
  "Rollladen Kippfenster Schalter"
  {channel="homematic:HM-LC-Bl1PBU-FM:ccu2:NEQ1561998:1#LEVEL"}

I put it into my sitemap:

Switch item=sWintergarten_Fenster
  label="Kippfenster"
  mappings=[OFF="Zu (↓)"]
Slider item=rWintergarten_Fenster


It is working as expected: click on the button closes the rollershutter. BUT: as you can see there is an error state indicated for the label - a label I never defined :frowning: openhab2.log contains messages like this:

2018-02-23 12:57:58.850 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value 'ON' of item sWintergarten_Fenster with format '%.2f %%': {}
java.util.IllegalFormatConversionException: f != java.lang.String
	at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4302) [?:?]
	at java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:2806) [?:?]
	at java.util.Formatter$FormatSpecifier.print(Formatter.java:2753) [?:?]
	at java.util.Formatter.format(Formatter.java:2520) [?:?]
	at java.util.Formatter.format(Formatter.java:2455) [?:?]
	at java.lang.String.format(String.java:2940) [?:?]
	at org.eclipse.smarthome.core.library.types.OnOffType.format(OnOffType.java:29) [109:org.eclipse.smarthome.core:0.10.0.b1]
	at org.eclipse.smarthome.ui.internal.items.ItemUIRegistryImpl.getLabel(ItemUIRegistryImpl.java:372) [155:org.eclipse.smarthome.ui:0.10.0.b1]
	at org.eclipse.smarthome.ui.basic.internal.render.AbstractWidgetRenderer.preprocessSnippet(AbstractWidgetRenderer.java:118) [196:org.eclipse.smarthome.ui.basic:0.10.0.b1]
	at org.eclipse.smarthome.ui.basic.internal.render.SwitchRenderer.renderWidget(SwitchRenderer.java:75) [196:org.eclipse.smarthome.ui.basic:0.10.0.b1]
	at org.eclipse.smarthome.ui.basic.internal.render.PageRenderer.renderWidget(PageRenderer.java:172) [196:org.eclipse.smarthome.ui.basic:0.10.0.b1]
	at org.eclipse.smarthome.ui.basic.internal.render.PageRenderer.processChildren(PageRenderer.java:137) [196:org.eclipse.smarthome.ui.basic:0.10.0.b1]
	at org.eclipse.smarthome.ui.basic.internal.render.PageRenderer.processPage(PageRenderer.java:100) [196:org.eclipse.smarthome.ui.basic:0.10.0.b1]
	at org.eclipse.smarthome.ui.basic.internal.servlet.WebAppServlet.service(WebAppServlet.java:179) [196:org.eclipse.smarthome.ui.basic:0.10.0.b1]
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848) [88:org.eclipse.jetty.servlet:9.3.22.v20171030]
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:584) [88:org.eclipse.jetty.servlet:9.3.22.v20171030]
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) [191:org.ops4j.pax.web.pax-web-jetty:6.0.7]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [87:org.eclipse.jetty.server:9.3.22.v20171030]
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [85:org.eclipse.jetty.security:9.3.22.v20171030]
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) [87:org.eclipse.jetty.server:9.3.22.v20171030]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180) [87:org.eclipse.jetty.server:9.3.22.v20171030]
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:284) [191:org.ops4j.pax.web.pax-web-jetty:6.0.7]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512) [88:org.eclipse.jetty.servlet:9.3.22.v20171030]
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) [87:org.eclipse.jetty.server:9.3.22.v20171030]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112) [87:org.eclipse.jetty.server:9.3.22.v20171030]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [87:org.eclipse.jetty.server:9.3.22.v20171030]
	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) [191:org.ops4j.pax.web.pax-web-jetty:6.0.7]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134) [87:org.eclipse.jetty.server:9.3.22.v20171030]
	at org.eclipse.jetty.server.Server.handle(Server.java:534) [87:org.eclipse.jetty.server:9.3.22.v20171030]
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:333) [87:org.eclipse.jetty.server:9.3.22.v20171030]
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251) [87:org.eclipse.jetty.server:9.3.22.v20171030]
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283) [79:org.eclipse.jetty.io:9.3.22.v20171030]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108) [79:org.eclipse.jetty.io:9.3.22.v20171030]
	at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93) [79:org.eclipse.jetty.io:9.3.22.v20171030]
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303) [90:org.eclipse.jetty.util:9.3.22.v20171030]
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148) [90:org.eclipse.jetty.util:9.3.22.v20171030]
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136) [90:org.eclipse.jetty.util:9.3.22.v20171030]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) [90:org.eclipse.jetty.util:9.3.22.v20171030]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) [90:org.eclipse.jetty.util:9.3.22.v20171030]
	at java.lang.Thread.run(Thread.java:748) [?:?]

This is kind of a blocker for me now. I am happy for every idea :heart:

Cheers,
Marianne

Hi Marianne,

i’m not sure, how the binding will handle ON and OFF.
The homematic documentation shows the following for the LEVEL channel.

LEVEL is from type FLOAT an has a range from 0.0 to 1.0. So the binding has to translate ON/OFF to 0.0 or 1.0. I’m not sure, if this done in the binding for this device. For dimmers, like HM-LC-Dim1TPBU-FM this will work. I can’t tell you why, maybe someone could explain it.

I think you have to do a workaround like the following:

homematic.items

 Rollershutter rWintergarten_Fenster
  "Rollladen Kippfenster"
  {channel="homematic:HM-LC-Bl1PBU-FM:ccu2:NEQ1561998:1#LEVEL"}
Switch sWintergarten_Fenster
  "Rollladen Kippfenster Schalter"

homematic.sitemap

Frame label="Rolladen" {
	Switch item=sWintergarten_Fenster mappings=[ON="Öffnen (↑)", OFF="Schließen (↓)"]
}

homematic.rules

rule "Rolladen öffnen"
	when
		Item sWintergarten_Fenster received command  ON
	then
		sendCommand(rWintergarten_Fenster, 0)
end

rule "Rolladen schließen"
	when
		Item sWintergarten_Fenster received command  OFF
	then
		sendCommand(rWintergarten_Fenster, 100)
end

As mentioned in the answer before, the implementation of some commands is not straightforward.

I have a lot of dimmers (HM-LC-Dim1TPBU-FM) installed, where the LEVEL channel understands ON and OFF sent as command. Also 0 switches off, and 100 switches on the light. That’s a bit weird. But I think, the dimmer item will handle this,
(https://docs.openhab.org/configuration/items.html) as the dimmer item will accept OnOff, IncreaseDecrease and Percent as possible values.

Otherwise you could try the offical commands from the rollershutter item, as mentioned here:

Possible commands are “UpDown, StopMove, Percent”. So try the following on your sitemap, maybee it works as expected.

homematic.sitemap

Frame label="Rolladen" {
	Switch item=rWintergarten_Fenster mappings=[Up="Öffnen (↑)", Down="Schließen (↓)"]
}

Please find my solution here:

https://community.openhab.org/t/basic-ui-sitemap-default-item-rollershutter-err-text/67861/18

best regards.