Unsubscribe and re subscribe not working

I’ve written an SmartApp which subscribes to a contact sensor close event using:

unsubscribe()
subscribe(settings.“sensor${lock}”, “contact.closed”, sensorHandler)

It works fine, I get all the “closed” events.

Now I changed to the code to and reinitialized the app:

subscribe(settings.“sensor${lock}”, “contact”, sensorHandler)

ST refuses to send my app any notifications for “open” events, it’s still sending me only closed events. I checked the app subscription details under installed SmartApps and it shows that it’s subscribed to all contact events but it still refuses to send any “open” events.

Anyone else facing this issue or have any idea what’s going on?

@slagle @jody.albritton

There could be something weird going on with a backend cache. I say this because I was just working in a device handler… I changed my code to have this line twice to test something out.

tileAttribute (“device.level”, key: “SECONDARY_CONTROL”) {attributeState “default”, label:’${currentValue}%’
}

So I basically got two xx%, which is what I expected.

When I removed the second instance the second xx% stayed. No idea how to get rid of it since I already removed it from the code. It is still there hours later. Even if I create a new device. Still there.

1 Like

This is ridiculous, I deleted the entire APP and reinstalled it from scratch and it STILL won’t send the App “open” notifications.

I think you’re right @whoismoses it’s caching the state of the app and not updating it somewhere.

@Tyler - any clue as to why this may be happening?

1 Like

I’ve been working on this device handler, trying to get the refresh to work properly and I can’t tell if I am doing something wrong or if ST is just not working right. Basically on iOS “pull down to refresh” the device doesn’t call any methods for my device handler. Isn’t it supposed to call refresh? I put a refresh button in and that works…

No, I’ve never seen it call refresh, that just refreshes the iOS app state.

Do you know if there is a method that is call when you go into the detailed view of a device? I am trying to get a “virtual device” that controls a bunch of other actual devices to show on / onish / off depending on the states of the devices without having to hit the refresh button.

Are you sure it’s not firing? I had a situation recently and I would have bet the farm mine wasn’t either. I commented all lines out except for one debug line and magically it was firing. But something had changed on the backend generating causing no errors, nothing. Just curious.

I can definitely say the open event is coming to ST because the Live Logging is showing the contact sensor open and closed events.

As for the custom app, I have 3 separate instances (2 brand new) of it installed and in all 3 of them I ONLY see the closed event notifications debug lines and not a single open event debug line (same line just a different value).

I can only summarize that it’s not being called. I opened and closed the door atleast 50 times and not once have I seen the open event come in any of the 3 app instances.

just lost…and frustrated

1 Like

We had/have a SmartTiles user (or 2 or 3) report that certain Events are not showing up on dashboards.

We haven’t changed anything in the SmartApp, so this would be symptoms of the same issue you describe.

1 Like

I know this is stupid, but for my problem, the only line that would execute was something dumb like log.debug(“executed”) - all other lines were commented out. Trying to print evt.value would blow up (for me the issue was on off, not open close). Adding the lines back in a little at a time, I eventually found a line that caused all other the lines to be ignored, at least acted like they were never called. This was an app that had worked for me for a year. Jusr a thought.

1 Like

Yes so 2 things:

  1. I removed the log line and replaced with a simple log.error “Handler called” and again it was only called for closed events
  2. The debug line is

log.trace “Event name $evt.name, value $evt.value, device $evt.displayName”

It is called EVERY time without fail for a closed event, NEVER once for an open event. I think it’s something more than the debug line.

Sorry. It was just a thought. My issue came down to comparing evt.value. Good luck.

2 Likes

Heck I made is even simpler, I ran the SmartApp through a simulator with a Virtual Contact, flicked it Open and nothing!!
Flicked it Close and I see the messages and actions.

Something very funky going on the platform here, it’s just eating up those Open messages specific to this SmartApp.

Just deleted it all and started over and it seems to be working now. Sigh…

I had an app the other day and that’s what worked for me too. It still bothers me how it became “corrupt”. I guess I’ll never know.