@AlexF concerning the datatype for status channels:
i understand your point however i believe you have somehow a better way in openhab to do what you want using the MAP transforms.
Let’s suppose from your example that the temporary lux mode channel would return a number (not a string type as it is at present)
Number TemporaryLuxMode "Temporary Lux Mode" {channel="nibeuplink:f1145:nibe:hotwater#48132"}
then to map the corresponding labels you can define a transformation map (a .map file) that you place in the transform directory of your config (e.g. in /etc/openhab2/transform). Let’s call it TemporaryLuxMode.map with the following content:
0.0=off
0=off
1.0=3h
1=3h
2.0=6h
2=6h
3.0=12h
3=12h
4.0=once
4=once
-=invalid
Note: there is apparently a bug/limitation with this map transform (when using persistence services for the Items if i remember well) such that that it is recommended to define both the decimal x.0 and integer x translation. I found this hint in another post.
Now, having defined the transform, you can recall it in your items definition file:
Number TemporaryLuxMode "Temporary Lux Mode [MAP(TemporaryLuxMode.map):%s]" {channel="nibeuplink:f1145:nibe:hotwater#48132"}
The advantage besides the translation being cleanly defined in a .map file is that you get both representations to coexist. The Item will be automatically displayed (e.g. on the sitemap) with the string translated value (i.e. with its label ‘off’, ‘3h’, ‘6h’, etc) while it can be stored with its native number type in the database (when you use openhab persistence), and this without having to use rules to translate between representations.
You can also access either representations in rules, for instance:
val mode = TemporaryLuxMode.state as Number // this sets the variable mode as a Number 0,1,2,3, etc
val modeStr = transform(“MAP”,”TemporaryLuxMode.map”,TemporaryLuxMode.state.toString) // this sets the variable modeStr as the String equivalent representation of the mode (using the MAP defined transform). i.e. if the state is 1, then modeStr will be set to the String '3h'
TemporaryLuxMode.sendCommand(transform(“MAP”,”TemporaryLuxMode.map”,”3h”)) // this sends the command 1 (translated from the map file)
TemporaryLuxMode.sendCommand(1) // this does the same
So in this way i think you get what you would want while using the concepts embedded in openhab with the transform approach to play with the item representations.
The other important thing i wanted to highlight in my previous posts is that in the current 2.4 and the last 2.3 versions, and although the status channels are indeed defined as String type, you actually don’t get the string equivalent. I have not checked for the temporary lux mode channel, but for instance for the channel ‘Compressor Status Blocked’ (channel ‘compressor#10012’) which is defined as String:
I have defined the Item consistently with String type as required:
String NibeCompressorStatusBlockedTmp "Compressor Status Blocked" {channel="nibeuplink:f1145:nibe:compressor#10012"
and this is what i see in the events.log when the item initialises after startup:
2018-05-31 16:59:21.419 [vent.ItemStateChangedEvent] - NibeCompressorStatusBlockedTmp changed from NULL to 0
A query from the Karaf console is also consistent with this:
openhab> smarthome:status NibeCompressorStatusBlockedTmp
0
you will note i don’t get ‘No’ or ‘Off’ which would have been the string representation. What i get is the String ‘0’. I’m not sure this is what you would be expecting from what you explained in your posts, as we should have rather expected to have the item state get the string value ‘No’ (or ‘Off’). So overall i would think that giving directly a Number type in this case (the number 0 or 1) would be more consistent and as well more convenient.
Please don’t hesitate to shout if I miss something