Need help with combining two pistons into one


#1

1) Give a description of the problem
If I turn on two rooms the speak command is repeated twice as I have one piston for each room. I would like to combine the two Pistons so that if both rooms are turned on by a routine only one random line of text is spoken. Also if only one room is turned on the text is spoke once which it does now.

2) What is the expected behavior?
When both rooms are turned on the spoken line will only be spoken once Unless only one room or the other is on.

3) What is happening/not happening?
If I turn on both rooms at the same time the random text is spoken twice

4) Post a Green Snapshot of the pistonimage

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


#2

Just so I understand, do you only consider the room to be ‘on’ if both dimmers are on? I think you want to create a piston that watches for any of the dimmers to change to on and then use logic to determine if one room is on or both are on. Similar to this logic but the first if will have all four dimmers and then you will need to use if-then-else internally to get the desired result (room 1 on, room 2 on or both on).


#3

I usually turn on just one room at a time and then there isn’t a problem, especially if your Piston works eliminating the strange speaking when not asked. Now on some days I have both rooms on, and the speakers play more than one message. So that’s what I need to prevent. If one room is turned on play one message if both rooms are turned on play another. Now turning off I can duplicate the piston and use off, but the same conditions exist. Does that make any sense?


#4

Yes, that makes good sense. I was just wondering if you really wanted to require both dimmers to be on to say the room was on. You might want to use ‘or’ instead of ‘and’ for the turn on. For turn off, you would want the ‘and’ as you would want everything off.


#5

That is why I asked for help, as I usually have both lights on in each room. And the logic sometimes eludes me,.


#6

OK. Hope my solution works for you.


#7

Thank you, I think it will work out, I am also hoping it stops the speaking when it shouldn’t speak.


#8

Please let me know if this worked for you. Also, if it did mark my message above as your solution. Thanks.


#9

I think it eliminated the speaking without asking it to speak, but I tried and tried to use your piston and combine the two rooms for on and off and just failed drastically.


#10

This will do what you want in one piston, and has a 60 minute lockout in it to prevent repeated greetings. You can adjust the lockout on it to anything you want on line 30.

Any questions or tweaks needed that you need help with, just let me know!


#11

OK now a question will this give me the announcement when either is turned on then off and on again? As I would like it to speak anytime it is turned on. I also use the random command for speak as the other Piston above has. Where in your piston would I add the same rooms for off?


#12

I think what you need to do from what I provided is just add your other two dimmers to the first if:

  Any of Dimmer 14's, Dimmer 2's, Dimmer 3,s or Dimmer 8's switch changes to off

and then duplicate the if inside the then for the second room so you will have

    if
      Dimmer 14's switch is off
        and
      Dimmer 2's switch is off
        and 
      Time is between 8:45 am and 11:29 PM
   then
     speak
     exit
   endif
   if
      Dimmer 3's switch is off
        and
      Dimmer 8's switch is off
        and 
      Time is between 8:45 am and 11:29 PM
   then
     speak
   endif

I don’t have enough devices to implement it myself but this should work if you follow my logic. The ‘exit’ will keep the piston from speak for both rooms at the same time. I like michicago’s 60 minute lockout. Is that what you want or do you always want it to speak when the lights go out? I’m not sure if his logic will completely work since there is a mix of a time trigger and switch conditions. I read earlier when you mix the two it will only look at the trigger.


#13

Only if it is turned on 60 minutes after. There’s a ‘lockout’ to prevent repeat messages. You can change it to any duration you want (10 seconds, 30 minutes, 2 days… anything) by modifying line 30 in the green snapshot of the piston.


#14

I see the logic, but I think this is way too much for me to handle. I will just stick to duplication the pistons for on and off. Thanks for the help.

I understand. Thanks. I will try it.


#15

This is what I have now, but the rest I am lost.


#16

Just so I understand. I think in one of you other threads you were wanting to speak something when the rooms turned off. This looks like you want something when they turn on. For turn on, do all the lights need to be on or just any one? Once I understand your goal, maybe we can lay out the whole thing. Maybe you want something said if you turn the light on and something different if all the lights go out?

If I understand correctly, if only one, two, three or all four lights come on at the same time, you always want only one message. If all the lights go out in one room or both rooms at the same time you want a single message. If the lights go out in one room and then 5 minutes later the lights go out in the other room, do you then want to hear two messages? Similarly for turning on? In either room, do the lights always go on/off together? Finally, do you want to trigger when the first light comes on in a room and when the last one goes off if they do not turn operate together?


#17

Here is what I want: There are two room, living room and family room. Each room has the following.
Each room has two lights. Here is what I want to do. If one or two lights in one room come on I want that random message, if one or tow in both rooms come on I want the same message. Now I want the same thing to happen for off command but a different message. The message only plays during those times I had above. Does that make it any clearer? I also need it to play only one of the messages, my original piston, not the one you made played both random messages.

What is happening now if I turn on both rooms using a routine the echo speaks two sentences instead of one. Thanks for the help.

Below is what I wrote, but it doesn’t speak as I want. When lights come on there is no text spoken, but when turned off there is.


#18

The only thing that’s not clear is how long you want between switching rooms on or off before the message is repeated. If they’re switched on 15 seconds apart, do you want the message to repeat? Or a minute? Or something else entirely?


#19

A few minutes is fine, but as it is now when I turn either room on I get no voice. But off I get a voice.


#20

Ok, and do you want to hear the message when either light in the room is turned on or only when both of them are on?