[Solved] Data manipulation on channels possible?

Hi,

I was wondering if a data manipulation on channels is possible…

Background is, I’ve got three channels, bound to Number Items.

Is one able to manipulate these number values to string values with aphanumeric text before passing the data to the items?

I’m talking about changing the data type of the items to string and convert their values on channel-side (similar to JsonPath)?
e.g.

0 = OFF
1 = SHUFFLE TITLE
2 = SHUFFLE PLAYLIST

I know I can manipulate on the item-side but imo only how the ‘item name’ is displayed, not the ‘state’ itself…

tried to manipulate with js on item-side but this doesn’t seem to work, because I’m trying to use the item states to display on the widget,

I searched on the forums yesterday, but haven’t found an answer to my question.

Maybe someone could clarify this for me??

I need this in a mainUI widget. Or is it possible to convert/manipulate the item state itself in mainUI?

thanks
Dan

That sounds like the typical map transfirmation.
A look onto the documentation would help.

haha nice1 :wink:

I always take a look at the documentation before posting…

Instead of pointing someone to the documentation it would be nice to get a description for a solution. and this is not really answering the question if manipulation on channel-side is possible…

but thanks anyway

The answer is: maybe.

What is your Thing, or binding that is creating these Channels?

Well I think you need to elaborate your goal a bit more. Every item usually has a state and a displayState, and the displayState is e.g. the state after a transformaion or a profile has been applied.

Why exactly do you need as the item.state string in the main UI widget, you can also manipulate the displayed value in the widget itself or apply a transformation?

1 Like

Hi @hafniumzinc ,

I use textual config - the bindings is squeezebox, item type is number.

Hi Sascha,

I haven’t found a way to use the displayState of an item in yaml, only the item state…

that’s why I’m looking for a workaround, but maybe there’s an easier solution available I haven’t thought about??


text: =items[props.prefix+items[props.selected].state+props.shuffle].state

this is the yaml line where I’d like to manipulate the numbers to alphanumeric text

component type is

- component: oh-button

can I use something like

text: =items[props.prefix+items[props.selected].state+props.shuffle].displayState

I found no information on the so called displayState so far - have to search for it…

Edit:
Ok after searching for the use of displayState it seems this could work for me…
thanks!

Is displayState equal to the ‘item display name’ which is configured in the brackets?? e.g.

Number  SqueezeLivingroomShuffle  "[JS(shuffle.js):%s]"  (gSqueeze)

Ok Gentlemen,
I don’t need to manipulate on channel-side. displayState is working just fine for me…

Sorry never used it nor heard of it before - special thanks to Sascha for pointing me in the right direction :wink:

have a nice weekend you all!

1 Like

Sorry for that. I missed the point that you were looking for a solution on MainUI/ widget.
The solution in the linked docs was for the display on a sitemap🤷‍♂️

Just to circle around to the original question which I don’t think was clearly answered.

Yes you can change the value at the Channel level. But only sometimes (as @hafniumzinc tried to get across). But only if the binding supports it. Usually, only like level bindings like MQTT and HTTP support it at the Channel.

You can also apply a transform at the Link between the Channel and the Item using a Profile.

But if what you really care about is how it’s displayed, you should focus on the State Description Item metadata.

And I strongly suggest that anyone sticking to text based configs, at heart familiarize yourself with the MainUI way of configuring stuff. Many settings are self explanatory in MainUI that require carful reading if the docs to understand otherwise. You can create a config there, look at the code tab and translate that to a text config.

no problem :wink:

Thanks for the additional info Rich!

I already thought that this would only be possible where the binding’s configuration is able to get channels edited by the user like the mqtt binding :wink:

Funny that I completely missed the availability of the displayState option - never used it with sitemaps so this way was completely new to me :see_no_evil: …one never stops learning :wink:

1 Like