A simple list widget that controls a simple light switch. The current state of the light is represented by the icon and toggle’s color: yellow for on, gray for off.
- description: The label for the widget
- context: item
description: The light switch Item
iconColor: '=(items[props.item].state == "ON") ? "yellow" : "gray"'
color: '=(items[props.item].state == "ON") ? "yellow" : "gray"'
Hey Rich - Finally getting around to making a UI … your widgets are nice … I haven’t spent much time to understand how to code them … but quick question, I see you have a Battery Level Widget that uses a group … can the same thing be dont to control a list of lights? I’m assuming that could make the list more compact than just adding cells for each light?
I haven’t posted it to the marketplace but I have posted one at A couple of simple oh-repeater examples.
It’s a little specific to my setup though because it hides and shows different switches based on the state of an Item so that it includes the Christmas lights only while I have them up. And even that isn’t perfect because it requires “Christmas” to be in the Item label.
You are using:
in your oh-toggle-item examples. This even works in my widget, but not if I use another color instead of gray. I would like to have something like
color: '=(items[props.item].state == "ON") ? "green" : "red"'
The ON-Value always works, but with OFF I always get “gray” switches.
Make sure to reload MainUI after making the changes. Also, changes to a custom widget placed on a Layout page need to be removed and readded to that Layout page to pick up the changes.
Thanks for your response, but this hint did not work for me. I also could not find any widget sample here with colorful OFF setting
To me it seems to be a bug with OpenHAB 3.1. But I found a workaround:
Even no need for the case distinction, its done by the UI
I have just tried this widget and if I test the widget in the developer tools it works fine, but when I import the widget to the display page, I can configure the title and item, but the widget is invisible.
I do not see any log message I can link to the problem. I run openhabian with OH3.2
Do I need to install something special?
EDIT: I have realised that I need to add list and then add the widget in the list