Help me fix this please


#1

1) Give a description of the problem
I want to set a two timeframes for my sensor when it may trigger.

2) What is the expected behavior?
Sensor can only trigger and turn on/off lights within a given timeframe.
ie: between 00:00 and 17:00 the kitchen lights should come on, and stay on for 3 minutes and then turn off.
and: between 17:00 and 00:00 the kitchen lights should come on and stay on for 3 minutes and then dim to 1%

3) What is happening/not happening?
With this current piston the lights turn on, i need to find out how to add that specific timetable, which should be between 17:00 and 00:00 and i need to know how to add a second condition+ timeframe.

**4) Post a Green Snapshot of the piston!
piston


#2

fixed this myself :slight_smile:


#3

Feel free to share your working piston with us… It may help someone else


#4

alright. Im almost there, when i finish this, i will make a post/how-to on the matter.
First i need to tackle one more inconvenient behaviour. Maybe you can help me. For some reason the lights that are activated in this piston wont turn off after inactivity of the sensor.


#5

This will cover both options with one nested IF statement. You’ll have one behavior between midnight and 5pm in this one, and another behavior between 5pm and midnight.

Notice the “N” next to the WITH statements. That’s because I clicked on the gear cog at the bottom of the dialog box for the WITH statement and changed the Task Cancellation Policy to “Never Cancel Tasks”. More on that here:


#6

thanks alot! im going to try this right now! thanks again


#7

All is working very well! thanks again.Was wondering, would it be possible to pause this piston automatically when i press a button that overrides the light, for instance; when i want to cook and its before sunset i press a button and the lights come on, and stay on, at the same time the piston gets paused. When i press that same button again the piston gets resumed and the sensor is active again(?)


#8

You would need a separate piston for that:

If Button pushed then
Turn on lights
Pause other piston
End
If Button pushed second time
Turn off lights
Resume piston
End

Something like thst


#9

Glad to help!

Rather than pausing the piston, you might just want to have a variable in your current one.

Define variable motionLights (boolean)

If button pressed
THEN
If motionLights is True
Set motionLights False
Else set True

Add a restriction to your section that monitors IF “motion sensor changes” so it’s
Only When motionLights is True
IF
Motion sensor changes to active
THEN
control lights and timer as you do now

To add a restriction, you might need to go to the upper right corner when you’re editing your piston, then click the “show restrictions” option.


#10

Bit late, but thanks for your reply. Im trying to work out your advise but cant really get it to work due to limited knowledge and experience. Could you make a screenshot maybe? (buy you a beer)

greetings


#11

No problem!

This should get you started. I don’t have a motion sensor so change the $device variable to your motion sensor in line 35. Everything from your original piston should plug-in below line 35, too.

Any questions, let me know!


#12

Thanks for sure for helping me again, youre a king, forgive me for not replying sooner.
Right now, trying to copy my orginical piston into your concept, but cant get that to work yet.
will check in back here.


#13

No worries, if you’re getting stuck somewhere, post up a copy of your piston and I’ll help you get the two merged.


#14

Morning,

Im not getting any further because some lines i need to be ‘when’ instead of ‘if/then’, beneath is the code that im trying to merge into your concept. The second screenshot is how far i got until now.



#15

Something like this? If not - can you describe what you want your piston to do in plain English and I’ll modify as needed?


#16

let me look at that. I want the sensor/piston of the sensor to disable when i press the button that manually turns on the lights to 100% when im cooking. When i press the button for the second time, to turn off the lights i want the sensor/piston to reactivate again working as usual. Hope ive been clear :slight_smile: once again, thanks for all the support!


#17

Ok, got it. The enable/disable bit of the piston is the IF condition starting at line 21. If (dimmer 14) button is pushed, the motion lights are disabled. When it’s pushed again, the motion lights are enabled once again.

Without knowing what kind of swtiches you’re using and your device type handler, I am not certain you can actually use the light switches themselves as a means to enable or disable motion. That’s because when you switch them on manually, the switches report to ST/WC that they were just switched on. But they do the same thing when they switch on through a program… so there’s no distinguishing between the two.

Some switches (GE for example) have a “double-tap” feature where you can click up or down twice in rapid succession. The double-tap sends a different message to ST/WC… rather than saying “I was switched on” it says “button #1 or #2” was pressed. You can use this to drive different actions… like in the example piston I posted.


#18

It’s all good, using your code and it works like a charm! Happy with this! Thanks again mate! :beers: