Button set up as a reset pendant


#1

1) Give a description of the problem
I own a senior care home that is currently using smartthings as a secondary alert system.
Each resident has a smart pendant that is a single press button that turns on a switch to call a nurse for help.
The nurses have buttons as well to reset the switches.

I need to find out how to write a code that uses a “while” type logic.

2) What is the expected behaviour?
I want the nurses pendants to basically be reset buttons that only reset the switch if pressed almost simultaneously with the patients pendant.

I think the logic should read:
if button1 is pressed, turn on switch 1

If button 1 is pressed a timer is started for 3seconds
WHILE the timer is running, if button 7 is pressed, then turn off switch1
else, leave switch1 on.

3) What is happening/not happening?
I have everything figured out except the timer portion. not too sure how that will work.
I know about a Wait action, but i want that wait period to be listening for a button push.

**4) Post a Green Snapshot of the piston!
I don’t have a green snapshot just yet… The whole difficult part for me is the timer portion. not even too sure how to tackle that.
As mentioned, i could throw in a wait action, but i also want to ensure listening to reset pendant presses during the wait.


#2

I don’t have any freetime today, but anything you subscribe to will run thru the code (top to bottom) at each and every event.

Also, 400ms sounds like it is doomed for failure. I would not go less than 10 seconds, although 20 seconds sounds more reliable.


#3

awesome! yeah, i can change that timing, But do you think if i just used a wait command, the piston will listen while waiting? or would it wait for the specified amount of time and then listen for the secondary button press?. Because if it waits first, then the reset pendant push could be mistakenly used for someone else’s button push.

I am ultimately trying to simulate a simultaneous button press with room for human error.
The nurse would need to repress the patient pendant and hers right afterwards to turn the switch off.

Does that make sense? or did i just jumble up everything?


#4

Untested, but I would start with something like this:

define
   boolean {timer} = (not set)
end define

execute
   IF Button 1 is pressed   <-- Trigger
   Then with Switch 1   (TCP set to Never)
      Set variable {timer} = true
      Turn on
      Wait 12 seconds
      Set variable {timer} = false
   END IF

   IF Button 7 is pressed   <-- Trigger
      and
      {timer} is true
      Then
         Turn off Switch 1
   END IF
end execute

Each trigger will run thru the code top to bottom, but button 7 will only do something during the 12 seconds that the variable is true.


#5

this is exactly what i was looking for so i duplicated it in webcore.
I will try to tinker around with it a bit more, but i feel like its almost there!!

I fear that the code ran top to bottom and waited for those 10 seconds with the variable “TRUE” before listening to button 7’s press which did nothing because timer was already false by then :frowning:

Here is a green snapshot of what that might look like:


#6

Yes. The second IF should not be inside the first IF.
It should begin after the first END IF, as seen here.

Also, the WITH on line 24 should have Task Cancellation Policy set to Never.


If you need to troubleshoot this, please turn logging to Full


#7

That absolutely worked! never thought of assigning a boolean (True or False) to a wait timer like that to essentially create a listening timer. ingenious!

Thank you for your speedy reply. Here is a copy of the completed logic so you know how everything worked.

Since i’ll have 3 reset buttons, ill change that code to "If ANY of these buttons gets pushed while Timer variable = true, then shut off switch1

and, ill also have to run this code for each patient button, so i assume i have to either create a piston for each button, or line by line add each button to this piston to begin a timer for each button on press. Thats alot of variables! haha! but regardless! thanks so much for your help!


#8

Be careful with this. When too many pistons execute at the same instant, some commands are sure to get lost in all the commotion… In a perfect world, one event (trigger) should only execute one piston. It may not always be possible, but it is always my goal when programming anyone’s SmartHome.


Personally, I try to avoid having multiple timers running simultaneously from the same piston…
(Especially when health or safety is at stake)


Since these alerts you are seeking could literally be the matter of life and death, reliability is paramount!

I would probably put a dedicated button in each room that the nurse can reach, but out of reach from the bed. (perhaps high on the wall over the bed?) With a dedicated button, each press only triggers one piston. You can remove:

  • All WAITS
  • All double, triple, quadruple triggers
  • 90% of all logic

This will increase your reliability tenfold…

Just my two cents.


#9

The good news is, variables will not be the problem here…

I have many pistons with over 50 variables programmed… and a few pistons with over 150 variables… All working like a champ…


#10

Sorry, yes… This is preferred.
(I missed that earlier)


#11

Yes, we have already installed this functionality with wall buttons over the bed and use it to ensure each patient is being checked on every 30 minutes signified by a button press. If the button isnt pushed every 30minutes, an AC powered siren/strobe light goes off as well as an ifttt call to community and one to alert management.

The resident pendant buttons have already been working for about 6 months now with ease. The buttons we were using have a hold feature, but the newer buttons are unfortunately only a single press, which calls for another way to shut off the help switch.
Hence my reaching out to code a dedicated reset button.
This reset button project is just to give each patient a way to call a nurse while they are out and about around the community.

I just want you to know though, that you may have single handedly added value to about 35 seniors feeling of security outside of their normal support given!

Now we can get on with the show! haha!


#12

I might also consider making that same button press issue an additional command to reset the switch mentioned in this thread. Basically, adding that reset command to a trigger that is already in place. (happening whenever a nurse checks on someone)

The extra beauty of this method is each wall button press will only trigger a single piston, and only reset the switch for that one room.

To me, this would be the best of both worlds. Clean, efficient & reliable.


#13

Oh wow!! thats a great idea!!!
So, just so i understand what you mean correctly,
If patient button 1 is pressed, the nurse can either use the reset button 1 that you just helped me get working OR the wall button above the bed as an acknowledgement and reset of the switch.


#14

Well, technically the reset can come from both pistons… but I was actually suggesting keeping it simple, by adding the reset command to the current wall piston.
(and deleting or pausing the piston talked about here)

The less things happening simultaneously, the more reliable SmartThings becomes…