1

Is there a way to run through a function even though there is no state change?

subscribe(locks, "codeReport", codeReturn)

I'm trying to subscribe to an event, but it only enters the subscription function if there is a state change Eg:

isStateChange: false Does not get run

isStateChange: true Gets run.

ethayer
  • 55
  • 1
  • 6
  • I changed the device type code to always set isStateChange: true, but this seems like a pretty bad hack to make this work. Seems like this should be pretty common use case. What am I missing here? – ethayer Mar 18 '15 at 23:48
  • Can you post the code you are using to generate the event in the device type. – Jeff Beck Mar 19 '15 at 00:13

1 Answers1

0

The event will only be broadcasted if the state has changed, or if the event type is physical. Plus a handful of other very rare cases.

In general it would be better to set the other attributes to get the event to broadcast then change the isStateChange to always be true.

Jeff Beck
  • 3,944
  • 3
  • 28
  • 45
  • Hmm, seems like an oversight in the ST event machine. I would like to grab the event and make sure it was changed successfully and if not, request another change. I guess I'll need to write my own event into the device type to support this. was hoping to avoid having to edit the device type for my app to work. – ethayer Mar 19 '15 at 01:04
  • Which device type is this? Or can you post the the code where the event is created? – Jeff Beck Mar 19 '15 at 01:38
  • the code is [here](https://github.com/ethayer/user-lock-manager/blob/master/zwave-lock.groovy#L491) I've created a custom event using the default device type from SmartThings. This custom event actually gives me more, I think, as it includes the entire list of codes in one object. If this state object is available outside of the device type code, I could drop the requirement for a custom device type. – ethayer Mar 20 '15 at 19:42
  • Add " type: 'physical' " to the event you are creating and you can remove the state change true. – Jeff Beck Mar 20 '15 at 23:18