Has someone an Idea what syntax is neccecary to change the colour of my F7 icon?
→ I have tried and read many things, but nothing really works…
→ When the colour change works, then I would try to change the Icon by the state of my Item if possible.
component: oh-plan-marker
config:
coords: 220.7853332824764,460.86258889060605
name: OG Bad Radio
icon: f7:hifispeaker
iconUseState: false
item: OG_Bad_Radio
action: toggle
actionItem: OG_Bad_Radio
actionCommandAlt: OFF
actionCommand: ON
iconSize: 30
iconColor:
? (OG_Bad_Radio.state) == ON) ? "red"
? (OG_Bad_Radio.state) == OFF) ? "green"
slots:
default: []
What means the UI here by “use experssion for dynamic colours”?
The most common expression that you’ll use in this case comes in the form of:
(Test expression) ? value if test expression is true : value if test expression is false
To set an expresion in any of the widget fields or code you have to start that value with an = so that the widget parser knows you aren’t just typing something that it should copy directly. So your expression here should be:
items - to get the state of an item in a widget expression you have to use this special items object
'ON' - all the item states are stored in the items object as strings. The widget parser thinks ON is a variable named ON which doesn’t exist, so that’s not what your looking for, but 'ON' is the text equivalent of the state you are testing against.
: - if you were typing this directly into the code page or widget developer the colon in this expression would confuse the YAML parser because colons have the important meaning of dividing a property name and it’s value. To fix this oyu would have to enclose the entire expression (= and all) in another set of quite different than what you used to the pieces inside the expression. I used single quotes ' for the expression strings, so I’d have to put double quotes " around the expression. YOu don’t have to do this when you are using the widget settings dialog, it will do that for you automatically.