Learned Something I don't Understand

I have some apps that I created myself. One of them that controlled some lighting had been working fine. I modified it and then it didn't work. I discovered the problem, but don't understand how it worked before as the code was wrong. Here is what I did.

I had several subscriptions, this is an example of one of them.
subscribe(frontDoor, "contact", porchDetectHandler) This works correctly.

Previously I had, by accident this:
subscribe(contact, "frontDoor", porchDetectHandler) This worked correctly before but not after I made some changes.

Just wondering why it worked before even tho it was wrong.

No idea, but I guess the only explanation is that enough of what you wrote matched one of the (other) signatures for this method and created the subscription as expected. :slight_smile: I don't see any current signatures that look promising, but it's possible there is more than what is documented. There also appear to have been some changes in 2.2.1, but that was a while back; still, any subscriptions you had already created (i.e., if you didn't go in and edit the installed app and save your changes--assuming you create these subscriptions as a result of updated() and whatnot) wouldn't have been affected since they were already in place.

In related news, the handlerMethod parameter here is specified as a String in some parts of the docs, so you might want "porchDetectHandler", but not all variations of this signature specify String (the others have none), and they even went so far as to fix a bug/cache issue recently related to unsubscribing when not using a String, so apparently they don't really consider it wrong, but...just another thing to note, I guess. Ha.