Help with $device, $CurrentEventDevice


#1

I am trying to get a notification if 1) a particular door is opened, and 2) if any of the doors is open in the evening.

  1. works fine.
  2. does not. Instead of the name of the door, it just returns the name of my hub. if $CurrentEventDevice is not the right variable, what should I be using? I tried $device before and I that didn’t work either, i think.


#2

I’d do ‘save matching devices’ to variable, then send that variable in the notification.

image


#3

1 is correct, $currentEventDevice references the device that triggered the piston
2 should use $device but the for each is a loop where it pulls one device at a time so the if block should only reference $device, not ‘any of’ (though you will probably have to write as an expression)
image


#4

When a device event occurs, $currentEventDevice is the name of that device e.g. Contact Sensor 1, and you’ll also see $currentEventAttribute (e.g. contact) and $currentEventValue (e.g. open).

The Any of {Doors}'s contact changes to open trigger condition can only ever be true if the $currentEventDevice has just opened and the event is being processed, so $currentEventDevice does the job nicely. There is no point in doing something like saving the matching devices in this case as there can only be one.

The timer block (every) is run by a timer event rather than a device event. The $currentEvent ... variables are still populated but their names are no longer descriptive. The $currentEventDevice will probably be your SmartThings location, with the others being something like timer (I can’t remember offhand) and a timestamp.

You’ve been offered a couple of options by @eibyer and @fieldsjm. Instead of looping, you could just have an Any of {Doors}'s contact is open condition and save matching devices to a variable which you can use in the notification, or alternatively you can stick with what you have and $device really ought to work. Depends if you want one notification with all the open doors, or multiple notifications with one each.


#5

Thanks! This looks good, I am trying this option.