You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am sorry if this is not the correct use of Issues. I have seen other drivers in Hubitat clear the unused attributes periodically. I think your app can do the same thing but i am not familiar enough with Groovy to confidently update anything. I think something like this could work but will defer to you.
// Method to clear and remove optional attributes from "Current States"
// This ensures that unused attributes do not clutter the dashboard or remain visible when settingEnable is turned off.
def clearOptionalAttributes(attributeList) {
attributeList.each { attributeName ->
// Set the attribute value to null to indicate it's no longer active
sendEvent(name: attributeName, value: null, displayed: false)
// Remove the attribute from the device's current state if it exists
if (device.hasAttribute(attributeName)) {
device.removeCurrentState(attributeName)
}
}
// Log the cleared attributes for debugging and confirmation
log.info "Cleared optional attributes: ${attributeList.join(', ')}"
}
// Method that runs whenever preferences are updated (e.g., toggling settingEnable)
// This handles cleanup of optional attributes and reinitializes active ones.
def updated() {
// Log that preferences have been updated to track when this method runs
log.info "Preferences updated. Checking optional attributes..."
// If the toggle for displaying all optional attributes is turned OFF
if (!settingEnable) {
// Retrieve the list of all optional attributes from the attributesMap keys
def optionalAttributes = attributesMap.keySet().toList()
// Clear all optional attributes to ensure they are no longer visible or active
clearOptionalAttributes(optionalAttributes)
}
// Reinitialize active attributes (if any) based on current preferences
// This is optional but useful for restoring visible attributes when toggling settingEnable ON
initializeAttributes()
}
// Example method to initialize optional attributes when settingEnable is ON
// This ensures that attributes are re-added with default or placeholder values as needed.
def initializeAttributes() {
// Only proceed if settingEnable is ON
if (settingEnable) {
// Iterate through all attributes in attributesMap
attributesMap.each { keyname, attribute ->
// Example initialization: Send a placeholder value for each attribute
// Replace "Example Value" with actual logic for populating the attribute
sendEvent(name: keyname, value: "Example Value")
}
}
}
The text was updated successfully, but these errors were encountered:
I am sorry if this is not the correct use of Issues. I have seen other drivers in Hubitat clear the unused attributes periodically. I think your app can do the same thing but i am not familiar enough with Groovy to confidently update anything. I think something like this could work but will defer to you.
// Method to clear and remove optional attributes from "Current States"
// This ensures that unused attributes do not clutter the dashboard or remain visible when settingEnable is turned off.
def clearOptionalAttributes(attributeList) {
attributeList.each { attributeName ->
// Set the attribute value to null to indicate it's no longer active
sendEvent(name: attributeName, value: null, displayed: false)
}
// Method that runs whenever preferences are updated (e.g., toggling settingEnable)
// This handles cleanup of optional attributes and reinitializes active ones.
def updated() {
// Log that preferences have been updated to track when this method runs
log.info "Preferences updated. Checking optional attributes..."
}
// Example method to initialize optional attributes when settingEnable is ON
// This ensures that attributes are re-added with default or placeholder values as needed.
def initializeAttributes() {
// Only proceed if settingEnable is ON
if (settingEnable) {
// Iterate through all attributes in attributesMap
attributesMap.each { keyname, attribute ->
// Example initialization: Send a placeholder value for each attribute
// Replace "Example Value" with actual logic for populating the attribute
sendEvent(name: keyname, value: "Example Value")
}
}
}
The text was updated successfully, but these errors were encountered: