rule "kip spot"
when
Item kokken_spot_switch changed to ON
then
Thread::sleep(500)
kokken_spot_switch.sendCommand(OFF)
end
This actually works great.
The light icon reflects the state of the output.
I tried to accomplished this in 2.1.0, but can’t get it to work.
Correct me if i’am wrong, in openHAB 2, the icon follows the switch item, right?
So i can’t force the icon to follow the state of my output.
What do i do to get the above code to work in the version 2?
The behavior of dynamic icons has changed a bit. You can no longer refer to dynamic icons like that any longer.
What you need to do is copy the icons you want and name them something like kokkenon.png and kokkenoff.png (note there is not a - and it uses all lowercase). Then use those as your icons on the sitemap for those Items.
You can download the PNG version of the default icons here. I’m not sure where to get the svg icons.
Thanks @ThomDietrich, i have read that page multiply times, and i do understand the new behavior of dynamic icons. But i can’t find anything about renaming the icons, to force them to follow the visibility state and not the item state.
Hello @alkaline, thanks for posting a complete example, however I have to ask why you did go through all that trouble. You’ve basically imitated the functionality of Dynamic Icons. The same thing can be accomplished by the following set.
Did you do all of that just to spare you of one additional sitemap element? I admire the passion
Still, so that no one gets the wrong idea, a slightly different solution would be:
Number WZ1_Heizung_Valve_Percent <heating>
rule "Wohnzimmer WZ1 Icons Heizung"
when
Item WZ1_Heizung_Valve changed
then
WZ1_Heizung_Valve_Percent.postUpdate(WZ1_Heizung_Valve.state * 100)
end
Hi @ThomDietrich, thanks for clarification. However, the idea wasn’t to have two items displayed within sitemap, but one item (only the switch), which has the icon of the valve state applied which works great. I am acting from an end-user point of view since I am not a professional coder at all. So my solution can be optimized?
Hmmmmmmm,
nope I think your solution is the best you can do. The only thing you could probably improve is figure out a formula to reduce your rule to one line. Something like (untested!)