As an aside, I’ve replaced all my ‘switches’ with ‘retractive switches’. The inputs are then buttons which makes life slightly easier with rules and stops the device getting out of ‘sync’ with the switch position.
This is an example of when Blink might be useful. Set BlinkCount 1 and BlinkTime 1800. If you ‘detach’ the switch and use it to trigger a Rule with power1 3 you will get the light switching off after 3 minutes – use power1 3 from MQTT/KNX too. You then need a rule which triggers on double press and sends power1 1 to keep the light on.
The Buttons and Switches and Rules pages explain how to interpret the different states.
Regards
Phil K
Sent from Mail for Windows 10
From: Markus Waldhauser
Sent: 06 July 2021 09:05
To: TasmotaUsers
Subject: Sonoff Mini R2, Switch off with Time delay or constant on
Hi everyone,
I am new to Tasmota devices and I am having following issue.
I use Sonoff Mini R2 (1 Relais, 1 Button, 1 Switch) with Tasmota KNX Firmware.
I can switch on / off using KNX. Config found in Screenshot.
I can switch on / off using MQTT topic.
I can switch on / off using 2 connected switches (top and bottom of the stairs).
I have applied the following rule so that the light will be switched off automatically after 3 minutes.
Backlog switchmode1 0; rule1 1
Rule1 ON power1#state=1 DO Backlog Power1 on; delay 1800; Power1 off endon
*********************
So far so good, but I am looking for following improvement where I need your help.
KNX, MQTT and normal use of the switch should result in same behaviour.
Switch on manually, switch off manually or after 3 minutes if I forgot to switch off.
Additional I want to use SwitchMode8 to switch light on permanent if I change the switch twice within specified 0,5 seconds.
So I have the light for a longer period, for e.g. cleaning the stairs.
When I am finished I would toggle switch once more for power off.
Regards, Markus
--
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/e39f7ba0-da79-48dc-82c3-b5a564353d95n%40googlegroups.com.
Can solve some of it with
On power1#state=1 do backlog var1 4; var2 0 endon
On power1#state=0 do backlog var1 3; var2 1 endon
Rule x ON Switch1#State=2 DO Power1 %var1% endon; (no need for backlog by the way)
Rule 1 ON Switch1#State=3 DO Power1 %var2% endon (Switch permanent on)
Don’t think that will work. Will get back to you later.
From: Markus Waldhauser
Sent: 06 July 2021 12:26
To: TasmotaUsers
Subject: Re: Sonoff Mini R2, Switch off with Time delay or constant on
Thanks for your help so far.
I unterstand what you mean, and I have tried already a little bit with actual release 9.5 KNX
Unfortunately I have 2 follow up questions.
In this case MQTT STAT Topic and KNX Output is not updated, and also in the Web Interface State Info is OFF, even when relais is switched on.
Is there a solution for this, so that I get feedback to KNX Visu and MQTT World?
Additionally can I make a logic connection between 2 states for the rule?
At the moment I did the following:
Backlog SetOption114 1; BlinkCount 1; BlinkTime 1800; SwitchMode 8; rule1 1
Rule1 ON Switch1#State=2 DO Backlog Power1 3; endon
But what I really want to do is:
Rule x ON Switch1#State=2 AND RELAIS=OFF DO Backlog Power1 3; endon (Switch on for 3 Minutes, time defined by blinking)
Rule y ON Switch1#State=2 AND RELAIS=ON DO Backlog Power1 4; Power1 0; endon (Interupt Blink mode / switch off)
Rule 1 ON Switch1#State=3 AND RELAIS=OFF DO Backlog Power1 1; endon (Switch permanent on)
Regards, Markus
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/1a68cc5c-65a1-4435-96c0-e8dfad6640ddn%40googlegroups.com.
Well done. I was about to send you another set replacing the rule timer with Blink
I’m not sure about the highlighted ones though. In each case the trigger is the same as the next command
In Basic Rule 1 would be
If
power2=on
then
let power2=on
let ruletimer1 =180
end
Backlog SetOption114 1; SwitchMode 8; SwitchTopic 0; rule1 1
Rule1 ON power2#state=1 DO Backlog Power2 on; RuleTimer1 180 ENDON ON Rules#Timer=1 DO Power2 off ENDON
Rule2 1
Rule2 ON power2#state=1 DO backlog Power1 1; var1 0 endon ON power2#state=0 DO backlog Power1 0; var1 1 endon ON power1#state=1 DO backlog Power1 1; var1 0 endon ON power1#state=0 DO backlog Power1 0; var1 1 endon
Rule3 1
Rule3 ON Switch1#State=2 Do Power2 %var1% endon ON Switch1#State=3 Do Power1 %var1% endon ON Switch1#State=2 Do Power1 %var1% endon
So rules should be (I might be wrong though)
Backlog SetOption114 1; SwitchMode 8; SwitchTopic 0; rule1 1
Rule1 ON power2#state=1 DO RuleTimer1 180 ENDON ON Rules#Timer=1 DO Power2 off ENDON
Rule2 1
Rule2 ON power2#state=1 DO backlog Power1 1; var1 0 endon ON power2#state=0 DO backlog Power1 0; var1 1 endon ON power1#state=1 DO backlog var1 0 endon ON power1#state=0 DO var1 1 endon
Rule3 1
Rule3 ON Switch1#State=2 Do Power2 %var1% endon ON Switch1#State=3 Do Power1 %var1% endon ON Switch1#State=2 Do Power1 %var1% endon
But then (I think) you can simplify further by removing the var1 changes in Rule2 which are repeated when Power1 changes state.
Backlog SetOption114 1; SwitchMode 8; SwitchTopic 0; rule1 1
Rule1
ON power2#state=1 DO RuleTimer1 180 ENDON (start ruler timer for 3 minutes)
ON Rules#Timer=1 DO Power2 0 ENDON (when rule timer expires switch off R2)
Rule2 1
Rule2
ON power2#state DO Power1 %value% endon (when R2 changes state make light match it)
ON power1#state=1 DO var1 0 endon (change var1 to inverse of light state)
ON power1#state=0 DO var1 1 endon (change var1 to inverse of light state)
Rule3 1
Rule3
ON Switch1#State=2 DO Power2 %var1% endon (toggle R2)
ON Switch1#State=3 Do Power1 %var1% endon (toggle Light)
ON Switch1#State=2 Do Power1 %var1% endon (not sure if this is necessary – Light follows R2 anyway - or if it could be combined with the first statement in this ruleset)
I know it’s me being pedantic but simplifying rules make it easier to change later if you need to.
Phil K
Sent from Mail for Windows 10
From: Markus Waldhauser
Sent: 07 July 2021 09:41
To: TasmotaUsers
Subject: Re: Sonoff Mini R2, Switch off with Time delay or constant on
And this is the final solution, where I can switch off timed light and permanent light immediatly
Backlog SetOption114 1; SwitchMode 8; SwitchTopic 0; rule1 1
Rule1 ON power2#state=1 DO Backlog Power2 on; RuleTimer1 180 ENDON ON Rules#Timer=1 DO Power2 off ENDON
Rule2 1
Rule2 ON power2#state=1 DO backlog Power1 1; var1 0 endon ON power2#state=0 DO backlog Power1 0; var1 1 endon ON power1#state=1 DO backlog Power1 1; var1 0 endon ON power1#state=0 DO backlog Power1 0; var1 1 endon
Rule3 1
Rule3 ON Switch1#State=2 Do Power2 %var1% endon ON Switch1#State=3 Do Power1 %var1% endon ON Switch1#State=2 Do Power1 %var1% endon
Markus Waldhauser schrieb am Mittwoch, 7. Juli 2021 um 09:48:40 UTC+2:
Based on your help I found a good solution.
I configured a virtual relais for my Sonoff MiniR2.KNX & MQTT Command are pointing to Power2.
KNX & MQTT Feedback are triggerd by Power 1.
I used the following rules:
Backlog SetOption114 1; SwitchMode 8; SwitchTopic 0; rule1 1
Rule1 ON power2#state=1 DO Backlog Power2 on; RuleTimer1 180 ENDON ON Rules#Timer=1 DO Power2 off ENDON
Rule2 1
Rule2 ON power2#state DO Power1 %value% endon
Rule3 1
Rule3 ON Switch1#State=2 Do Power2 on endon ON Switch1#State=3 Do Power1 on endon
With this solution I can switch on the timer via MQTT or KNX.
I can even switch off Timer using MQTT or KNX.
Toggle of the physical switch starts the timer.
Toggle switch twice within 0,5 seconds only switches on Power1 for constant light.
To switch off constant light I only have to toggle the switch and timer starts, and light is off 3 Minutes later. Optionally I can switch off immediatly using MQTT or KNX.
The only minor con is, that I can not switch off using the physical switch, have to wait 3 minutes for light off, but I consider this 1st world problem.
Regards!
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/cdb1b7d3-fe88-4cb8-ba56-30b8e6fbed99n%40googlegroups.com.
Makes sense