Piston to loop through locks and lock if not locked


#1

1) Give a description of the problem
Sometimes more than on device is added to the array lock device. Also it is supposed to remove each item from the array on line 54 but a device will remain after execution.

2) What is the expected behavior?
Loop through each lock device and lock if not locked. Check if device is locked. Send sms if device failed to lock. Remove each device from the array.

3) What is happening/not happening?
(PUT YOUR INFO HERE)

**4)

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)

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


#2

I didn’t try or test your piston yet, I would suggest adding a WAIT after sending the LOCK command so that your device gets a chance to react to the command and register its status with the hub. As it is, the piston will hammer the device with the lock command.


#3

I originally had a 10 second wait in the loop and still had the problem. Do I need to increase the wait time?


#4

Not sure if this matters, but I notice that the lockDevice array is not initialized. Is it possible that it retains data between runs? If it did, iterations would exceed 3 after a few times with locks left open. Changing the definition to “device iterations = null” should prevent that.


#5

Both are set. Iterations is set to 0 in variables and lockdevice is in varibales but set to not set. Isnt that the same as null?

What I’ve noticed is that I don’t believe the device aray works like I think. When the array is empty the logs show it still thinks a device is in the aray even though I examine the count and I cant seem to get IsEmpty to work with it.

See how the log shows it still tests the array for locked even though it’s empty.

+387ms ║║Calculating (string) Failed to lock + (string) Empty device list >> (string) Failed to lock Empty device list
+392ms ║║Calculating (string) Failed to lock Empty device list + (string) at >> (string) Failed to lock Empty device list at
+397ms ║║Calculating (string) Failed to lock Empty device list at + (string) 9:36 P.M. >> (string) Failed to lock Empty device list at 9:36 P.M.

#6

I modified it a little, still untested.


#7

I’m used to other coding languages so I was kind of over complicating this. Also I was filling the device array list during execution. Now I’m just assigning the devices in the beginning when the variable is set. Below is the working piston.