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.



Version 0.1

  • initial release


uid: rlk_light_list_widget
  - list
  - light
    - description: The label for the widget
      label: Title
      name: title
      required: false
      type: TEXT
    - context: item
      description: The light switch Item
      label: Item
      name: item
      required: false
      type: TEXT
  parameterGroups: []
component: oh-toggle-item
  icon: f7:lightbulb
  iconColor: '=(items[props.item].state == "ON") ? "yellow" : "gray"'
  color: '=(items[props.item].state == "ON") ? "yellow" : "gray"'
  title: =props.title
  item: =props.item

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.

Any idea?

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:

 color: green
   --f7-toggle-inactive-color: red

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