Post by papa on Feb 14, 2016 16:19:50 GMT
User Interface (UI) screen real-estate can get crowded & our mouths start watering at posts offering Multiple Items on a Line.
I tried some of those & they did not work for me due to some errors & perhaps OpenHAB changes or differences on operating systems.
On Windows, I had adapted the Humidex rule to Fahrenheit & it had worked & I believe still works (I'm watching it from a distance)
However, on Linux, the Humidex rule was not working, not even showing an error.
I believe I learned: (At least for Linux,) don't use quotes or spaces in rule names (?).
This much got me one rule using postUpdate that worked.
Next the elements for combining Weather Temp & Weather Humidity on the same UI line.
Added on 2/15/2016: The following items get weather info for Santa Clara, CA (w=2488836 below). For your town, put your location in the input box at weather.yahoo.com. See the number that appears at the end of the internet address box. Use that number instead of 2488836 in the items below. For example, for Omaha, NE, use w=2465512.
Items (for Santa Clara, CA whose Yahoo Weather woeid is 2488836)
Number Weather_Temperature "Outside Temperature [%.1f °F]" <temperature> (Weather_Chart) { http="<[http://weather.yahooapis.com/forecastrss?w=2488836&u=f:60000:XSLT(yahoo_weather_temperature.xsl)]" }
Number Weather_Humidity "Outside Humidity [%.1f %%]" <humidity> (Weather) { http="<[http://weather.yahooapis.com/forecastrss?w=2488836&u=f:60000:XSLT(yahoo_weather_humidity.xsl)]" }
String Climate_Out "Climate Outside [%s]" <comfort_level> (Weather)
Rules:
rule Ext_Climate
when
Weather_Temperature changed or
Weather_Humidity changed or
Time cron "0 */2 * * * ?"
then
var Number HumiW = Weather_Humidity.state
var Number TempW = Weather_Temperature.state
var Number HumiW_r = (Math::round(HumiW.floatValue))
var Number TempW_r = (Math::round(TempW.floatValue * 10.0 ) /10.0)
Climate_Out.postUpdate(TempW_r + "°F... " + HumiW_r + "%")
end
Sitemap:
Text item=Climate_Out valuecolor=["green"]
Notes:
Config elements already included in openhab-papa.zip: the top two items.
New (& not yet in the zip file): the Climate_Out item, the Ext_Climate rule, & the sitemap entry.
The top two items get the Weather Temp & Humidity for w=2488836, namely Santa Clara, CA. For your location code, go to weather.yahoo.com, enter your town name & get the number that appears at the end of the internet address.
u=f for fahrenheit & related measures. Change that to u=c for Celsius related measures.
Using postUpdate, the last item will receive the combination of the top two items.
The rule is triggered when the state of either top item changes or every 2 minutes (a frequency you can change)
The rule massages & then with postUpdate combines the top two items states with each other & explanatory labels.
The sitemap entry displays the combined item states in green text.
At present, it seems these two versions of postUpdate will both work:
postUpdate(Climate_Out,TempW_r + "°F... " + HumiW_r + "%")
Climate_Out.postUpdate(TempW_r + "°F... " + HumiW_r + "%")
Probably because more is involved (including the finding & parsing of a rule), displaying a line of combined item states seems to take a bit longer than displaying the separate item states
Seems an ok trade for more efficiently using the screen.
Again about rule names, it currently seems to me that OpenHAB (1.8.1) (at least on Linux) ignores rules whose names have quotes or spaces
Whereas, names like Ext_Climate work.