Heya @nayelyz, now I remember why I did it the way I did originally (that’s why I didn’t mark you answer as a solution yet until I tested it)
If you call a method via runEveryXXMinutes() that is not refresh, it will not run the method.
Note: note that I did as the documentation says, that runEveryXXMinutes() must not call it with (), and the method must not be private. Yet even so, it’ll not run scheduledRefresh(). Also that sendHubCommand is not prepared to call a method as a string, must be called as sendHubCommand (method()). Same goes for the delayBetween, method must be called as method().
Here’s my example, using your comments:
metadata {
definition (...............) {
capability "Actuator"
capability "Configuration"
capability "Refresh"
capability "Switch"
capability "Temperature Measurement"
capability "Sensor"
capability "Power Meter"
capability "Energy Meter"
capability "Health Check"
}
fingerprint ..............
def rates = [:]
rates << ["5" : "Refresh data every 5 minutes"]
rates << ["10" : "Refresh data every 10 minutes"]
rates << ["15" : "Refresh data every 15 minutes"]
rates << ["30" : "Refresh data every 30 minutes"]
preferences {
input name: "refreshRate", type: "enum", title: "Refresh time rate", description: "Change the data poll refresh rate (default: 10)", options: rates, required: false, defaultValue: "10"
}
}
def installed() {
sendEvent(name: "checkInterval", value: 720, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
}
// updated() seems to happen for example after you save settings in the device (it also seems to happen after install)
def updated() {
log.info "Updating settings of the device"
unschedule()
switch(refreshRate) {
case "5":
runEvery5Minutes(scheduledRefresh)
log.info "Data poll refresh rate has been updated and is scheduled to run every 5 minutes"
break
case "15":
runEvery15Minutes(scheduledRefresh)
log.info "Data poll refresh rate has been updated and is scheduled to run every 15 minutes"
break
case "30":
runEvery30Minutes(scheduledRefresh)
log.info "Data poll refresh rate has been updated and is scheduled to run every 30 minutes"
break
default:
runEvery10Minutes(scheduledRefresh)
log.info "Data poll refresh rate has been updated and is scheduled to run every 10 minutes"
}
}
def ping() {
scheduledRefresh()
}
def configure() {
log.info "Configuring Reporting and Bindings, setting schedule and forcing first report"
delayBetween(zigbeeReportCommands(), 500)
}
def refresh() {
log.info "Running refresh command and requesting refresh values from device"
delayBetween(zigbeeRefreshCommands(), 500)
}
def zigbeeRefreshCommands() {
[
zigbee.onOffRefresh(),
zigbee.readAttribute(0x0002, 0x0000),
zigbee.readAttribute(0x000C, 0x0055, [destEndpoint: 0x0002]),
zigbee.readAttribute(0x000C, 0x0055, [destEndpoint: 0x0003])
]
}
def zigbeeReportCommands() {
[
zigbee.onOffConfig(),
zigbee.configureReporting(0x0002, 0x0000, 0x29, 1, 300, 0x01),
zigbee.configureReporting(0x000C, 0x0055, 0x39, 1, 300, 0x01, [destEndpoint: 0x0002]),
zigbee.configureReporting(0x000C, 0x0055, 0x39, 1, 300, 0x01, [destEndpoint: 0x0003])
]
}
def scheduledRefresh() {
log.info "Running scheduled refresh command and requesting refresh values from device"
sendHubCommand(zigbeeRefreshCommands(), 500)
}
This is why I did it the way I did before (and forgot why), the runEveryXXMinutes() will not execute in my case something that is not refresh().
I know the switch clause happens, as the log.info prints happen. but the scheduled tasks don’t when they are not a refresh().
Either I’m missing some method nuance like the way it has to be done with delayBetween(), or there something weird going on.