Are you sure?
The code I pasted above has several "log.info" lines.
Are you sure?
The code I pasted above has several "log.info" lines.
My apologies. I use both "Light Usage Table" and "Usage and Count" and it is Usage & Count that is creating the log entries. Sorry for wasting your time. I now have my head on straight.
Not a worry.
@kewashi or @bravenel, any way we can reset an individual device's duration time instead of the entire table? I'd like to keep the rest of the devices in the table's information within the table.
You can do that here on the table manually or using a remote variable. Reset individual device times and on counts.
I've almost got a table working on an app UI, but am stuck with trying to get the table to update after edits. Any suggestions?
When the user clicks "Save", I run this code:
void appButtonHandler(btn) {
...
confirmEditPeriod()
....
}
def confirmEditPeriod() {
def periodMap = [:]
periodMap.start = settings["periodStart"]
periodMap.end = settings["periodEnd"]
state.scheduleMap[(state.editingPeriod.schedule)][state.editingPeriod.period].start = periodMap.start
state.scheduleMap[(state.editingPeriod.schedule)][state.editingPeriod.period].end = periodMap.end
state.editingPeriod = null
}
So I save the field values to state, and then presumably the page reloads. But the table info doesn't update unless you click Save a second time. What's the trick to get the table info to update right away?
Let me know if I need to show more of the code....
This forces a page reload, but you have to be careful to avoid a refresh loop:
paragraph "<script>{changeSubmit(this)}</script>"
That should be protected by a test of something, so that it only happens once.
Ok. I had seen that in your example code and tried that, but I'm afraid it isn't doing the trick either...What am I doing wrong?
void appButtonHandler(btn) {
...
confirmEditPeriod()
....
}
def confirmEditPeriod() {
logDebug("confirm", "Debug")
def periodMap = [:]
periodMap.start = settings["periodStart"]
periodMap.end = settings["periodEnd"]
state.scheduleMap[(state.editingPeriod.schedule)][state.editingPeriod.period].start = periodMap.start
state.scheduleMap[(state.editingPeriod.schedule)][state.editingPeriod.period].end = periodMap.end
state.editingPeriod = null
state.refreshTable = true
}
def schedulePage() {
dynamicPage(name: "schedulePage") {
section() {
if (state.refreshTable == true) {
state.refreshTable = false
paragraph "<script>{changeSubmit(this)}</script>"
}
...
displayPeriodTable(j)
...
}
}
}
Full code is here (work in progress still)
EDIT: adding debug logging right after I set the state in confirmEditPeriod suggests that the state isn't being updated in confirmEditPeriod. Hmm.
EDIT2: Ok, I got it working. Even though the button submits the page, putting submitOnChange: true for each of the entry fields being editing made it to where those edits are reflected the first time the button is pressed. No need it seems for the changeSubmit(this) script.