Rules

31 views
Skip to first unread message

joel gerardi

unread,
Jul 5, 2021, 5:03:29 PM7/5/21
to TasmotaUsers
I was able to make a motion sensor using a PIR am312 from amazon and wiring it GPIO3 on my shelly 1.  I have it set up with the following rule:

This is doing exactly what i need it to do. 

I am using the motion detector to open and close a sliding door.

via a button in home assistant,  I an do this using a standard button in HA to flip the switch to on but i need a rule to then shut it off immediately. I have tried multiple different syntax and cant get anything to work.

rule1 is enabled.

ie:

rule1 ON power#state=1 do power 0 ENDON
or
rule1 ON power#state==1 do power 0 ENDON

Ideas?  

ΧΡΗΣΤΟΣ ΚΑΛΤΣΟΣ

unread,
Jul 6, 2021, 1:36:03 AM7/6/21
to joel gerardi, TasmotaUsers
Hi Joel,

This can be like the following

 Rule1
    on button1#state=2 do power1 2 endon -------> when button is toggled toggle power1

If you are using a switch instead of button it can be 

  Rule1
      on Switch1#State=0 do power1 0 endon  ------->when sw1 state is off turn off power1
      on Switch1#State=1 do power1 1 endon    ---->when sw1 state is on turn on power1



   Rule1
    on button1#state=2 do power1 3 endon  

The general idea of making a rule is

Rule<x> ON <trigger1> DO <command> ENDON

IF you want multiple commands you have to use Backlog after "do" e.g. on tele-DS18B20#temperature<37 do Backlog power2 1; power3 3 endon
https://tasmota.github.io/docs/Rules/



Here are some rule info

Button2#State when a button changes state:
0 = OFF
1 = ON
2 = TOGGLE
3 = HOLD

Power<x> Control the corresponding power state (1..8) (also restarts PulseTime)<x>
0 / off / false = turn OFF
1 / on / true = turn ON
2 / toggle = if power state is ON switch to OFF and vice versa
3 / blink = toggle power for BlinkCount times each BlinkTime duration (at the end of blink, power state is returned to pre-blink state)
4 / blinkoff = stop blink sequence and return power state to pre-blink state

Switch1#State when a switch changes to state. Will not trigger if SwitchTopic is set.
use Switch1#state=0 and Switch1#state=1 for comparison, not =off or =on
0 = OFF
1 = ON
2 = TOGGLE
3 = HOLD (SwitchTopic 0 must be set for this to trigger)
4 = INC_DEC (increment or decrement dimmer)
5 = INV (change from increment to decrement dimmer and vice versa)
6 = CLEAR (button released for the time set with SetOption32)

Chreers,
Chris

**************************************************************

Chris Kaltsos(Χρήστος Κάλτσος)

Electronic Engineer (B.Sc.)

MSc in Ubiquitous Computing

Internet of Thing ( IoT ) Specialist

Mobile: +306971567588

e-mail: chris.f...@gmail.com

**************************************************************




--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/234ed7b6-1301-4754-953e-1272ea826b88n%40googlegroups.com.

Philip Knowles

unread,
Jul 6, 2021, 1:39:14 AM7/6/21
to joel gerardi, TasmotaUsers

Try PulseTime or Blink

 

Sent from Mail for Windows 10

--

joel gerardi

unread,
Jul 6, 2021, 3:31:49 AM7/6/21
to TasmotaUsers
When i say i am using a button, i am referring to a button in home assistant, not a button on the tasmota.  In other words i am sending an mqtt command to the tasmota (cmnd/BackDoor/power 1). Once the relay closes i want to immediately open it.  So once i achieve power 1, i want to return to power 0.

I cant seem to get any rules to fire at all.  Im wondering if there is another setting someplace that i need to change to get rules to work.

Philip Knowles

unread,
Jul 6, 2021, 4:41:24 AM7/6/21
to joel gerardi, TasmotaUsers

As I said try PulseTime you don’t need a Rule to achieve what you want pulsetime 5 will turn the relay off after 500ms.

Blink is sometimes a better option as it uses power1 3 as a trigger. If sometimes you want a device to stay on you can send power1 1 but if you want it to stay on for a minute you can set BlinkCount 1 and BlinkTime 600 and send the command power1 3.

 

The issue maybe using a Button. You said earlier that you are using a PIR. A Button ‘toggles’ the Relay - a Switch only operates the Relay when it’s closed. If the PIR has an adjustable on time adjust it to the minimum.

 

You are also better to use power1 1 and power1 0 rather than just power. You should probably insert a delay in the Rule too.

 

Regards

 

Phil K

Reply all
Reply to author
Forward
0 new messages