Rule to change item value in sitemap

HELLO I’M A BEGINNER CREATING RULES. AND I WOULD LIKE TO LEARN HOW TO UPDATE A SITEMAP LABEL WITH A BASIC RULE,

I HAVE 2 ITEMS, AND WHEN ONE RECEIVES A VALUE FOR MQTT I WANT THE OTHER TO CHANGE

MY CODE IS THIS

rule “1”
when
Item mqtt_Humedad received update or
Item mqtt_Humedad received changed or
System started

then
postUpdate(ana,100)
end

IS IT POSSIBLE TO CHANGE THE VALUE OF AN ITEM?

Welcome to the OpenHAB community!
Is ana an item?

Item label and state are two different things, example for a Number Item, label = “how many”, state = 22

Thank you very much for the welcome.
Ana is a number item
what I want to modify is the value that is shown on the screen, for example give it a 1 or a 2

Thanks for the answer, what I want to modify is the status, that is, the number that I see on the screen

SomeItem.postUpdate(22) should work.

The Action way to do it postUpdate(xx, yy) is more choosy and best avoided when possible.

I am trying but I am not successful in any way, it makes me very sad. I will publish some images of how I have the configuration, I tried in other ways

SO FAR I HAVE NOT BEEN ABLE TO EXECUTE ANY RULES, I WOULD LIKE TO AT LEAST MANAGE TO RUN A RULE TO BE ABLE TO LEARN

FROM ALREADY THANKS

Juan
The rule you posted a picture of will only ever run once at system start up. If you restart the system (not the greatest way to test a rule) it should initialize your item in your sitemap (which it seems to not in the picture)

above you call your item ‘Ana’ but in your sitemap you have ‘item=ana’
might just be a typo but for item names case matters

How have you defined the Item? Did you define a label?

Hey welcome to openHAB

On the sitemaps documentation page their is an example for temperature.

sitemap demo label="My home automation" {
    Frame label="Temperature" {
        // Overrides only the text, but will keep the state format from the Item definition
        Text item=Livingroom_Temperature label="Livingroom"
        // Overrides the text and hides any state representation.
        Text item=Livingroom_Temperature label="Livingroom []"
        // Overrides the text and state representation
        // and also changes the state unit to Fahrenheit
        // if the value of the item supports UoM (link below) the value will be transformed.
        Text item=Livingroom_Temperature label="Livingroom [%.2f °F]"
    }
}

This allows you to format the data you show on the sitemap.

Text item=ana label="Ana [%s]" icon="lightbulb"

Please you keyboard may need maintenance as the caps lock is stuck on.

You can use the Kraf console to change the state of items in testing.

ssh -p 8101 openhab@localhost

default password is habopen

Then you need to read about the console commands

Maybe this command look like what you want smarthome:send <item> <command>

smarthome:send ana 22

hi thanks for wanting to help me

Please try this new test.
I want to change the switch
a number is updated in ana (22)

this is my configuration

What I can be doing wrong?

I think you asked the XY question

You have not explained the problem in a way we can help you easily.

You can only have one data type per element on a sitemap.

The number item only has a number data type.

Lets assume you want to have a dimmable light on your sitemap.

Change number to a dimmer item
image

Sitemap Code
Different elements to test

Sitemap

Your rule will still work because the dimmer item can accept that data type also on/off

      Slider item=ana 	
      Switch item=ana	icon="lightbulb"
      Switch item=ana   icon="lightbulb" mappings=[ OFF="OFF", 50="HALF", ON="FULL"] 
      Setpoint item=ana icon="lightbulb"
1 Like