Hello sl4m,
again sorry for the delay.
Here i try to show you my solution for my task implementation.
I tried to keep everything generic and customizable to be able to create tasks for my home from variable sources with varible functions/icons/links/actions.
Im not a very advances OH-user but this solution works for me:
Items:
// l // Logging Tasks ==========================================================
String lTim_Str
String lTop_Str
String lCol_Str
String lTxt_Str
String lIco_Str
String lAct_Str
String lActItm_Str
String lActCom_Str
String lActTxt_Str
Number lDel_Num
Usage of Items: For all tasks, all (for example) Topics are stored in lTop_Str and Semicolon separated → This way i can have a variable amount of tasks, but a fixed number of items
Example for content of lTop_Str:
How to use the items, defined above i share with you my loggingtasks.rules which contains
- Create dummy-tasks for debugging and testing
- Function which deletes only a certain task (triggert from the button in the task-widget)
loggingtasks.rules:
// ========================================================
// LOGGING TASKS
// ========================================================
rule "LoggingTaskTest"
when
Item rRule_Str changed to "LoggingTaskTest"
then
// Define Dummy Arrays
val String aTim = "21.05.2021;Dienstag;Mittwoch;"
val String aTop = "Fehler;Abfall;Wetter;"
val String aTxt = "Heizung - Kreislauf 1 Druck zu hoch;Biomüll;Gewitter;"
val String aCol = "red;green;yellow;"
val String aAct = "navigate;NULL;url;"
val String aActCom = "page:buero;NULL;http://www.weather.com;"
val String aActItm = "NULL;NULL;NULL;"
val String aActTxt = "Heizungsdaten;NULL;Gehe zu weather.com;"
val String aIco = "f7:exclamationmark_circle_fill;f7:archivebox;f7:cloud;"
// Set Values
lTim_Str.sendCommand(aTim)
lTop_Str.sendCommand(aTop)
lTxt_Str.sendCommand(aTxt)
lCol_Str.sendCommand(aCol)
lAct_Str.sendCommand(aAct)
lActCom_Str.sendCommand(aActCom)
lActItm_Str.sendCommand(aActItm)
lActTxt_Str.sendCommand(aActTxt)
lIco_Str.sendCommand(aIco)
lDel_Num.sendCommand(-1)
end
rule "Logging Task Delete"
when
Item lDel_Num changed
then
// If a valid item number to delete was set
if (lDel_Num.state >= 0){
logInfo("LOGGINGTASK", "Task #" + lDel_Num.state +" erased")
// Declarate temp Strings
var String lTim_Str_tmp = ""
var String lTop_Str_tmp = ""
var String lCol_Str_tmp = ""
var String lTxt_Str_tmp = ""
var String lIco_Str_tmp = ""
var String lAct_Str_tmp = ""
var String lActCom_Str_tmp = ""
var String lActItm_Str_tmp = ""
var String lActTxt_Str_tmp = ""
// Get number of items
var Number len = lTxt_Str.state.toString.split(";").length
// Set numerator
var Number i = 0
// Loop through elements
while (i< len) {
// Do not copy the part which is to delete
if (lDel_Num.state as Number != i){
// Copy Task if it shall not be deleted
lTim_Str_tmp = lTim_Str_tmp + lTim_Str.state.toString.split(";").get(i.intValue).toString + ";"
lTop_Str_tmp = lTop_Str_tmp + lTop_Str.state.toString.split(";").get(i.intValue).toString + ";"
lCol_Str_tmp = lCol_Str_tmp + lCol_Str.state.toString.split(";").get(i.intValue).toString + ";"
lTxt_Str_tmp = lTxt_Str_tmp + lTxt_Str.state.toString.split(";").get(i.intValue).toString + ";"
lIco_Str_tmp = lIco_Str_tmp + lIco_Str.state.toString.split(";").get(i.intValue).toString + ";"
lAct_Str_tmp = lAct_Str_tmp + lAct_Str.state.toString.split(";").get(i.intValue).toString + ";"
lActCom_Str_tmp = lActCom_Str_tmp + lActCom_Str.state.toString.split(";").get(i.intValue).toString + ";"
lActItm_Str_tmp = lActItm_Str_tmp + lActItm_Str.state.toString.split(";").get(i.intValue).toString + ";"
lActTxt_Str_tmp = lActTxt_Str_tmp + lActTxt_Str.state.toString.split(";").get(i.intValue).toString + ";"
}
logInfo("LOGGINGTASK", lTim_Str_tmp)
// Increase numerator
i = i + 1
}
// Update Log Items
lTim_Str.sendCommand(lTim_Str_tmp)
lTop_Str.sendCommand(lTop_Str_tmp)
lCol_Str.sendCommand(lCol_Str_tmp)
lTxt_Str.sendCommand(lTxt_Str_tmp)
lIco_Str.sendCommand(lIco_Str_tmp)
lAct_Str.sendCommand(lAct_Str_tmp)
lActCom_Str.sendCommand(lActCom_Str_tmp)
lActItm_Str.sendCommand(lActItm_Str_tmp)
lActTxt_Str.sendCommand(lActTxt_Str_tmp)
// Reset Delete Indicator
lDel_Num.sendCommand(-1)
}
end
As you may already have seen, i kept these funcions flexible to be able to configure different functions
- 1st example Task: navigate to page:buero if “Heizungsdaten” is klicked
- 2nd example Task: no further functions (despite delete)
- 3rd example Task: forwarding to a url for opening up weather-forcast
And least but not last the page & widget code which will make it clear to you how to use these functions:
"Aufgaben"-page:
config:
layoutType: responsive
label: Aufgaben
visibleTo:
- role:administrator
- role:user
sidebar: true
order: "0"
blocks:
- component: oh-block
config: {}
slots:
default:
- component: oh-grid-row
config: {}
slots:
default:
- component: oh-grid-col
config: {}
slots:
default:
- component: widget:cLink
config:
title: Aufgaben
link: overview
backgroundurl: /static/tasks.jpg
- component: oh-grid-row
config: {}
slots:
default:
- component: oh-grid-col
config: {}
slots:
default:
- component: widget:listLogTasks
config: {}
- component: oh-grid-row
config: {}
slots:
default:
- component: oh-grid-col
config: {}
slots:
default:
- component: widget:listLogNothingToDo
config: {}
masonry: null
grid: []
"listLogTasks"-widget:
(As you see, there are no props to set, due to the fact, that this is a purpose-built widget)
uid: listLogTasks
tags:
- repeater
- list
- log
- tasks
timestamp: Jun 11, 2021, 6:43:54 AM
component: oh-repeater
config:
for: int
sourceType: array
in: =items["lTim_Str"].state.split(";")
filter: loop.int
fragment: true
slots:
default:
- component: oh-list-card
config:
footer: =items["lTim_Str"].state.split(";")[loop.int_idx]
accordionList: true
slots:
default:
- component: oh-list-item
config:
icon: =items["lIco_Str"].state.split(";")[loop.int_idx]
title: =items["lTxt_Str"].state.split(";")[loop.int_idx]
badge: =items["lTop_Str"].state.split(";")[loop.int_idx]
badgeColor: =items["lCol_Str"].state.split(";")[loop.int_idx]
iconColor: =items["lCol_Str"].state.split(";")[loop.int_idx]
accordionItem: true
slots:
accordion:
- component: oh-list-card
config:
outline: true
slots:
default:
- component: oh-list-item
config:
title: Löschen
listButton: true
color: red
action: command
actionItem: lDel_Num
actionCommand: '=(loop.int_idx == "") ? "0" : loop.int_idx'
- component: oh-list-item
config:
visible: =items["lAct_Str"].state.split(";")[loop.int_idx] == "navigate"
listButton: true
title: =items["lActTxt_Str"].state.split(";")[loop.int_idx]
action: navigate
actionPage: =items["lActCom_Str"].state.split(";")[loop.int_idx]
- component: oh-list-item
config:
visible: =items["lAct_Str"].state.split(";")[loop.int_idx] == "command"
listButton: true
title: =items["lActTxt_Str"].state.split(";")[loop.int_idx]
action: command
actionItem: =items["lActItm_Str"].state.split(";")[loop.int_idx]
actionCommand: =items["lActCom_Str"].state.split(";")[loop.int_idx]
- component: oh-list-item
config:
visible: =items["lAct_Str"].state.split(";")[loop.int_idx] == "rule"
listButton: true
title: =items["lActTxt_Str"].state.split(";")[loop.int_idx]
action: rule
actionRule: =items["lActCom_Str"].state.split(";")[loop.int_idx]
- component: oh-list-item
config:
visible: =items["lAct_Str"].state.split(";")[loop.int_idx] == "url"
listButton: true
title: =items["lActTxt_Str"].state.split(";")[loop.int_idx]
action: url
actionUrl: =items["lActCom_Str"].state.split(";")[loop.int_idx]
And here the Widget if all taks are done:
uid: listLogNothingToDo
tags: []
props:
parameters:
- description: A text prop
label: Prop 1
name: prop1
required: false
type: TEXT
- context: item
description: An item to control
label: Item
name: item
required: false
type: TEXT
parameterGroups: []
timestamp: Jun 8, 2021, 7:54:01 PM
component: f7-card
config:
visible: =(items["lTim_Str"].state.split(";").length <= 1)
class:
- text-align-center
slots:
default:
- component: oh-label-card
config:
label: Alles erledigt!
action: command
actionItem: rRule_Str
actionCommand: LoggingTaskTest
- component: oh-image
config:
url: /static/nothingtodo.png
which looks like this
(If you click at “Alles erledigt!”, the debug-/test-tasks (from rule-script) will be created)
- I hope this is what you wanted me to provide
- For sure some more advanced users than me can give additional tips/improvements for this implementation
- Mor me its (at the moment) a centralized implementation to bundle taks from random sources
Have fun and if there is something still unclear → I will try do provide more information