I would like to have buttons as well as a slider in my sitemap to control my dimmers. For example I almost always go either 10%, 25%, 50%, 90% or full bright. Is there an “Easy” way do this?
I thought of adding this to my sitemap: Switch item=LivingRoomLampLevels mappings=[10="10%", 25="25%", 50="50%", 90="90%", 100="Full"]
and visually that kinda works.
I add this to my items file: Switch LivingRoomLampLevels "Levels"
and then I guess I need custom rules to accept the button push evens and make these into commands. I found the documentation to be very lacking in this area. So my question(s) are:
is this the best way to do this?
What would a rule look like to accept events of LivingRoomLampLevels
Can I make a custom UI element to do this instead, that perhaps I can reuse? I want this functionality with all my dimmers.
I did kind of get this working like this: rule "Living Room Lamp Level" when Item LivingRoomLampLevels received command then logDebug("delmar.rules","Got command:" + receivedCommand as DecimalType) sendCommand(LivingRoomLamp, receivedCommand as DecimalType) end
but it feels like a dirty hack, and I would have to repeat this several times. Is there a better way?
You can use a Switch sitemap element with a mapping configuration linked to a Dimmer item, as long as the command that is sent through the Switch element is accepted by the Dimmer item. In this case, the commands sent to the item are 10, 25, 50, 90 and 100, integer values between 0 and 100, so your LivingRoomLamp item will be able to process them easily.
You are also allowed to add an extra mapping definition like OFF=“OFF” to be able to turn the lamp off using the same sitemap element!