Hi! I want to get a switch with an icon frontdoor which shows open or closed door and raises the switch in the correct position.
all works, but the frontdoor icon does not switch.
I use icon=“frontdoor” at my sitemap.
and a switch next to the icon. With getting an http “on” or “off” the switch shows correct state.
i already have to use the following binding because of getting an “on” for closed door and an “off” for opened door from the binding:
Where the one without the - is the default icon that gets shown when the Switch is not ON or OFF (i.e. NULL). You must have all three.
To not have the toggle icon, use Text to put it on your sitemap instead of Switch.
Text item=FrontDoorOut label="FrontDoor: " icon="frontdoor"
But since you already have to populate the door using a Rule, why not create a Proxy Item to represent the door and a slightly more complicated rule to populate the Item.
Contact FrontDoorOutProxy
rule "frontdoor 1"
when
Item FrontDoorOutValue received update or
Item FrontDoorOut received update
then
var newState = CLOSED
if(FrontDoorOutValue.state == "on") newState = OPEN
if(FrontDoorOut.state == ON) newState = OPEN
if(newState != FrontDoorOutProxy.state) FrontDoorOutProxy.postUpdate(newState)
end
Lock or unlock next to the door would be nice too. Or open close. Are these all contact items?
I can get an open or lock status too if it would prevent a rule…
You might benefit from a review (or reread) of the Beginner’s Tutorial and the Items pages of the User’s Guide.
A Contact is another type of Item, like Switch and Dimmer and such.
There is no LOCK/UNLOCK state but you can use a map and custom icons to change ON to UNLOCK and OFF to UNLOCKED. Again, see the Item’s documentation.
None of these are contact Items. A Contact is a type of Item like a State. Unlike a State, a Contact has OPEN/CLOSED as its states instead of ON/OFF.
As long as you have two sources that are providing the state of your one Door Item and they are doing so in two different ways you will have to have a Rule.
It isn’t only for the Icon. The proxy is to be able to combine the state from two separate Items that are incompatible with each other into a single Item. That is what you original code was doing.