This object is in archive! 

Best way to create rule for Office Light

Robert Hercz shared this question 8 years ago
Need Answer

Hi guys,

I have installed a DoorSensor and a Fibaro Motion Detector in the office.

I wish to turn the lights on (switch on) whenever the door sensor is activated, and the to switch the lights off 20 minutes after the last detected movement or door activity.

I also want the system to send me a push message light is turned on (from off position), and when the light is turned off.

What's the best way to achieve this using the rules creator?

Best regards,

Robert

Replies (6)

photo
1

Hey robert, I think the easiest way is to create a variable that is changed according to movement or door opening/closing. I used something like this to determine if their is anyone home and to activate the alarm after 30 minutes if not. This way you can add more sensors later if needed.


For the light, you will need to use a single relay with an 2nd input, such as Zipato single module. This input is what you need to connect to the switch and use the rules to trigger on this. Otherwise the rule will always activate when the light turns on, whether by the switch manually, or virtually via the app or a rule, because everything will come through as via the main input on the module.

photo
1

Thats a way to do it, if you want to do more stuff later on as you Adrian mention. But if your new to the system and are having problems solving this yourself then this might be a eazier way to accomplish the same result in one rule,

photo
photo
1

Adrian,


I thought about adding rules just like you mention, i.e. testing for changes to a variable which is being set when devices trigger. I do, however, get error message "When Clause has no Event Dependency" when trying to save "When variable IsMovement = 1"...


Is this a "warning" rather than an error, and the code will actually run and trigger whenever there is a change to the variable?


Best regards,

Robert

photo
1

Adrian,


Enclosed is a screen dump showing the rules I'm trying to create. As you can see, the WHEN-rules which test on a variable are rejected by the compiler.


Brgds,

Robert

photo
1

Hi Robert, None of your rules have an event dependency on movement=1, they are all >0.

I can see rule 7 will not work because you are trying to set a variable to -1, try just the number 1. I had this issue, just pick a number.

And another rule 6 is triggered by the variable of less than 0. Variables can not be negative.


What is the debugmode variable?

With everything you have here, the movement variable will never be greater than 0, so no rules will run.

photo
1

Adrian


(The DebugMode variable is a setting so I can enable/disable spam messages when developing; I've removed them from the enclosed pic for clearity).


I have cleaned up the example which will not compile and also enclosed the error message.


How did you manage to compile/save/load WHEN blocks which test on a boolean variable ?


Brgds

Robert

photo
1

ooppps, my bad. Sorry, doing to many things and not thinking correctly. You are right, you can not activate a rule on a variable change in state with Zipato. This should be a virtual meter, not a variable. Works the same, just use value 1.

photo
photo
1

Adrian,

If I have understood things correctly, the virtual devices rely on web services or similar running at Zipato's hosting partner, where an HTTP request is sent from the Zipabox whenever somethings change, and where the web service update the virtual meter.

If this is correct, anything relying on a virtual meter/device will have a slight delay in execution, and will fail completely if the Zipabox is offline...?

Leave a Comment
 
Attach a file