I am trying to modify a location badge and found this tutorial:
I want the “projectors” badge to be displayed with a custom icon when the item “MQTThingVector_VectorStatus” has the value “Vector is on the charger”. Unfortunately this does not work as I had hoped.
here is my code from the homepage:
locations:
- component: oh-locations-tab
config:
badges:
speakers:
expression: state === 'PLAYING'
projectors:
badge:
icon: oh:vector_face
expression: MQTThingVector_VectorStatus === 'Vector is on the charger'
This is not true, expression for badge customisation is always evaluated and actually does not expect an = sign. It also only exposes state and Number, please see here for details.
So at best it could work with something like
expression: state === 'Vector is on the charger'
state contains the value of the “processed” item. One cannot reference custom items from here (nor does it make sense IMHO) …
I want the “projectors” badge to be displayed with a custom icon when the item “MQTThingVector_VectorStatus” has the value “Vector is on the charger”
there are (IMHO) two separate steps to achieve the same:
I want the “projectors” badge to be displayed when the item “MQTThingVector_VectorStatus” has the value “Vector is on the charger”,
setup custom icon for a badge
First you need to prepare your model properly so it will render projector. You will most probably need a rule that will convert a (new?) item’s state (lets call it MQTThingVector_VectorStatusSwitch) to on/off based on MQTThingVector_VectorStatus items value - so if (state of)
MQTThingVector_VectorStatus === 'Vector is on the charger'
then set MQTThingVector_VectorStatusSwitch to ON or OFF otherwise.
If you’ll tag MQTThingVector_VectorStatusSwitch properly within the room you want your projector to appear, that should do the trick for step 1.
As far as I can see, you already covered step 2 yourself in original post, just remove the expression part …