I have a problem changing String values and displaying them in BasicUI

Tags: #<Tag:0x00007f61733b6f88> #<Tag:0x00007f61733b6ce0> #<Tag:0x00007f61733b6ba0>
  • Platform information:
    • Hardware: Raspberry Pi 4 4GB
    • OS: Ubuntu Server 20.4
    • Java Runtime Environment: Open JDK 8
    • openHAB version: 2.5

Hi,

I’m Vidar from Germany and totally new to OpenHAB and home automation.

I tried the last 5 days(no joke) to assign text to a String and display it in the BasicUI. I do not want to use visibility (which did not work either), because I want to use the string in several UIs.

I created a Rule to assign the String depending on the power my dishwasher uses:

rule "Spuelmaschine_Betriebszustand"

when
    Item Kueche_Spuelmaschine_Leistung received update
then

    if (Kueche_Spuelmaschine_Leistung.state == 0 ) {
            Kueche_Spuelmaschine_Betrieb.state.toString("Aus")
    }

    else if (Kueche_Spuelmaschine_Leistung.state >=4) {
            Kueche_Spuelmaschine_Betrieb.state.toString("Läuft")

    }

    else if (Kueche_Spuelmaschine_Leistung.state > 0 && Kueche_Spuelmaschin>
            Kueche_Spuelmaschine_Betrieb.state.toString("Fertig")

    }

I also tried the postUpdate option.

the line to display it in the Sitemap:

Text item=Kueche_Spuelmaschine_Betrieb

Could someone please tell me, what I’m doing wrong?

Please post configurations (if applicable):

Sorry, I clicked the post button to early :slight_smile:

1 Like

You need to either sendCommand or postUpdate.

Kueche_Spuelmaschine_Betrieb.sendCommand("Aus")
Kueche_Spuelmaschine_Betrieb.postUpdate("Aus")

instead of

Kueche_Spuelmaschine_Betrieb.state.toString("Aus")

This assumes Kueche_Spuelmaschine_Betrieb is a String Item.

1 Like

You can edit post’s

You can use code fences ``` on the line before and after your code.

Sitemap can only show items not variables

I assume you have a string item

  String Kueche_Spuelmaschine_Betrieb "Spuelmaschine_Betriebszustand"

Then you would send the state to that item.

    if (Kueche_Spuelmaschine_Leistung.state == 0 ) {
            Kueche_Spuelmaschine_Betrieb.sendCommand("Aus")
    }

Kueche_Spuelmaschine_Betrieb is a String Item.

On my BasicUI It still showes “Kueche_Spuelmaschine_Betrieb”.
Should I try Default?

the item is defined like this:

String Kueche_Spuelmaschine_Btrieb "Betriebszustand"

No, Text should work fine. Can you show a screenshot of your BasicUI? Also, change your line to:

Text item=Kueche_Spuelmaschine_Betrieb label="Kueche Spuelmaschine [%s]"
1 Like

Here is the Screenshot:

Well, either something is not updating properly when you’re saving your configuration files, or something else is changing the state of Kueche_Spuelmaschine_Betrieb (an old rule?).

May also be worth a re-start of openHAB…

does not change much

That just means that Kueche_Spuelmaschine_Betrieb does not have a value assigned to it yet. It is null. Has your rule actually run yet with the sendCommand or postUpdate?

1 Like

I do not have any more rules regarding the dishwasher. I only have another one about my Oven

Yes, applyed it and started the Dishwasher a minute ago

Could my “when” be the Problem?

Item Kueche_Spuelmaschine_Leistung received update

Maybe - we don’t know much about this item.

Maybe change it to:

Item Kueche_Spuelmaschine_Leistung changed

No change.

I Tried postUpdate and also “changed” at when.

The Item Kueche_Spuelmaschine_Leistung is a Number and also displayed in BasicUI. It’s the Value “Leistungsaufnahme” (works)

I did a few experiments, and I guess the When clause could be the Problem. The Rule is now:

rule "Spuelmaschine_Betriebszustand"

when
    Item Kueche_Spuelmaschine_Leistung changed
then

    Kueche_Spuelmaschine_Betrieb.state.toString("Aus")

end

so BasicUI should display “Aus” all the time from the first change of “Kueche_Spuelmaschine_Leistung” on, but nothing happens.

Can you prove that this item is actually changing?

Yes. The Item is displayed in the BasicUI. It’s the Element “Leistungsaufnahme”. The Value comes from a IP Wallplug

This will not work. You must use sendCommand or postUpdate.

Can you show the Sitemap definition? Is this a unit of measurement item?