Modify location badge


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:

  - component: oh-locations-tab
          expression: state === 'PLAYING'
            icon: oh:vector_face
          expression: MQTThingVector_VectorStatus === 'Vector is on the charger'

And here is my item:

What am I doing wrong?

  1. All expressions must start with an equals sign
expression: =A == B
  1. The projector expression is not properly lined up under the protector heading, it needs to be indented

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) …

1 Like

So “state” is the “Semantic Class”, of the item right? Does the “Semantic Property” also plays a role here? Right now it’s “None” in my example.

Unfortunately it has not yet worked.

Are there plans to introduce more default badges? At least a power outlet and a cleaning robot would be nice.

There is no plan. Plans are ours - where we want to drive openhab and where we want to spend time are the only keys/limits

1 Like

That’s great! So who has the skills and time to add more default badges? :upside_down_face:

In order for

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 …