arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
21.75k stars 4.72k forks source link

PIR on a Timer #2801

Closed Lawrencezarb closed 6 years ago

Lawrencezarb commented 6 years ago

If I connect a PIR sensor to one of the GPIO ports to control the realy, is it possible to configure the Sonoff (maybe using rules?) to only detect the movement between certain times of the day.

Please note that the sonoff is not connected to any Home Automation system and is free standing.

andrethomas commented 6 years ago

I don't believe that will be possible.

I think the question is what you would do with the data that is created when the PIR sensor is triggered... normally one would push this via MQTT to something like mosquitto and perhaps node-red? I think the simplest would be to implement something to ignore triggers during specific times of the day on the automation system side.

Perhaps another solution (albeit a little more technical) could be to power the PIR sensor from one of the GPIO pins which is time controlled by Sonoff-Tasmota - that would give a less than perfect solution but still a solution - question is though... what will the PIR be triggering and how would you process the triggering of the PIR sensor anyway leading to the suggestion that without an automation system of sort (such as home assistant or node-red) there would not be much point.

Unless, of course, it is possible that I misunderstand your question entirely.

ascillato commented 6 years ago

If I connect a PIR sensor to one of the GPIO ports to control the realy, is it possible to configure the Sonoff (maybe using rules?) to only detect the movement between certain times of the day.

Yes, it is totally possible but only with the last version of tasmota (development branch) v5.14.0a

Configure the pin where the PIR is, as switch1 (for example). You can use switchmode1 3 (to detect only if PIR sends a 1 to the Sonoff)

Set a timer to be triggered when you want to control the relay with PIR Set another timer to be triggered when you don't want to control the relay with PIR

Set a rule to detect the fist timer and set a variable to 1 Set another rule to detect the other timer and set the same variable to 0

Set a rule to detect the state change of the switch and that makes a power with the value of the variable (if the variable is 1 will power on, if the variable is 0 will power off <- if the relay was off nothing will happen)

Everything together. Config

(var1 in this example will act as an enabled/disabled option)

This is an example, may be that some tunning is needed. See commands and rules on the wiki. Please check it and if it works you can add it to the wiki as an example, because your idea is very usefull. :+1:

As extra can be added that on boot it did not check the pir for some warming time. Also to send a mqtt message to an automation system, etc.

andrethomas commented 6 years ago

Perhaps easier...

Connect PIR as normal to voltage and send output of PIR through a relay to an input pin.

Turn relay on/off at specific times so that when the relay is off no input will be received on input pin.

ascillato commented 6 years ago

Yes, it is easier, but you need 2 relays. One for controlling the PIR and another for the light. If it is your case you can do it that way if you like it.

Now automations can be solved in different ways. All are valid options. Thanks for share. :+1:

Lawrencezarb commented 6 years ago

Hi All,

Thanks for all your useful and helpful comments. I am wating for my PIR sensor so cannt test it yet.

The real world senerio for me, is that the Sonoff will be use to control my sprinkers, which I will use the timers.

I have a pond in my garden that a Heron likes to visit. The idea is to use the PIR to trigger the sprinklers, to hopfully scare the Heron away, but only operate in the early mornings, say from 5am to 8am

reloxx13 commented 6 years ago

@ascillato using switchmode1 3 is require to use pulsetime as timer right?

currently im using a pir without rules, so it turns on 24h if someone is moving and im using switchmode1 1 and have the jumper on the outside (pulses as long someone is moving)

HC

so it will use the configured on time i configured by the potentiometer on the pir.

if i change this to switchmode1 3 now, the device wont turn off, since its only listening on the ON state. so i need the pulsetime to get it off again, since i cannot use "if" in the rules like if motion==1 and var1==1 set state = 1 if motion== 0 set state 0

if i use switchmode1 1, the rule is failing cuz it acts like this: if motion(1 or 0) set state = 1 (or always 0 by time) results in always on if var1 is 1.

so its acting like a switch and not like a pushbutton. if i want to use the pushbutton i need to set a pulsetime and change the jumper.

HC-SR501 infos (german only, but good imagess): http://www.netzmafia.de/skripten/hardware/RasPi/Projekt-PIR/index.html

another usefull hints for PIR: #640

my pir box: 2018-05-23 18 44 39

reloxx13 commented 6 years ago

Feedback: Rules, Timer, Pulsetimer disabled. As soon as i change it to Switchmode1 3, the Sensor is delayed to over 10sec before turning on anything. Tried both Jumper Positions. Highest sensity set on the PIR.

Switchmode1 1 is changing the state instant.