Service Status Standalone Widget

A dynamic standalone widget that shows only those services that are offline. The widget assumes that all the Items indicating status are Switch Items or String Items where “OL” indicates online (support for the NUT binding’s online status for an UPS).

The configuration assumes a single Switch Item that is the roll-up of all service status Items. For example a Group:Switch:OR(OFF,ON) which will be OFF if one or more of that Group’s members are OFF. Other options are supported as well, such as a Switch populated via a rule. This controls the header text.

The second parameter is a comma separated list of Item tags that indicate that an Item represents a service status. The Item must have all the listed tags to be included. Semantic tags can be used (e.g. Status,Power) or you can define your own custom tag(s).

Screenshots

Changelog

Version 0.2

  • added props for the widget title

Version 0.1

  • initial release

Resources

uid: rlk_all_services
tags:
  - card
  - marketplace:128041
  - services
props:
  parameters:
    - context: item
      description: All Services Status Item, ON means all services are online
      label: Rollup status
      name: rollup
      required: true
      type: TEXT
    - context: tag
      description: Comma separated list of Item tags that indicate a service status
      label: Service Item Tags
      name: tags
      required: true
      type: TEXT
    - defaultValue: All Services Online
      description: Title when all services are online
      label: Online Title
      name: online_title
      required: false
      type: TEXT
    - defaultValue: Offline Services
      description: Title when one or more services are offline
      label: Offline Title
      name: offline_title
      required: false
      type: TEXT
  parameterGroups: []
timestamp: Nov 28, 2022, 8:04:48 AM
component: f7-card
config:
  title: '=(items[props.rollup].state == "ON") ? props.online_title : props.offline_title'
slots:
  default:
    - component: oh-list
      slots:
        default:
          - component: oh-repeater
            config:
              filter: items[loop.item.name].state != "ON" && items[loop.item.name].state != "OL"
              for: item
              fragment: true
              itemTags: =props.tags
              sourceType: itemsWithTags
            slots:
              default:
                - component: oh-list-item
                  config:
                    badge: OFFLINE
                    badgeColor: red
                    icon: f7:wifi_slash
                    iconColor: red
                    item: =loop.item.name
                    title: =loop.item.label
1 Like

It seems your Widget is what I like, but I dont get it working.

I have network Items (switch status ON/OFF) called “Paul” “Erwin” and some other, all are in a Group “Online”. (Host “Erwin” is currently offline )
In an old Sitemap the Group “Online” is Off and if I open the group one Host is Offline as expected

In your Widget I added the groupItem “Online”, you wrote:
“The second parameter is a comma separated list of Item tags that indicate that an Item represents a service status.”

But where do I have to place the Items? Or what are “Item tags” ?

My current “Edit Widget Code”/YAML:

component: oh-repeater
config:
  fragment: true
  for: item
  sourceType: itemsWithTags
  itemTags: =props.tags
  filter: items[loop.item.name].state != "ON" && items[loop.item.name].state != "OL"
  groupItem: Online
  listContainer: true
slots:
  default:
    - component: oh-list-item
      config:
        icon: f7:wifi_slash
        iconColor: red
        title: =loop.item.label
        item: =loop.item.name
        badge: OFFLINE
        badgeColor: red```

network.items

Group:Switch:OR(OFF,ON)    Online // online Services    

Switch                      Paul                        "HostState Paul"                                                        <network>   (Online)            { channel="network:pingdevice:paul:online" }
DateTime                    Paul_lastseen               "Paul WLAN lastseen [%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS Uhr]"          <time>      (FG_TimeLineRRD)    { channel="network:pingdevice:paul:lastseen" }
Number:Time                 Paul_ResponseTime           "Paul responsetime"                                                     <time>      (FG_TimeLineRRD)    { channel="network:pingdevice:paul:latency" }

Switch                      Erwin                       "HostState Erwin"                                                       <network>   (Online)            { channel="network:pingdevice:Raspi_Erwin:online" }
DateTime                    Erwin_lastseen              "Erwin lastseen [%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS Uhr]"              <time>      (FG_TimeLineRRD)    { channel="network:pingdevice:Raspi_Erwin:lastseen" }
Number:Time                 Erwin_ResponseTime          "Erwin responsetime"                                                    <time>      (FG_TimeLineRRD)    { channel="network:pingdevice:Raspi_Erwin:latency" }

network.things

network:pingdevice:paul                                     [ hostname="10.1.1.161", macAddress="00:00:00:00:00:01", retry=1, timeout=5000, refreshInterval=60000 ]
network:pingdevice:Raspi_Erwin                              [ hostname="10.1.1.124", macAddress="00:00:00:00:00:0", retry=1, timeout=5000, refreshInterval=60000 ]

The widget needs two things.

  1. The Group which is used to determine if all are online or one or more is offline. This manages the title of the widget (“All Services Online” when ON and “Offline Services” when OFF
  2. Tags which are used to identify those Items that are to be shown when they are not ONLINE

You need to add a list of Item tags to tell the widget which Items are relevant and should be shown when they are OFF.

Nowhere. You probably want them to be a member of the Group but that’s not necessary.

1 Like

Thank you very much, great work.

I never used the Tags before, still migrating from an old 2.x instance.
I tried to configure it in the repeater component but I had to put my Group-Name “Online” at “Rollup status” and the Tag “ServiceChek” behind “Service Item Tags”

now working Widget Code Sample:

component: widget:rlk_all_services
config:
  rollup: Online
  tags: ServicCheck
slots: null

Sample line with a tag

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Type                      ItemName                    Description                                                             ICON        Group               Tag             Channel
Switch                      Paul                        "HostState Paul"                                                        <network>   (Online)            ["ServicCheck"] { channel="network:pingdevice:paul:online" }

It works like a charm! :+1:

Feature request: ability to customize (localize) title text

Done.

1 Like

@rlkoshak the addon got broken now: Perhaps you should have used defaultValue, not default?

Unable to parse YAML: Unrecognized field "default" (class <SNIP>ConfigDescriptionParameterDTO), not marked as ignorable (22 known properties: <SNIP>, "defaultValue", <SNIP>])

2022-11-28 18:28:38.494 [ERROR] [munity.CommunityUIWidgetAddonHandler] [org.openhab.core.addon.marketplace] - Unable to parse YAML: Unrecognized field "default" (class org.openhab.core.config.core.dto.ConfigDescriptionParameterDTO), not marked as ignorable (22 known properties: "readOnly", "max", "limitToOptions", "groupName", "name", "stepsize", "context", "defaultValue", "min", "label", "filterCriteria", "verify", "type", "description", "options", "required", "advanced", "unit", "multipleLimit", "pattern", "multiple", "unitLabel"])
 at [Source: (StringReader); line: 20, column: 35] (through reference chain: org.openhab.core.ui.components.RootUIComponent["props"]->org.openhab.core.config.core.dto.ConfigDescriptionDTO["parameters"]->java.util.ArrayList[2]->org.openhab.core.config.core.dto.ConfigDescriptionParameterDTO["default"])
2022-11-28 18:28:38.495 [ERROR] [munity.CommunityUIWidgetAddonHandler] [org.openhab.core.addon.marketplace] - Widget from marketplace is invalid: Unable to parse YAML
data: {"topic":"openhab/addons/marketplace:128041/failed","payload":"[\"marketplace:128041\",\"Widget is not valid.\"]","type":"AddonEvent"}

I really did test it. It’s weird that it works for me. I’ve default in a number of places so I’m not sure why it’s not working here.

I edited the widget to use defaultValue here. That works for me too. Let me know if it breaks. There might be something else wrong.

Works. Thanks

1 Like