Enumerated values from Sitemap showing in Basic UI

I was pleasantly surprised today when the Basic UI showed a radio button list for a Number item (defined in the frame as a “Default”). Can someone tell me where OH got these values from?

This is what the Basic panel looks like:


It’s in the Sitemap frame as:

Default item=UpstairsThermostatOperatingState label="State"

… and the item is defined as …

Number UpstairsThermostatOperatingState
   "Upstairs state [%.1f]" 
    <radio-button> 
    (UpstairsThermostat) 
    {channel="zwave:device:25750de2:node6:thermostat_state"}

Really more curious than anything, but it would be helpful to understand this better when I try to make a HabPanel template for this.

Thanks!

See here - (keyword stateDescription)

The zwave binding provides state translations for some Channels, e.g. org.openhab.binding.zwave/doc/honeywell/th8320zw_0_0.md at 5a8f314838b57f62d6963aa4ec9ce90a5d3a576c · openhab/org.openhab.binding.zwave · GitHub. This is done through StateDescriptions/CommandDescriptions, which will be available in OH 3.0 through Item metadata, rather than through just Thing definitions. This will allow us to easily add this type of functionality into our Items.

Nice! Thanks!

OK, so I see some odd behavior that may be related to these “display values”, or perhaps I just don’t understand something.

For that same thermostat, accessing the value of the Fan Mode item, I sometimes get an error.

This works as expected:

logInfo("Thermostat Temp Command", "Mode " + UpstairsThermostatFanMode.state)

Mode 0

However this line throws an error:

logInfo("Thermostat Temp Command", UpstairsThermostatFanMode.state)

[ntime.internal.engine.RuleEngineImpl] - Rule 'Thermostat Temp Command': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.LogAction.logInfo(java.lang.String,java.lang.String,java.lang.Object[]) on instance: null

Maybe I’m just tired, but that’s confusing me terribly.

logInfo would like two strings, please.

UpstairsThermostatFanMode.state
is not a string.

"some text" + UpstairsThermostatFanMode.state
begins as a string, so the rules evaluator knows that + means concatenate (and not maths add) and also that the second thing ought to be be string too. Thus inspired, it looks to see if the mystery object has a toString method - and it does. Here you “get away with it”.

The way to get what you expect -
"some text" + UpstairsThermostatFanMode.state.toString
or
UpstairsThermostatFanMode.state.toString

1 Like

It is also best to use parameterized logging, which will take care of the string conversions for you…

logInfo("Thermostat Temp Command", "Mode {}", UpstairsThermostatFanMode.state)