Stairs Baby Gate Announcements


#1

I am getting my feet wet with webCore and loving it. One of my uses is announcements for doors and our baby gate. Our son is lovingly dubbed “T Rex” and the piston below is to alert us to his movements at the top of the stairs.

My questions are:

  1. Should I have a local variable equal to a global variable for mere readability/update-ability of the code? I am somewhat torn between doing so and trying to trim things down as much as possible. In my mind this makes the code cleaner and easier to update but there must be a resource cost. Is it negligible?

  2. I have an architecture issue with my code… If the sensor has an acceleration event while the gate is open, which I’d like to ignore, I am getting the status unknown message. To address that I blank out the Message variable in the instance I am posting (not tested) but there has to be a better way that doesn’t complicate things with more IFs. The architecture of this code is a subset of what I use for my Door Announcements that I will post in another thread due to some “Cancelling” issues I am having. The reason for the IFs to set the message and then separately playing the message is due to the door piston having 6 possible statuses… not much reason for it here but I would like to reuse code if possible.

Just a note - the Volume variable is used in “Speak Text”. I am using Speak Text with restore (not sure that restore does) as the regular Speak Text quit speaking after a few tests. The restore variant works more reliably.


#2

New users can only post one image… oh well, here is the second image needed to read the piston above.

image


#3
  1. the cost is relatively small depending on how many global variables are copied.

  2. without another if, there is not really a way to simplify further. but if you are ok with another if - 1) at line 20 set message to ‘’, delete line 48 and only play the message if its not empty.


#4

I believe the picton showed below integrates your feedback. I will have to test it later…

For the IF checking whether message is empty, it shows:

{Message} is not

It would seem to me that after the is not it should show “” or something to indicate empty. Did I do it incorrectly or is this an improvement we can suggest to @ady624 ?

I have not done formal testing but it does not seem like the volume change is actually working.


#5
  1. in the define section you need to set Message to ‘’.
  2. delete line 51
  3. change line 59 to if isEmpty(message) is false