Adding Time Last Opened Announced By Google Into Piston


#21

Okay, is contact sensor 1 still open? Because that is also going to fire because you have a condition instead of a trigger for the first expression.

I would change the first part to Contact sensor 1 CHANGES TO OPEN.

Right now, if the Piston fires and Contact sensor 1 is still open, that part of the piston is going to execute again. I would also change the second half of the expression to CHANGES TO ON. no IS on. Because that will end up executing if it is still on when the first part does.


#22

Made those changes which doesn’t really address the time issue but the Piston appears to function the same as before.


#23

Okay. Don’t use the variable, just to test it. In your expression to issue the broadcast, put a value into it. See if that gets spoken. I can’t tell with your anonomized screenshot if you have the parameters defined correctly for GAR.

Wait…I don’t believe that you do. Why are you sending the command and the time in separate parameters? They should be grouped into the same parameter.

GAR requires your parameters be as follows:
broadcast = true
user = username_in_GAR
command = TEXT YOU WANT TO BROADCAST

If you are issuing the time in a separate parameter, then that is going to be ignored by GAR.

Yours currently has 4 parameters defined
image

That’s never going to work.


#24

Okay so how do i embed the global variable into the command, seems like everything I try doesn’t work


#25

I made a tiny piston which will (hopefully) help you to understand how variables work a bit…

pic

When Switch 1 turns on, the current day & time is stored in the variable.
(IE: 2:35 A.M. on Monday)

When Switch 1 turns off, it recites that previous time into the log below.
(this could easily be dumped into a text message, or a voice alert, etc)

When Switch 1 turns on again, a new time is stored…

Rinse and repeat.


Pro Tip:

If you are writing to a global variable, the global is NOT actually written until the very last line of code has completed. Because of this, I do not use globals for data that I need instant access to.

On the other hand, locals are written instantly. (within 10 milliseconds typically)
So local variables can be written, and then referenced on the very next line, if desired.


#26

So I ended up using a Concat in the expression and it ended up working.


#27

I’m new to this, so forgive me if some of my info is wrong. I’ve got something similar to this on my mailbox. If I walk inside, my Amazon Echo says a little message. You inspired me to add the time of day to the message. Here’s my mail notification piston:

How’d you get the Google Home to say text? I’ve been only able to have the Amazon devices do that.

At the end of 9idzx (and the other), it looks like you are comparing $hour. So if the piston gets run at 1 and/or 12 hours, that DashCount variable will be reset to 0. So at 1:00, 1:01, 1:02, etc, the variable could be reset to 0. For my mailbox script, I had a timer set for a specific time of day. If I’m understanding what you are trying to do, you might consider changing to something similar, otherwise your DashCount will be reset to 0 each time the piston is processed during the hours of 1 or 12. Are you trying to reset the fed counter at 1 or 12 (or both?)?


#28

I have a raspberry pi running nodejs and assistant relay. It allows my Google assistants to join smartthings and thus webcore to run broadcasts.