Hi everyone,
I am currently in the process of upgrading from Openhab 2 to Openhab 3 and face some issues/questions (to keep the topics clean I open one for each issue).
Platform information:
Hardware: Raspi
OS: Openhabian
openHAB version: 3
Icons based of State
For some rules I have the dependency times set based on the current season of the year. That setting can be changed inside the sitemap. Is there a possibility to change the icon of items based on the state with a rule/script? I cannot find any ressources and I think that was possible in OH2, wasn’t it?
The only thing I found was the option to set up dynamic icons → Items | openHAB
Is this the only option I have?
The states are basically
Summer
Winter
In-between
which are realized inside the metadata as mappings (see screenshots below).
To realize that I would download some icons of openhab (sun, snowflake, fog) and save them as “season-1”, “season-2” and “season-3”, so that they fit to the 3 number values of the item. Is that correct?
Dynamic icons would be the easiest way to make this work, and your summary of how to set that up is correct: give them all the same name followed by -<state>.
This is not the only solution:
If you are still using sitemaps then you could create three different lines for the same item and use a different icon for each of those three lines. Then each line can have a different visibility test based on the season item so that only the one with the correct icon shows at any given time. See dynamic sitemaps.
Now that you’re on OH3 if you are starting to change over from sitemaps to the new MainUI then this is very easy in any of the widgets where you can select an icon. You can find many examples of conditional statements in widgets throughout the forum and the expressions can be used to set dynamic icons.
The visibility route seems to be even easier for that issue. I will try it out.
The new UI Topic will be discovered once I have migrated the old OH2 setup. First I need to understand how the old stuff works in OH3, then the new features will be included But thank you for this hint, which would most likely be a question once I start to set the Widgets up.
After some research inside the Forum and some git issues it seems like that the visibility option can only be set when the sitemap is configured over the file system and not via the UI. Is that correct?