Page 1 of 1
Rules logic
Posted: 18 Sep 2017, 11:39
by playzino
I have IRreciver connect to NodeMCU with ESPEASY 2.0, i try do triger some event usign MCE Remote (RC6). I Try this code:
Code: Select all
On IR#IR=2148467803 do
pulse,4,1,100
endon
But pulse is trigered by similare ir codes like 2148467804, 2148467805. IRceciver recive correct IR.
Any idea what's wrong?
Re: Rules logic
Posted: 18 Sep 2017, 13:46
by grovkillen
I think it has something to do with the float value precision.
https://en.wikipedia.org/wiki/Single-pr ... int_format
If possible you should try to log the output from serial and see if the values are really the same as you think, they might be truncated?
Re: Rules logic
Posted: 18 Sep 2017, 14:14
by playzino
This is 32bit, RC6 Code. In log and on serial monitor i see correct (different) code
Code: Select all
IR#IR=2148467803
IR#IR=2148467804
IR#IR=2148467805
I try to use,
Code: Select all
On IR#IR do
if IR#IR=2148467803 do
...
endif
endon
,but this dosn't work
Re: Rules logic
Posted: 18 Sep 2017, 14:36
by grovkillen
It's not the correct syntax. The "test" need to have the Device#Value in square brackets (see rules syntax
here).
Code: Select all
On IR#IR do
if [IR#IR]=2148467803 do
//...
endif
endon
Re: Rules logic
Posted: 18 Sep 2017, 14:39
by playzino
ok thx, can I try some think like this?
Code: Select all
On IR#IR do
if [IR#IR]-214846700=803 do
//...
endif
endon
Re: Rules logic
Posted: 18 Sep 2017, 14:43
by grovkillen
You might, I haven't tested that one exactly (with the arithmetic on the left side). But it could work. Please report back

Re: Rules logic
Posted: 18 Sep 2017, 19:07
by playzino
Arithmetic on the left side don't work.
LOG:
Code: Select all
66189409 : IR : Code 800f045c - Type: 2 - Bits: 36
66189423 : EVENT: IR#IR=2148467804
66189470 : ACT : pulse,5,1,100
66189571 : SW : GPIO 5 Pulsed for 100 mS
Rules
Code: Select all
On IR#IR do
if [IR#IR]=2148467803 do
pulse,5,1,100
endif
endon
Any idea???
Re: Rules logic
Posted: 18 Sep 2017, 21:27
by toffel969
playzino wrote: ↑18 Sep 2017, 19:07
Arithmetic on the left side don't work.
LOG:
Code: Select all
66189409 : IR : Code 800f045c - Type: 2 - Bits: 36
66189423 : EVENT: IR#IR=2148467804
66189470 : ACT : pulse,5,1,100
66189571 : SW : GPIO 5 Pulsed for 100 mS
Rules
Code: Select all
On IR#IR do
if [IR#IR]=2148467803 do
pulse,5,1,100
endif
endon
Any idea???
Code: Select all
On IR#IR do
if [IR#IR]=2148467803 do
pulse,5,1,100
endif
endon
should be
Code: Select all
On IR#IR do
if [IR#IR]=2148467803
pulse,5,1,100
endif
endon
there is not supposed to be a "do" in the if statement
not sure if this solves your problem though
Re: Rules logic
Posted: 18 Sep 2017, 21:36
by playzino
Oh yeah, now is missing do, but the problem is that this rules works TO GOOD. Rules is executed by similar codes not only THIS code.
BTW. It is possible to use var in Rules?
Re: Rules logic
Posted: 19 Sep 2017, 08:29
by toffel969
playzino wrote: ↑18 Sep 2017, 21:36
Oh yeah, now is missing do, but the problem is that this rules works TO GOOD. Rules is executed by similar codes not only THIS code.
BTW. It is possible to use var in Rules?
Ya but when dealing with unexpected behaviour, it is best t respect the syntax. "Do" for events, "[]" for the value compared in if.
Variables should be possible as dummy devices. You can save 4 var per device
Re: Rules logic
Posted: 19 Sep 2017, 18:12
by Domosapiens
On IR#IR do
I'm not sure that using the same name for "Task Name" and "Value Name" is allowed.
I vaguely remember that I had problems with that.
Hope this helps
Domosapiens
Re: Rules logic
Posted: 29 Sep 2017, 13:35
by playzino
Tested on 26bit codes from other remote and works fine. Definitely have problem with 36bits codes.
Re: Rules logic
Posted: 08 Oct 2017, 09:16
by Drum
Might this explain it???
From the Wiki:
"Remember that you can only store floating point numbers as output from your device. Also note that the floating point precision is limited. For most application this will not lead to issues but storing a large 32 bit number like RFID tags will get rounded. As a workaround, you can store this into two floating point variables as 16 bit parts. Selecting SENSOR_TYPE_LONG will handle this within the framework. But it supports only one long value!"
Re: Rules logic
Posted: 08 Oct 2017, 10:13
by papperone
Drum wrote: ↑08 Oct 2017, 09:16
Might this explain it???
From the Wiki:
"Remember that you can only store floating point numbers as output from your device. Also note that the floating point precision is limited. For most application this will not lead to issues but storing a large 32 bit number like RFID tags will get rounded. As a workaround, you can store this into two floating point variables as 16 bit parts. Selecting SENSOR_TYPE_LONG will handle this within the framework. But it supports only one long value!"
I can confirm this as I faced similar problem when developping my HLW8012 plugin; calibration value were needed to be DOUBLE and not to be rounded so I ended up with saving them as "Custom Settings".
This is definitely doable and it works a charm so if needed as well for RFID readings of large tags then someone needs to implement it in the relevant pluing code.