Multiple !MAPPED! Items in a row [SOLVED..kinda]

Hey guys,

i want to show the state and the batterystate of an water-detector in a single row.
My Result so far is:

I got a map for the battery_low (false=OK, true=Change Battery)

But i dont know how i transform the 0 from the battery. I want it to look like “Status: Dry / Batterie: OK”

Changing the False to 0 and true to 1 in the map doesnt help.

My Rule looks like this:

rule “allinone”

when
Item Wassermelder1_gW14_Serverraum received update or
Item Batterie_Wassermelder1_gW14_Serverraum received update or
System started

then
{ Allinone.postUpdate("Status: " + (Wassermelder1_gW14_Serverraum.state) + " / " +"Batterie: " + (Batterie_Wassermelder1_gW14_Serverraum.state))
}
end

I hope its clear what i want and that someone can help me :slight_smile:
Greets

The only solution i see is to build the status string with some if then else clauses. eg If state = 0 then Empty else OK

But maybe you may think about another approach. I use the labelclor option. If there is an Error with a device than the label is Red. Based on this i am able to search for the reason.

Thomas

You have to format that right in the postUpdate-“Command”.

sendCommand(Gui_Innentemperatur_Aussentemperatur, Temperatur_Wohnzimmer_Wand.state.format("%.1f")+ " °C / " +Wetter_Temperatur.state.format("%.1f")+ " °C")

Should also possible to format that with mapping (like it does items or sitemap):
"[MAP(kontakt.map):%s]"

Thanks for the Input!

Will try the if-else-solutiion if nothing…more smooth will work.

@anfuchs Adapted the code as followed:

when
Item Wassermelder1_gW14_Serverraum received update or
Item Batterie_Wassermelder1_gW14_Serverraum received update or
System started

then
{
Allinone.postUpdate(“Status: " + (Wassermelder1_gW14_Serverraum.state.format(”[MAP(Wassermelder.map):%s]“)) + " / " +“Batterie: " + (Batterie_Wassermelder1_gW14_Serverraum.state.format(”[MAP(Battery.map):%s]”)))
}
end

Result is unfortunately:

Maps are:

Wassermelder:
0=Trocken
1=Feuchtigkeit erkannt
2=Wasserstand erkannt
UNDEFINED=unbekannt
-=unbekannt

Batterie:
0=OK
1=Batterie wechseln!
-=unbekannt
UNDEFINED=unbekannt

Or do i still haven´t the right formatting?

Greets

Mhhhh… Than maybe mapping isn’t working in rules :frowning: … SORRY.

Unfortunately it seems so, thanks for the Input anyway. :slight_smile:

[solved]

The else-if-thing worked, but only if i define the according item as a String. HM-WD seems to write the numbers automatically as Text if you define the item as a String. Bad side is i cant work with the status as a number for further operations.

Rule now looks like:

rule “allinone”

when
Item Wassermelder1_gW14_Serverraum received update or
Item Batterie_Wassermelder1_gW14_Serverraum received update or
System started

then
if (Batterie_Wassermelder1_gW14_Serverraum.state == 0.00)
{
Allinone.postUpdate("Status: " + (Wassermelder1_gW14_Serverraum.state) + " / " +“Batterie: OK”)
}
else
{
Allinone.postUpdate("Status: " + (Wassermelder1_gW14_Serverraum.state) + " / " +"Batterie: Batterie wechseln! ")
}
end

Thanks for your help guys!

Greets

somewhere (over the rainbow) i read about transformation in rules, but i can’t remeber where

Thomas

2 Likes

Thats what i was looking for, thank you! Hope i can adapt it for my purposes :slight_smile:

1 Like