Sitemap Switch Group Item Mappings

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 problem is since gFamilyRoom_Lights value is a decimal the sitemap won’t show the current state. Luckily at least the light icon will change based on the value of the lights. But it is confusing when looking at the sitemap when a Dimmer item will have On or Off highlighted, but if it is a group of Dimmers it won’t.

1 Like

It would be nice to have
mappings=[<0.01="Off" ...
mappings=[as OnOffType==OFF ="Off" ...
but we can’t.

I think this kludge might work ?

Switch item=gFamilyRoom_Lights icon="light" mappings=[0="Off",30="Dim",100="On"] visibility=[gFamilyRoom!=0.0]
Switch item=gFamilyRoom_Lights icon="light" mappings=[0.0="Off",30="Dim",100="On"] visibility=[gFamilyRoom==0.0]
1 Like

I just created proxy items.

@rule("proxy_gLivingRoom_Lights received command")
@when("Item proxy_gLivingRoom_Lights received command")
def proxy(event):
    sendCommandCheckFirst("gLivingRoom_Lights", str(event.itemCommand))

@rule("gLivingRoom_Lights received update")
@when("Item gLivingRoom_Lights changed")
def bound(event):
    postUpdateCheckFirst("proxy_gLivingRoom_Lights", int(event.itemState.floatValue()))

And then use:

Switch item=proxy_gLivingRoom_Lights icon="light" mappings=[0="Off",30="Dim",100="On"]

In my sitemap. Seems to give me the desired effect. Just a bit more overhead than I was hoping for.

postUpdateCheckFirst() wasn’t working for me because of the parallel nature of events. Switched it to events.postUpdate() instead. Also made a group for proxies and proxied items so I could clean up my rule to just:

from core.rules import rule
from core.triggers import when
from core.utils import sendCommandCheckFirst, postUpdateCheckFirst

@rule("Proxies Group received command")
@when("Member of gProxies received command")
def proxy(event):
  sendCommandCheckFirst(str(event.itemName)[6:], str(event.itemCommand))

@rule("Proxied Group Changed")
@when("Member of gProxied changed")
def bound(event):
  events.postUpdate("proxy_" + str(event.itemName), str(int(event.itemState.floatValue())))

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.