Strange behaviour: rules mess up devices

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
groovy
Normal user
Posts: 39
Joined: 14 Oct 2016, 11:32
Location: Chemnitz, Germany

Strange behaviour: rules mess up devices

#1 Post by groovy » 08 Feb 2017, 13:11

I have a strange problem with rules on my WiFi candle.
There are 2 devices connected to an ESP8266-01: The LEDs for the candle and a PIR to switch them on or off.
Both devices work okay. My setup is as follows:
devices_ok.png
devices_ok.png (31.94 KiB) Viewed 8757 times
and both devices work as expected:
log_ok.png
log_ok.png (28.81 KiB) Viewed 8757 times
However, as soon as I enable my simple rules:
rules.png
rules.png (26.05 KiB) Viewed 8757 times
to switch the LEDs on and of with the PIR, the Candle device gets screwed up. The name changes to PIR and the first value changes from "Color" to "Switch":
devices_screwed.png
devices_screwed.png (32.58 KiB) Viewed 8757 times
and the EVENTS in the log also go crazy:
log_screwed.png
log_screwed.png (28.61 KiB) Viewed 8757 times
It works for a short time (Candle switches when PIR is activated) but after half a minute or so it doesn't work anymore.
Any idea what happens here? Are my rules wrong?

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Strange behaviour: rules mess up devices

#2 Post by toffel969 » 09 Feb 2017, 07:57

CANDLE in capital Letters might be the problem. It Shows in small Letters in events. Also, where do the "::" Come from? . I found strange behaviour when not respecting syntax of Rules. ( like end on instead of endon, or. Instead of,)
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

groovy
Normal user
Posts: 39
Joined: 14 Oct 2016, 11:32
Location: Chemnitz, Germany

Re: Strange behaviour: rules mess up devices

#3 Post by groovy » 09 Feb 2017, 08:47

Thanks for your answer.
I tried all kinds of upper/lower letters with no effect.
The : separates the arguments, see the authors examples in sourcecode:

Code: Select all

// Commands
        // CANDLE:<FlameType>:<Color>:<Brightness>
        //    <FlameType>  : 1 Static Light, 2 Simple Candle, 3 Advanced Candle, 4 Police, 5 Blink, 6 Strobe, 7 Color Fader
        //    <Color>      : n.def.  Use the default color
        //                   RRGGBB  Use color in RRGGBB style (red, green blue) as HEX
        //    <Brightness> : 0-255 
        // Samples:   CANDLE:2::100           Simple Candle with Default color and Brigthness at 100
        //            CANDLE:5:FF0000:200     Blink with RED Color and Brigthness at 200
        //            CANDLE:0::              Candle OFF
        //            CANDLE:1::255           Candle ON - White and full brigthness

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Strange behaviour: rules mess up devices

#4 Post by toffel969 » 09 Feb 2017, 18:03

groovy wrote:Thanks for your answer.
I tried all kinds of upper/lower letters with no effect.
The : separates the arguments, see the authors examples in sourcecode:

Code: Select all

// Commands
        // CANDLE:<FlameType>:<Color>:<Brightness>
        //    <FlameType>  : 1 Static Light, 2 Simple Candle, 3 Advanced Candle, 4 Police, 5 Blink, 6 Strobe, 7 Color Fader
        //    <Color>      : n.def.  Use the default color
        //                   RRGGBB  Use color in RRGGBB style (red, green blue) as HEX
        //    <Brightness> : 0-255 
        // Samples:   CANDLE:2::100           Simple Candle with Default color and Brigthness at 100
        //            CANDLE:5:FF0000:200     Blink with RED Color and Brigthness at 200
        //            CANDLE:0::              Candle OFF
        //            CANDLE:1::255           Candle ON - White and full brigthness
I still think it gots to do with rule syntax. Maybe you can try the following:

CANDLE:0::0 for switching off.

Also, for debugging purposes, try and flash an LED when you execute code. Maybe it helps with finding the fault. I'll think about it again.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Strange behaviour: rules mess up devices

#5 Post by toffel969 » 11 Feb 2017, 11:38

toffel969 wrote:
groovy wrote:Thanks for your answer.
I tried all kinds of upper/lower letters with no effect.
The : separates the arguments, see the authors examples in sourcecode:

Code: Select all

// Commands
        // CANDLE:<FlameType>:<Color>:<Brightness>
        //    <FlameType>  : 1 Static Light, 2 Simple Candle, 3 Advanced Candle, 4 Police, 5 Blink, 6 Strobe, 7 Color Fader
        //    <Color>      : n.def.  Use the default color
        //                   RRGGBB  Use color in RRGGBB style (red, green blue) as HEX
        //    <Brightness> : 0-255 
        // Samples:   CANDLE:2::100           Simple Candle with Default color and Brigthness at 100
        //            CANDLE:5:FF0000:200     Blink with RED Color and Brigthness at 200
        //            CANDLE:0::              Candle OFF
        //            CANDLE:1::255           Candle ON - White and full brigthness
I still think it gots to do with rule syntax. Maybe you can try the following:

CANDLE:0::0 for switching off.

Also, for debugging purposes, try and flash an LED when you execute code. Maybe it helps with finding the fault. I'll think about it again.

Not really a solution, but maybe a workaround. try using the http command /udp to switch it off
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

groovy
Normal user
Posts: 39
Joined: 14 Oct 2016, 11:32
Location: Chemnitz, Germany

Re: Strange behaviour: rules mess up devices

