Using Rules to Update a dummy text item...not showing up in sitemap

Hey guys, I am having some trouble getting a text item to update on Sitemap. Let me explain below:

Item File:

String JMsHome "JM" <man_3>
Switch JMHomekit "JM is Home" [ "Lighting" ]

Rule File

rule "Occupancy Test"
    Item JMHomekit received update
    switch JMHomekit.state
        case ON : 
        case OFF : 


   Text item=JMsHome

HomeKit updates JMHomekit which is an ON/OFF type item and the above rule updates the JMsHome item accordingly. After activating the rule, the sitemap doesn’t display the item state. If i go into the console and use smarthomestatus JMsHome it says: Home. The logs show no errors, they verify the rule is in fact running and they show the item state being updated accordingly (home or away).

I originally just had JMHomekit and used mappings to make it say ‘Home’ or ‘Away’ on the sitemap but i didn’t like how i could click the buttons, changing the item state. This is why i chose to create the text item JMsHome to display a message i couldn’t change.

I want it to look like this but cant get the state to show on the right side where Carrie Underwood is:

Thoughts and advice is appreciated.

Hi, two thoughts on this.

  1. You might try to change the description to
    String JMsHome "JM [%s]" <man_3>

  2. I‘ve seen in your rule you are using a mix of postUpdate and sendCommand. And you are using the generic methods.
    Probably not the root cause for your issue but worth to have a look here postUpdate vs. sendCommand

Cheers thefechner

Hey thanks for the reply. I’ll try making that change and let you know how it works. For my own knowledge, what does the %s do?

Regarding the rule, that was my bad. I originally tried postUpdate which didn’t work then I tried sendCommand which also didn’t work. When I copied this rule to post here, I meant to change both back to postUpdate but missed one. I never ran the rule like that where one is post update and the other is sendCommand.

Ha, funny, as I didn’t know the exact term how it is called, I did a quick search and found the answer to your sitemap issue. :grinning:

In the same thread there is also a link to an explanation how to display other values than string (e.g. numbers & units)

So why not do the following.

Create a .map file in the transformation folder that maps ON to Home and OFF to Away. See Map - Transformation Services | openHAB for details.

Configure the Item’s label to use that map. JM [MAP(].

Then use a Text sitemap element to show the Switch Item.

There is no need for a Rule and a separate Item to achieve this.

Hey thank you both for posting and providing that information. Adding the [%s] to my item and using postUpdate solved my problem:

Item file

String JMsHome “JM [%s]” <man_3>

Also wanted to post a workaround that might help someone else out reading this if for some reason the above solution isn’t acceptable. Before i tried the above solution, I made the below dummy items:

Switch JMsHome “JM” <man_3>
Switch JMsAway “JM” <man_3>
Switch JMHomekit “JM is Home” [ “Lighting” ]

and had the following sitemap file:

Switch item=JMsHome mappings=[ON=“Home”] visibility=[JMHomekit==ON]
Switch item=JMsAway mappings=[ON=“Away”] visibility=[JMHomekit==OFF]

Here is a screenshot of my sitemap with this implemented

for those not aware, the visibility tag above basically hides the ‘incorrect’ item according to how JMHomekit is set. When JMHomekit is on, the item JMsAway is hidden but JMsHome is shown and visa versa.

Thanks everyone!