codahq
January 19, 2020, 5:30am
21
Any chance that could change? Or is it more complicated than it seems to provide? I think the reason for the ask is at least valid, right?
It would allow a device driver to handle multiple device models potentially without messing up how they are viewed on dashboard. My biggest use case is a motion sensor that can have a battery or can be plugged in or a motion sensor driver that covers many motion sensors, some of which don't support batteries.
JohnRob
January 19, 2020, 5:39am
22
Mike,
I performed this test:
My Inovelli had a State Variable: " oldLabel: Garage Flood "
I added the highlighted code to your "Basic Z-Wave Tool" (see below)
Replaced my Inovelli NZW31 with the Basic Z-Wave Tool
All the state variables could be seen with the Basic Tool as the driver
l asked for a Parameter Report
Results:
The "oldLabel: Garage Flood" was no longer shown.
I reverted back to the Inovelli Driver and the removed State variable did not reappear.
Perhaps the driver did not try to recreate the "oldLabel:" as I did not try to change the Label.
Was what I did just suppressing the display?
John
codahq
January 19, 2020, 5:45am
23
No, I've muddied the water a little. There are two places referred to as state in drivers:
state (which this post was originally about and you've shown
device.getCurrentStates() which is what I've introduced and stores attributes
Removing anything from state works. Removing attributes is what doesn't.
JohnRob
January 19, 2020, 3:06pm
24
That's OK. From my standpoint the state.variables (correct term?) is all I care about. Sometime back I switched from one driver to another. The old driver left a bunch of state.variables on the device page which annoyed me (I think it's a personality disorder ) . I was able to remove them using the above method.
Hence my original question: Is it possible to create an driver like the "Basic Z-Wave Tool" to wipe out the current state values for the reason I stated above?
Thanks for the explanation on the two "state" types.
John
It is more complicated than that.
We have discussed dynamic device capabilities, however it's not something we expect to entertain.
codahq
January 19, 2020, 6:27pm
27
I don't think I'm asking for fully dynamic capabilities though it would be nice. I want to remove an attribute value which I guess means I want to delete the event.
Do you still have a copy of this?
csteele
December 8, 2022, 2:32pm
29
Probably but it's incorporated into the Device driver.
Temporarily change your device to use the Device driver, click Save Device and then you get:
Click the Delete buttons, then swap back to your actual driver and it's all good.
8 Likes
it would appear that simply calling currentState.remove() removes all current states / (attributes) and then they will repopulate as and when they are sent as new events... enjoy
1 Like
tomw
January 4, 2023, 3:00am
31
Baz2473:
currentState.remove()
Can you share a code snippet that uses this? I get a missing method exception.
One from my stash that has similar capability
Code
/*
*/
static String version() { return '0.0.0' }
definition (
name: "Quick and Dirty",
namespace: "thebearmay",
author: "Jean P. May, Jr.",
description: "Allow killing of current states",
category: "Utility",
importUrl: "https://raw.githubusercontent.com/thebearmay/hubitat/main/apps/xxxxx.groovy",
installOnOpen: true,
oauth: false,
iconUrl: "",
iconX2Url: ""
)
preferences {
page name: "mainPage"
page name: "deviceCharacteristics"
page name: "dumper"
page name: "Tesla"
}
def installed() {
// log.trace "installed()"
state?.isInstalled = true
initialize()
}
def updated(){
// log.trace "updated()"
if(!state?.isInstalled) { state?.isInstalled = true }
if(debugEnable) runIn(1800,logsOff)
}
def initialize(){
}
void logsOff(){
app.updateSetting("debugEnable",[value:"false",type:"bool"])
}
def mainPage(){
dynamicPage (name: "mainPage", title: "", install: true, uninstall: true) {
if (app.getInstallationState() == 'COMPLETE') {
section("Main")
{
input "qryDevice", "capability.*", title: "Devices of Interest:", multiple: false, required: true, submitOnChange: true
if (qryDevice != null) {
input "stateStr", "string", title:"Current State to Remove", submitOnChange: true
if (stateStr != null)
input "removeState", "button", title: "Remove"
}
input "debugEnabled", "bool", title: "Debug?"
if(state?.btnPush) {
qryDevice.deleteCurrentState("$stateStr")
state.btnPush = false
}
}
} else {
section("") {
paragraph title: "Click Done", "Please click Done to install app before continuing"
}
}
}
}
def appButtonHandler(btn) {
switch(btn) {
case "removeState":
state.btnPush = true
break
default:
log.error "Undefined button $btn pushed"
break
}
}
1 Like
tomw
January 4, 2023, 3:24am
33
thebearmay:
similar capability
Thank you, but I am hoping to remove Event history, not State variables.
@Baz2473 used some terms (attributes, events, etc) that lead me to believe he found a method to do that.
Baz2473
January 4, 2023, 10:58am
34
Currently on my mobile so hereβs the best I can do for you.
Create the command so a new button appears in the driver.
Use that button to call the function.
I have 2.
deleteAllStates = deletes all stored states and atomicStates
&
delectAllCurrentStates = deletes all current states in the event / attribute side. They will then repopulate as and when they get sent again.
A few screenshots for ya.
2 Likes