#6 Post by groovy » 12 Feb 2017, 07:58

I already tried the HTTP method, see my post here, where also the actual ruleset comes from.
What I really don't understand is, that it works for the first time, but as soon as the PIR is switched for the first time, it messes up the device.
I will test it further, thanks for your suggestions.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Strange behaviour: rules mess up devices

#7 Post by toffel969 » 12 Feb 2017, 16:20

groovy wrote:I already tried the HTTP method, see my post here, where also the actual ruleset comes from.
What I really don't understand is, that it works for the first time, but as soon as the PIR is switched for the first time, it messes up the device.
I will test it further, thanks for your suggestions.
what is the reset time of your pir? anyway, maybe try a timer. instead of using pir=0 to switch off, try using a timerSet command to set desired time and then the 'candle off command' in the timer rule.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Strange behaviour: rules mess up devices

#8 Post by toffel969 » 12 Feb 2017, 16:23

groovy wrote:I already tried the HTTP method, see my post here, where also the actual ruleset comes from.
What I really don't understand is, that it works for the first time, but as soon as the PIR is switched for the first time, it messes up the device.
I will test it further, thanks for your suggestions.
as far as i can see the log, its only after pir=0
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

groovy
Normal user
Posts: 39
Joined: 14 Oct 2016, 11:32
Location: Chemnitz, Germany

Re: Strange behaviour: rules mess up devices

#9 Post by groovy » 12 Feb 2017, 17:19

toffel969 wrote:as far as i can see the log, its only after pir=0
The first log is without the rules being active. Will try your suggestions when I get back to the device tomorrow, thanks.

groovy
Normal user
Posts: 39
Joined: 14 Oct 2016, 11:32
Location: Chemnitz, Germany

Re: Strange behaviour: rules mess up devices

#10 Post by groovy » 13 Feb 2017, 11:01

toffel969 wrote:as far as i can see the log, its only after pir=0
Just did some tests again. The device get's messed up as soon as the PIR switches for the first time, no matter if it's on or off.
I also tried a timer instead of the PIR for switching off:

Code: Select all

on PIR#Switch do 
 CANDLE:3::60
 timerSet 1,10
endon
on Rules#Timer=1 do
 CANDLE:0::
endon
Same result. Candle device is renamed to "PIR" and first value name is set to "Switch" as soon as the PIR switches on.
Is it possible that the ":" separator is somehow misinterpreted by another part of the code and replacing it with something may help?

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Strange behaviour: rules mess up devices

#11 Post by toffel969 » 13 Feb 2017, 17:43

groovy wrote:
toffel969 wrote:as far as i can see the log, its only after pir=0
Just did some tests again. The device get's messed up as soon as the PIR switches for the first time, no matter if it's on or off.
I also tried a timer instead of the PIR for switching off:

Code: Select all

on PIR#Switch do 
 CANDLE:3::60
 timerSet 1,10
endon
on Rules#Timer=1 do
 CANDLE:0::
endon
Same result. Candle device is renamed to "PIR" and first value name is set to "Switch" as soon as the PIR switches on.
Is it possible that the ":" separator is somehow misinterpreted by another part of the code and replacing it with something may help?
Maybe try to swap the devices (make PIR Task1 and Candle Task2). Sonst fällt mir auch nichts mehr ein :cry:
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

groovy
Normal user
Posts: 39
Joined: 14 Oct 2016, 11:32
Location: Chemnitz, Germany

Re: Strange behaviour: rules mess up devices

#12 Post by groovy » 13 Feb 2017, 18:16

Will try this tomorrow. Danke dir.

groovy
Normal user
Posts: 39
Joined: 14 Oct 2016, 11:32
Location: Chemnitz, Germany

Re: Strange behaviour: rules mess up devices

#13 Post by groovy » 14 Feb 2017, 07:04

toffel969 wrote:Maybe try to swap the devices (make PIR Task1 and Candle Task2).
This is very strange. I just swapped the devices and now the candle device stays intact but the PIR is renamed to "CANDLE" and the value is renamed from "Switch" to "Color".
So it seems it's affecting always the first device :?

Update:
With my last sentence in mind, I created a dummy device as the first one, candle as second and PIR as third.
Now, as expected, the dummy device is renamed to PIR and the value name to Switch, but my candle doesn't get touched and works now.
This is a workaround, but obviously not the solution.
Last edited by groovy on 14 Feb 2017, 07:57, edited 1 time in total.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Strange behaviour: rules mess up devices

#14 Post by toffel969 » 14 Feb 2017, 07:54

groovy wrote:
toffel969 wrote:Maybe try to swap the devices (make PIR Task1 and Candle Task2).
This is very strange. I just swapped the devices and now the candle device stays intact but the PIR is renamed to "CANDLE" and the value is renamed from "Switch" to "Color".
So it seems it's affecting always the first device :?
2 thoughts. change build version , avoid using the first task, just use 2+3 . but this is really strange
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

groovy
Normal user
Posts: 39
Joined: 14 Oct 2016, 11:32
Location: Chemnitz, Germany

Re: Strange behaviour: rules mess up devices

#15 Post by groovy » 14 Feb 2017, 07:58

You are fast :D
See my update on the former post.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Strange behaviour: rules mess up devices

#16 Post by toffel969 » 14 Feb 2017, 13:18

groovy wrote:You are fast :D
See my update on the former post.
Great minds think alike, and fools never differ ;-) glad to hear you got it working
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Post Reply

Who is online

Users browsing this forum: No registered users and 43 guests