This template supervises not ignored Things. When a Thing is offline, it changes the item Things online item to off and creates a new item under Parent item with the label set to the label of the Thing that is offline. Then it switches that item to off.
When the Thing is online again, the created item is not deleted but switched to on. That way offline/online history is kept and you can analyse, when Things were offline to find potential problems.
To setup this template, follow these steps.
Prepare the item:
- Click on
Settings→Model - On the right, click on
Add Equipment - Name:
OnlineThings, Label:Online Things - Click
Create - Click
Add Metadata→State Description - Toggle on
Read onlyandSave(top right) - Click on
Online Thingsto open it - Click
Editon top right - Set
Members Base TypetoSwitch - Click
Save(top right)
Install the template:
- Click on
Settingsand then onAutomation - Scroll to
Rule Templatesand click onShow xx more - Click the
ADDbutton onOffline Things Display - Click the large
ADDbutton on the pop up
Setup the rule:
- Go to
Rulesand create a rule fromOffline Things display. - Select the above item
Online ThingsasParent item,Ignored Things itemandThings online item. - Force a Thing to be offline by e.g. removing power from it
- Check the item
Online Things, it should go tooffand an item named after the offline Thing should be created inside.
Ignore a Thing:
- Go to
Settings→Things - In the list, on the Thing you want to ignore, click the square
Copy UID - Click on
Settings→Model - Click on
Online Things - On the right, click on
Online Thingsto open it - Click
Editon top right - Paste into
Add tagand pressenter - Click
Save(top right)
Show it on a page:
- Click on
Settings→Pages - Click on
Overview(or an other page you want) - If you don’t have rows/columns, click
Add Rowand on the rowAdd Column - Click on it and choose
List card - Click on the
+and chooseLabel List Item - Click on it and
Edit YAML - Paste the code
YAML for Label List Itembelow into it - Click
DoneandSave(top right)
Note:
Then you use a Group as Things online item, the state on and off is only visible if at least one item was created within the group.
Inputs, corrections and suggestions are very welcome.
Detection of offline Things is based on the template Thing Status Reporting. My first approach was to use it to implement this template. But it turned out more complicated than implementing that part myself.
YAML for Label List Item:
component: oh-label-item
config:
action: group
actionGroupPopupItem: OnlineThings
item: OnlineThings
style:
background: =items.OnlineThings.state == 'OFF'?'red':''
title: Online Things
Language: ECMAScript (ECMAScript 262 Edition 11)
Dependencies: JavaScript Scripting
Changelog
Version 0.1
- initial release
Version 0.2
- do not delete online items in other groups
Version 0.3
- fix item deletion