Hi all,
This sensor is my first foray into the IoT world using Mysensors & arduino! I may be being completely dim, but essentially I would like the following to happen:
When I walk past the PIR the ceiling light should switch on. If the ceiling light is already on and I walk past, it should switch off. So far I have the following:
But it doesn't seem to want to play ball. The only thing I can think of is that it may get stuck in a loop after that because the PIR would still be on?
Any help would be appreciated!
Switching Lights on/off with PIR if already on
Moderator: leecollings
-
- Posts: 135
- Joined: Friday 02 January 2015 9:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands
- Contact:
Re: Switching Lights on/off with PIR if already on
Although it's an odd situation you want to accomplish... You'll have to add a state for every device, so you'll get something like:
Only I think this won't work as you planned because when the first condition is met (and a sensor usually stays on for a certain amount of time after detecting motion) the second condition is true which will turn the ceiling off again. This means the first condition is met again so it'll turn the ceiling back on again etc....
You 'll have to add a variable for instance for this to work properly so you'll get something like this:
* set this time a bit longer than the sensor stays on after detecting motion
quick'ndirty
You could also use a dummy switch with an off delay set to a bit longer than the sensor stays on
Code: Select all
If [Security sensor = On] and [ceiling = Off]
Do [Set ceiling = On]
Else if [Security sensor = On] and [ceiling = On]
Do [Set ceiling = Off]
You 'll have to add a variable for instance for this to work properly so you'll get something like this:
Code: Select all
If [Security sensor = On] and [ceiling = Off] and [var ceiling = 0]
Do [Set ceiling = On]
Do [Set var ceiling = 1]
Do [Set var ceiling = 2 after 10* seconds]
Else if [Security sensor = On] and [ceiling = On] and [var ceiling = 2]
Do [Set ceiling = Off]
Do [Set var ceiling = 3]
Do [Set var ceiling = 0 after 10* seconds]
quick'ndirty
You could also use a dummy switch with an off delay set to a bit longer than the sensor stays on
Re: Switching Lights on/off with PIR if already on
Thanks for the reply! I've tried popping that in but I get the error
Do I need to be defining local variables or something else? I've looked at other examples and can't see anything wrong! I changed the name of 'security sensor' just in case it was the space that was confusing it but no joy with that either...
The exact script I now have is
Code: Select all
2017-02-22 22:40:39.646 Error: EventSystem: in ce: [string "If [pir = On] and [ceiling = Off] and [var ce..."]:1: ']' expected near '='
The exact script I now have is
Code: Select all
If [pir = On] and [ceiling = Off] and [var ceiling = 0]
Do [Set ceiling = On]
Do [Set var ceiling = 1]
Do [Set var ceiling = 2 after 10 seconds]
Else if [pir = On] and [ceiling = On] and [var ceiling = 2]
Do [Set ceiling = Off]
Do [Set var ceiling = 3]
Do [Set var ceiling = 0 after 10 seconds]
end
-
- Posts: 121
- Joined: Sunday 11 October 2015 8:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3.6224
- Location: Holland
- Contact:
Re: Switching Lights on/off with PIR if already on
not
but
Code: Select all
"If [pir = On] and [ceiling = Off]
Code: Select all
"If [pir == On] and [ceiling == Off]
RPI-2 + SSD / ESPEasy Sensors & Switches / Sonoff / RFLink / Action Switches / TP-Link switch / Node-Red / Reacticz
-
- Posts: 135
- Joined: Friday 02 January 2015 9:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands
- Contact:
Re: Switching Lights on/off with PIR if already on
you aren't adding this as lua are you?kcp601 wrote:Thanks for the reply! I've tried popping that in but I get the error
Do I need to be defining local variables or something else? I've looked at other examples and can't see anything wrong! I changed the name of 'security sensor' just in case it was the space that was confusing it but no joy with that either...Code: Select all
2017-02-22 22:40:39.646 Error: EventSystem: in ce: [string "If [pir = On] and [ceiling = Off] and [var ce..."]:1: ']' expected near '='
The exact script I now have is
Code: Select all
If [pir = On] and [ceiling = Off] and [var ceiling = 0] Do [Set ceiling = On] Do [Set var ceiling = 1] Do [Set var ceiling = 2 after 10 seconds] Else if [pir = On] and [ceiling = On] and [var ceiling = 2] Do [Set ceiling = Off] Do [Set var ceiling = 3] Do [Set var ceiling = 0 after 10 seconds] end
I made a blockly in text :p
please add a screenshot of what you made
Re: Switching Lights on/off with PIR if already on
Ahhh, that was the problem! I now have the below, which I think is right? Not had a chance to test it yet. The idea was that when I walked into the room, the light would turn on and when I walked out, if it was already on it would turn off. What I didn't take into account though, is if someone else walks in to the room whilst I'm also in the room! May have to look at an addition one in the room that detects if I'm moving around in the room. Thanks for all your help!
-
- Posts: 135
- Joined: Friday 02 January 2015 9:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands
- Contact:
Re: Switching Lights on/off with PIR if already on
does it work as you expected?
Who is online
Users browsing this forum: No registered users and 0 guests