Notification of arriving and leaving work for various people


#1

1) Give a description of the problem
I would like to have a push notification when a presence sensor arrives or departs from a WC location. Since I have ST and WC presence sensors, they are named funny and I would like to have the actual name on the notification. IE: presence sensors are named Jane-WC and Tom-WC but I would like the notification to say Jane has left location or Tom has left location.

3) What is happening/not happening?
I am not sure if this piston will actually work as it is right now. But I need some help also with defining the names to be normal.

**4) Post a Green Snapshot of the piston![image|45x37]

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

You can simply change the names in your ST app…
But for any reason if you don’t want that,
you can write this piston with two seperate IF blocks instead of “any presence sensor”

I haven’t tested but if I’m not mistaken, currently, your Pnames variable will write Jane,Tom in both cases because you are not recording anything into the variable inside the piston.

Try this: (just a draft)
IF Presense sensor location changes to any of “TOM’s work, Trudence,Mid-Usa”
Then
Save matching devices
Send PUSH notification "Tom has left {location} at {time}


#3

If there are common characters in the sensor names, you can just use the replace() function.

replace($currentEventDevice,"-WC","")

In your example above, it will drop all -WC from the sensor names and give you Tom or Jane.


#4

This seems like an easier way to do it if I change the names to all have -WC. Where do I put the replace function?


#5

You can put that in your notification or logging, use an Expression box and substitute that anywhere you use $currentEventDevice


#6

So like this?
replace($currentEventDevice,"-WC","") " has made it to " [$currentEventDevice : currentPlace] " at " $time"."


#7

Yup


#8

Thanks! This worked!