Is there a way to lockout other tiles while one is in "nextState" situation?

devicetype
tile
garagedooropener
garagedoor

(Justin Eltoft) #1

Hi,
I’ve created a garage door controller out of the thingShield and I’m using “nextState” to show opening or closing while I wait for the door to actually open. The only issue is that since the arduino can’t queue up the commands from the device handler, I would like to lock out the other tiles to open or close the other two doors when one of the doors is in transition. The given door in transition is locked out automatically by SmartThings by the way so that’s good. Technically I know that I could open or close two garage doors at the same time, but again since I’m delaying in the arduino code to let the door settle into it’s final state it is in a delay and won’t queue up the command from what I’ve seen.

My code for the garage door is here if you want to see it.

Justin


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

It’s a little tricky and some work (but worth the education)… My recommendation is to change your Arduino code to not block while waiting. That’s always a bad practice in this situation.

Obviously most Arduino projects are trivial, but if your project is part of a system that can receive additional messages at any time, then you should keep the message check loop or callback running as frequently as possible. You can check for another door request while “simultaneously” (the next statements in the loop) checking if enough time has passed to send an update status on the last action back to SmartThings.

TL;DR: This is a “real time system”. Blocking is bad.

P.S.: I built a multi-function Arduino + ThingShield device. I ought to check if I followed my own advice before posting this :speak_no_evil:. I’ll check & share my code if applicable.


(Justin Eltoft) #3

Thanks Terry, you’re absolutely right. I’ll go ahead and work it out on the arduino side. I was being a bit lazy here with this question. :slight_smile: