Item as a string, can this be used as a default state?

Good evening.

I have a Roborock vacuum linked through the Xiaomi Wifi binding.
Using the ‘Error Code’ string channel I have created an item of ‘Roborock_Error_Code’.

Is there a way to equate ‘No error’ to be a default state for ‘false’ or ‘off’, and any other state to be ‘true’ or ‘on’?
My end goal is I have this item in a group and would like to be able to use the Aggregation function for determining ON or OFF as part of the group.
I see I can use the State Description - option metadata and add ‘No error=false’ however it does not affect the group aggregation and then I can’t display the actual state on a label card.

I think I could create another item linked to the channel as a switch and map the ‘No error=false’ but I am wondering if what I am trying to do is possible as this way i would have to use two items, the original for the description and the second for the state.

Thanks for any help with this.
Craig

You should be able to do that using the Map transform. Set the "no errors to OFF and the default to ON. See Map - Transformation Services | openHAB

You can use this in the State Description pattern or use a transform profile to convert it before it gets to the Item. With the profile you can use a Switch Item.

Thanks Rich I will look at this.

I was stuck on thinking of a channel configuration similar to what MQTT uses (eg Custom On/Open Value) if it exists for other channel types and bindings.

Craig

Hi Rich, thanks again I used the map transform and the group item aggregation is working.
I hate to ask if this will be something simple I have overlooked…

I seem to be having some trouble though with dispaying the string value.
How do I display the orginal un-transformed state of the Roborock_Error_Code item?
I see that with the map transform it changes this per the map file i created.

I would like to display the original string on a card.

Thanks
Craig

You can choose between two options. You can change how the Item appears by default or you can change the Item’s actual state. Once you’ve changed the Item’s state, you can’t go back.

If you want to see the original state, you can’t use a profile to transform the state.

I didn’t think you can do what you want without using two separate items.

Bind another (string) item to the vacuum error code channel.

Thanks Rich and Danny.

I was hoping to use only one item per channel for the widget I am working on to keep it as simple as possible.
If that’s not possible I will have to reevaluate how to set up the items needed for it.

Thanks for your help.
Craig