What is wrong with my Subscribe?

I have written a few Apps for devices and haven't had this much trouble! I bought a Zooz ZSE11 and just want my subscribe for motion to use the callback handler():

#include thebearmay.localFileMethods

definition(
name: "Zooz3",
namespace: "Example",
author: "Hubi",
description: "Logs Sensor States",
category: "Convenience",
iconUrl: "",
iconX2Url: "")

preferences {
section("MySensors") {
input name: "motionSensor", type: "capability.motionSensor", title: "motion", required: true
}
}

def installed() {
log.debug "installed()"
}

def updated() {
if (logEnable) log.debug "updated()"
unsubscribe()
subscribe(motion, "motion", handler)
subscribe(motion, "motionSensor", handler)
subscribe(motionSensor, "motion", handler)
subscribe(motionSensor, "motionSensor", handler)
subscribe(Motion, "Motion", handler)
subscribe(Motion, "MotionSensor", handler)
subscribe(motionSensor, "Motion", handler)
subscribe(motionSensor, "MotionSensor", handler)
}

def handler(evt) {

log.debug "Entered handler"
       
log.debug "getCurrentStates = " + evt.device.getCurrentStates()    

}

def uninstalled() {
log.debug "uninstalled()"
}

I put several subscribes in to quickly find out which one would work (I got frustrated changing the single line for my subscribe). I then ran this and noticed when I moved my hand above the sensor the Live logs view of that Device show ACTIVE (about 30 seconds later it reported INACTIVE). I then went to the tab for this App and all it showed was "2024-01-03 04:45:17.461 PM debug installed()". I used an App titled "Get Attribute App" written by "csteele-PD". It produced the following:

What technique of debugging would you suggest to figure out how to get the subscribe to function properly?
Thanks

This is the format you want, or really with "handler" per the signature, though I believe they made either work.

Did you hit "Done" so your updated() method actually runs?

Yes. I just Removed it and created it again and then hit Done and got in the logs:

2024-01-03 05:52:01.699 PMdebuginstalled()

I then looked at the log for the Device and it showed

dev:1892024-01-03 05:53:01.198 PMinfoZooz-ZSE11 motion became inactive

dev:1892024-01-03 05:52:19.802 PMinfoZooz-ZSE11 motion became active

When I went back the the App's log nothing was added?

Unless you have logDebug defined somewhere, I don't see why it would. Removing that check at least for now may help you see morw clues in Logs.

Does the App Status (gear icon) page show a subscription for this device?

I added:

section("Logging") {
    input name: "logEnable", type: "bool", title: "Enable logging?"
}

to preferences and it now works. Why would this make it work? Until I added this I did not get "updated()" in the log... only "installed()".

Because logEnable was not true, so the log.debug() was never run.

So this is the Enable/Disable for the actual App right? O'Boy!

I'm not sure what you mean. The logEnable setting is one you're (now) providing and can act accordingly in your app code. It does not do anything on its own if that is what you're asking.

Got it! My face feels pretty red. Maybe I can have the Administrator erase my post like it never happened... LOL. I appreciate the help

Hi Bertabcd1234, it looks like I had a very senior moment. I keep a template for new Apps and for some VERY interesting reason when I copied that template over for the Zooz App I mistakenly deleted the "section("Logging")" under preferences... And it apparently looks like the default would be false! Before getting your help I wasted my time for at least 30 minutes and decided to post. During our posting conversation I simply did a compare between my template and the Zooz App and it was apparent I was OLD! Why I didn't do that comparison prior to posting just did not occur to me until I got the nudge from you... THANKS. I actually enjoy debugging most times but not when I find out the solution indicates a senior moment. It definitely deflated my balloon. Thanks Again

Really null since it doesn't exist, but if (null) is false, so that is why the body (the line to log) did not run. Google "Groovy truth" if you want to find some examples that might be more surprising than this one. :slight_smile: