chrisonline
(Christian Grasser)
November 24, 2020, 10:49am
1
I have a Dimmer
item who has additional state types (see here at the bottom https://docs.openhab.org/v2.2/concepts/items.html ).
Main state is PercentType
but it has also the state type OnOffType
.
If I add this item with default
to the sitemap I get of course a dimmer item.
If I change the type to switch
I get the switch item.
But I want to show instead of the switch 2 buttons with “ON” and “OFF”.
With a standard switch item I use a mapping with “ON=” and “OFF=”.
This is not possible with the dimmer item because it checks always the state of the current dimmer value.
For example state=1 or state=50.
How can I access inside the mapping the alternative state “ON” and “OFF”?
Just use a Switch
sitemap element with your Dimmer
Item. Something like:
Switch item="myDimmerItem" label="myDimmerItem []" mappings=[ON="ON", OFF="OFF"]
Or if you want to provide absolute values:
Switch item="myDimmerItem" label="myDimmerItem []" mappings=[100="ON", 0="OFF"]
chrisonline
(Christian Grasser)
November 24, 2020, 11:26am
3
Thanks I have already do this.
The problem is that now I don’t see the current state.
Both buttons are not enabled because the item state is reported as state=1 or state=50 and so on.
So I want to access the alternate state because this would be on state=1 or state=50 “ON” and if state=0 it would be "OFF.
Ah, I see. I don’t think this is possible.
This might help:
Is it possible to make a Group Item with a base type of Dimmer return an Integer from any of the Functions? Alternatively is there a way to make a Sitemap Switch mapping match both 0 and 0.00000000?
I have a group item of base type Dimmer with my lights color items called gFamilyRoom_Lights.
In my sitemap I have:
Switch item=gFamilyRoom_Lights icon="light" mappings=[0="Off",30="Dim",100="On"]
This makes a nice button to turn On, Off, or set to a predefined dim level all in one line. The prob…
1 Like
chrisonline
(Christian Grasser)
November 24, 2020, 1:06pm
5
Thanks.
I have exactly searched for something like this mentioned in the linked post from you:
mappings=[as OnOffType==OFF ="Off" ...
But as also mentioned this is not possible.
So I will add an virtual item
for this.