ioBroker / ioBroker.vis-2

Next generation visualisation for ioBroker platform.
Other
26 stars 3 forks source link

[enhancement]: allow to use widget oid value as special binding or allow usage widget data during assignment #345

Closed nullsibnelf closed 3 months ago

nullsibnelf commented 4 months ago

No existing issues.

Related problems

Using widget.oid in bindings dosn't work.

Description

Hi,

I tried many variants, since weeks now, and I cant belive, that it isn't possible to use values of the same widget in a binding. I asked in the IoBroker-Forum, and they sent me here - to create a issue.

I want to do a binding to the value of the Object ID, to color the text depenend on the level. I could write the object ID, but with 100 strings, I have to write it 100 times. When there is a way to point to the ObjectID, I could use the same code to all Strings - just copy paste.

I'm using vis2. Picture for illustration: string binding

Additional context

No response

foxriver76 commented 4 months ago

see https://github.com/ioBroker/ioBroker.vis-2#special-bindings

So it can only be used in the js part according to the docs, which means something like this would work {t:1;widget.data.oid}

But yes, then your specific use case would not be possible currently.

nullsibnelf commented 4 months ago

Crazy, that nobody never tryed to use this before. Thought I did something wrong. Thanks!

BTW: I dont get the "only in js part". There is this js-part - that does this exactly mean? I'm relatively new to IoBroker, could you do a screenshot where to find this? Or is this related to the Scripting-Section in the mainmenu? (TS, JS, Blockly ect)

foxriver76 commented 4 months ago

I haven't written these docs and I also think it is a bit confusing. From my understanding: You have the assignment part (the part with the : to assign value of an state) and the js/code part of a binding (where the output is generated). So you unfortunately cannot do like {val:widget.data.oid;val} as it won't be evaluated as an assignment.

manuxi commented 3 months ago

You could try it with prepend/append html: image

prepend: Ht outdoor: <span class="{wert:dp.0.val; wert == "true" ? "red" : "green"}"> append: </span>

(or instead of class="[...]" => style="color:[...]")

foxriver76 commented 3 months ago

Will be possible in next version like

I am not sure if there are edge case widgets where this will not work for, it depends on the fact, that the oid is called oid by the widget developer.