Dynamic icon using rules

167 views
Skip to first unread message

Tebbaerty Tebbaerty

unread,
Jun 28, 2015, 2:53:22 PM6/28/15
to ope...@googlegroups.com
Hi,

Is it possible to use dynamic icon ?

What i am trying to do is the following :
1. Have weather binding configured
2. Show temperature with dynamic icon. Aggregate some weather conditions into a single icon ( ex: if its sunny, or sun with clouds then show sunny icon, if its raining or no sun at all then show cloud icon)

How would i create an item which has the icon updated depending on other conditions like wind, cloudy, sunny, etc...
I imagine i should use rules, but i don't know how exactly

Thanks,

Torgeir

unread,
Jun 30, 2015, 3:58:37 AM6/30/15
to ope...@googlegroups.com
There's a similar example on this on the "Samples-Tricks" page: https://github.com/openhab/openhab/wiki/Samples-Tricks#how-to-use-yahoo-weather-images
I'm using it myself, and it works fine.... shows different images according to the current weather.

Tebbaerty Tebbaerty

unread,
Jun 30, 2015, 8:01:38 AM6/30/15
to ope...@googlegroups.com
Hi,

Thanks for your suggestion. It looks very good. If no other option will be provided, i will stick with that.


However, what i am really interested in, is how do i use rules to update the icon of an item ?
Basically i want to create a rule that when Item1 or Item2 was changed then update Item3.icon

Is it possible ?
I've seen that with postUpdate you can change the value of an item, but how about it's icon ?

watou

unread,
Jun 30, 2015, 8:12:49 AM6/30/15
to ope...@googlegroups.com


...what i am really interested in, is how do i use rules to update the icon of an item ?
Basically i want to create a rule that when Item1 or Item2 was changed then update Item3.icon

Something like this:

your.items:

String House "[%s]"
Switch Flood "[%s]"
String Level "[%s]" <level>

your.rule:

rule SetLevel
when
 
Item House changed or
 
Item Flood changed
then
 
var level = (Flood.state == ON) ? "high" : "low"
 
Level.postUpdate(level)
end

Have icons named level-high.png and level-low.png and the icon on the Level item will change.


Reply all
Reply to author
Forward
0 new messages