[SOLVED] Little help with this script // show string in sitemap

Hi there,

my question is simple.

I have this item:

String _name "Nombre Stage"

Sitemap

Text item=_name

and this sentence in one rule, and I would like to save the string in the item _name:

rule "Name"
when Item name_01 changed to ON
then
var String _name = "string text..."
logInfo("ExecTest", _name)  // Here I check that the String show up properly in Log.

I have saved the ip in the sring _name, but I do not know how to show it in sitemap.

String _name "Nombre Stage[%s]"
rule "Name"
when
    Item name_01 changed to ON
then
    val x = "string text..."
    logInfo("ExecTest", x)  // Here I check that the String show up properly in Log.
    _name.postUpdate(x)
end
1 Like

Thank youu :smile:

That won’t work because _name is a string not an item.
If the variable contains an item’s name then you can use the postUpdate action:

postUpdate(_name, x)

The postUpdate action takes strings as arguments
See: https://www.openhab.org/docs/configuration/rules-dsl.html#myitem-sendcommand-new-state-versus-sendcommand-myitem-new-state

Sorry, but there you are wrong. It works. Test it, if you don’t believe.

For me is working.

Well, thanks guys, that’s new to me.

@vzorglub

@hr3
I know that, it say that : “Rules are often used to manipulate the state of an Item”
An Item, not a String

@vzorglub It’s a item with the type string!

Yes, I read it wrong I saw it as one file and missed that there was no var
Doh!