whitti
(Daniel Hermann)
April 18, 2016, 10:56am
1
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
Greets
Dibbler42
(Thomas Bail)
April 18, 2016, 1:02pm
2
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
anfuchs
(Andreas)
April 18, 2016, 1:21pm
3
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]"
whitti
(Daniel Hermann)
April 18, 2016, 1:37pm
4
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
anfuchs
(Andreas)
April 18, 2016, 1:41pm
5
Mhhhh… Than maybe mapping isn’t working in rules … SORRY.
whitti
(Daniel Hermann)
April 18, 2016, 1:46pm
6
Unfortunately it seems so, thanks for the Input anyway.
whitti
(Daniel Hermann)
April 18, 2016, 2:01pm
7
[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
Dibbler42
(Thomas Bail)
April 18, 2016, 2:23pm
8
somewhere (over the rainbow) i read about transformation in rules, but i can’t remeber where
Thomas
whitti
(Daniel Hermann)
April 19, 2016, 7:31am
10
Thats what i was looking for, thank you! Hope i can adapt it for my purposes
1 Like