Schritt 14 - Kapitel 3, jetzt schicken wir die Schildkröte los
Bitte baut am Ende der Layoutdatei folgende Zeilen ein:
# Kapitel 14 - Teil 3
# wir schicken die Schildkröte los
# http://de.wikipedia.org/wiki/KTurtle
#
rgb "00FF00"
pt 12
# Wertebezeichnungen linksbündig ausgeben
thalign "left"
moveto 410 360
text x y "Temperatur"
moveby 0 30
text x y "Luftfeuchte"
moveby 0 30
text x y "Luftdruck"
# Messwerte rechtsbündig ausgeben
thalign "right"
moveby 140 0
text x y {ReadingsVal('owo','c_pressure','?')}
moveby 0 -30
text x y {ReadingsVal('owo','c_humidity','?')}
moveby 0 -30
text x y {ReadingsVal('owo','c_temperature','?')}
# Einheiten linksbündig an die Messwerte anhängen
thalign "left"
moveby 2 0
text 552 y "°C"
moveby 0 30
text x 390 "%"
moveby 0 30
text x y " hPa"
Das Ergebnis sieht optisch genauso aus wie die ersten drei Wertezeilen, nur in grün.
(http://up.picr.de/17994399nk.png)
Wozu dann das Ganze?
Nunja, stellt Euch mal vor, Ihr wollt bei den drei Readings die Luftfeuchtigkeit nur dann anzeigen, wenn es regnet.
Dann kann man das entweder so lösen (am Beispiel der weiss angezeigten Readings)
condition {(ReadingsVal('regenDummy','state','') eq 'rain')}
text 410 300 "Luftfeuchte"
condition 1
oder so - (am Beispiel des Schildkrötenprinzips)
condition {(ReadingsVal('regenDummy','state','') eq 'rain')}
moveby 0 30
text x y "Luftfeuchte"
condition 1
Der grundlegende Unterschied für den Fall, dass es NICHT regnet, ist klar erkennbar:
(http://up.picr.de/17994455ji.png)
Im weissen Beispiel wird zwar die Luftfeuchtigkeit nicht angezeigt, aber es entsteht eine Lücke.
Im grünen Beispiel wird die Luftfeuchtigkeit nicht anzeigt, die Schildkröte läuft aber auch nicht weiter und der Luftdruck rutscht einfach um eine Zeile nach oben.
Klar?
Ein Anwendungsfall aus meiner Produktivumgebung, ich überwache damit meine Fenster- und Türkontakte.
Geschlossene Fenster/Türen werden nicht angezeigt, gekippte Fenster/Türen werden gelb, geöffnete Fenster/Türen in rot dargestellt.
Dieses Codebeispiel NICHT in das Workshop-Layout übernehmen!
#--------------------
# Türen und Fenster
#
condition 1
thalign "left"
moveto 410 50
condition { ReadingsVal("Melder_TEingang","state","") eq "open" }
rgb "FF0000"
moveby 0 20
text 410 y { "Eingang" }
text 470 y { ts2text(ReadingsTimestamp("Melder_TEingang","state","")) }
condition { ReadingsVal("Melder_TBalkon","state","") eq "open" }
rgb "FF0000"
moveby 0 20
text 410 y { "Balkon" }
text 470 y { ts2text(ReadingsTimestamp("Melder_TBalkon","state","")) }
condition { ReadingsVal("Melder_TBalkon","state","") eq "tilted" }
rgb "FFFF00"
moveby 0 20
text 410 y { "Balkon" }
text 470 y { ts2text(ReadingsTimestamp("Melder_TBalkon","state","")) }
condition { ReadingsVal("Melder_FSl","state","") eq "open" }
rgb "FF0000"
moveby 0 20
text 410 y { "SZ li" }
text 470 y { ts2text(ReadingsTimestamp("Melder_FSl","state","")) }
condition { ReadingsVal("Melder_FSr","state","") eq "open" }
rgb "FF0000"
moveby 0 20
text 410 y { "SZ re" }
text 470 y { ts2text(ReadingsTimestamp("Melder_FSr","state","")) }
condition { ReadingsVal("Melder_FSr","state","") eq "tilted" }
rgb "FFFF00"
moveby 0 20
text 410 y { "SZ re" }
text 470 y { ts2text(ReadingsTimestamp("Melder_FSr","state","")) }
condition { ReadingsVal("Melder_FKl","state","") eq "open" }
rgb "FF0000"
moveby 0 20
text 410 y { "KU li" }
text 470 y { ts2text(ReadingsTimestamp("Melder_FKl","state","")) }
condition { ReadingsVal("Melder_FKr","state","") eq "open" }
rgb "FF0000"
moveby 0 20
text 410 y { "KU re" }
text 470 y { ts2text(ReadingsTimestamp("Melder_FKr","state","")) }
condition { ReadingsVal("Melder_FKr","state","") eq "tilted" }
rgb "FFFF00"
moveby 0 20
text 410 y { "KU re" }
text 470 y { ts2text(ReadingsTimestamp("Melder_FKr","state","")) }
condition { ReadingsVal("Melder_FAl","state","") eq "open" }
rgb "FF0000"
moveby 0 20
text 410 y { "AZ li" }
text 470 y { ts2text(ReadingsTimestamp("Melder_FAl","state","")) }
condition { ReadingsVal("Melder_FAr","state","") eq "open" }
rgb "FF0000"
moveby 0 20
text 410 y { "AZ re" }
text 470 y { ts2text(ReadingsTimestamp("Melder_FAr","state","")) }
condition { ReadingsVal("Melder_FAr","state","") eq "tilted" }
rgb "FFFF00"
moveby 0 20
text 410 y { "AZ re" }
text 470 y { ts2text(ReadingsTimestamp("Melder_FAr","state","")) }