inconsistency RTD, Rule- problem

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
M*I*B
Normal user
Posts: 319
Joined: 22 Jan 2018, 15:47
Location: Germany
Contact:

inconsistency RTD, Rule- problem

#1 Post by M*I*B » 10 Jan 2023, 20:58

Just some trouble...

1. Inconsistency in the RTD / TaskValueSet
In the RTD there is an inconsistency in the TaskValueSet area as to how the command is to be written.
TaskValueSet 12,1,0 versus TaskValueSet,12,1,0 respectively TaskValueSet dummy,var1,0 versus TaskValueSet,dummy,var1,0
Once it is shown with spaces, once with a comma. It may of course be that both are correct (I haven't tried it yet), but in my opinion you should urgently write if both spellings are correct.

2. Simple Rule don't work

Code: Select all

On Clock#Time Do
	TaskValueSet,6,1,%syshour%
	TaskValueSet,6,2,%sysmin%
	
	If [tick#h] > 12
		TaskValueSet,6,3,[tick#h]-12
	Elseif [tick#h] = 0
		TaskValueSet,6,3,12
	Else
		TaskValueSet,6,3,[tick#h]
	Endif
Endon
Task 6 is a quad-dummy named "tick" with h, m, h1, m1 as values
Value 1 to 3 (4 I don't use yet) will not set if the time- event comes up every minute
DLzG
Micha

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: inconsistency RTD, Rule- problem

#2 Post by Ath » 10 Jan 2023, 21:08

1. Both ways of writing are correct, see: https://github.com/letscontrolit/ESPEasy/issues/2724

2. The reason to allow the task and value names in TaskValueSet command, is to improve readability of scripts:

Code: Select all

On Clock#Time Do
	TaskValueSet,tick,h,%syshour%
	TaskValueSet,tick,m,%sysmin%
	
	If [tick#h] > 12
		TaskValueSet,tick,h1,[tick#h]-12
	Elseif [tick#h] = 0
		TaskValueSet,tick,h1,12
	Else
		TaskValueSet,tick,h1,[tick#h]
	Endif
Endon
It will be set, but the shortest Interval of your Devices determines the update interval of the page, and it may not be set at all, so there is no update...
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: inconsistency RTD, Rule- problem

#3 Post by Ath » 10 Jan 2023, 21:37

The parameter parsing is already documented in RTD: https://espeasy.readthedocs.io/en/lates ... er-parsing
/Ton (PayPal.me)

User avatar
M*I*B
Normal user
Posts: 319
Joined: 22 Jan 2018, 15:47
Location: Germany
Contact:

Re: inconsistency RTD, Rule- problem

#4 Post by M*I*B » 10 Jan 2023, 22:43

Ath wrote: 10 Jan 2023, 21:37 The parameter parsing is already documented in RTD: https://espeasy.readthedocs.io/en/lates ... er-parsing
You're right. I wasn't concerned with the two spellings with numerical or name references. It was clear to me that both are possible (I'm lazy and prefer to use numbers). I was only concerned with using the first separator between the command and the values, i.e. space or comma...
But how do you / a beginner like I am normally use the RTD?
You call it up and look for the order or command. Once you find what you need, use it as it is.
No one thinks of questioning every single command listed in the RTD and trying to understand the parsing behind it, let alone searching through all the issues for it. Beginners in particular may be a bit confused and unsure if they find two different spellings in the RTD without any indication that both are correct. I'm not either. I was just assuming that both are correct.
Ath wrote: 10 Jan 2023, 21:37 It will be set, but the shortest Interval of your Devices determines the update interval of the page, and it may not be set at all, so there is no update...
I probably expressed myself wrongly...
There is neither an update nor ever an entry. After the reboot and one minute of waiting for the first time event, at least the current hour and minute should be in cells 1 and 2. But the dummy always stays at "0" with all cells; nothing happens at all.
Or have I misunderstood you now?
DLzG
Micha

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: inconsistency RTD, Rule- problem

#5 Post by Ath » 10 Jan 2023, 22:55

Is your dummy task enabled, and does it have an Interval set? Then it should work...
/Ton (PayPal.me)

User avatar
M*I*B
Normal user
Posts: 319
Joined: 22 Jan 2018, 15:47
Location: Germany
Contact:

Re: inconsistency RTD, Rule- problem

#6 Post by M*I*B » 10 Jan 2023, 23:01

... yes and yes/no ...
I have try both and just right now I have catch the problem...

Code: Select all

On Clock#Time Do
... don't work. The Logfile show the event but the "DO" will be ignored.

If I set ...

Code: Select all

On Clock#Time=All,**:** Do
... the Logfile show the event as before AND the "DO" will be processed ...

Is that a bug?
DLzG
Micha

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: inconsistency RTD, Rule- problem

#7 Post by Ath » 10 Jan 2023, 23:12

M*I*B wrote: 10 Jan 2023, 23:01 Is that a bug?
That's debatable... but I think the Weekday and time arguments are actually required. This is sort of an 'exceptional case' in the event handling/rules processing. (I missed that the arguments are missing..., must have been a busy day 8-))
/Ton (PayPal.me)

User avatar
M*I*B
Normal user
Posts: 319
Joined: 22 Jan 2018, 15:47
Location: Germany
Contact:

Re: inconsistency RTD, Rule- problem

#8 Post by M*I*B » 10 Jan 2023, 23:14

... opk, same here...

Then let us end here and take a nap ;)

Good N8 then ...
DLzG
Micha

User avatar
M*I*B
Normal user
Posts: 319
Joined: 22 Jan 2018, 15:47
Location: Germany
Contact:

Re: inconsistency RTD, Rule- problem

#9 Post by M*I*B » 10 Jan 2023, 23:29

... just one more after the nap:

How can I check if a numeric value even or odd?
DLzG
Micha

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: inconsistency RTD, Rule- problem

#10 Post by TD-er » 10 Jan 2023, 23:40

Assume you have something already in [int#1]
The "let" command does all computation things you throw at it.
The % is the "modulo" operator.

Code: Select all

let,1,[int#1]%2
if [int#1]=0
  logentry,"even"
else
  logentry,"odd"
endif

User avatar
M*I*B
Normal user
Posts: 319
Joined: 22 Jan 2018, 15:47
Location: Germany
Contact:

Re: inconsistency RTD, Rule- problem

#11 Post by M*I*B » 10 Jan 2023, 23:41

... great! Thank you!
DLzG
Micha

igorka
Normal user
Posts: 74
Joined: 17 Jul 2022, 13:41
Location: Ukraine

Re: inconsistency RTD, Rule- problem

#12 Post by igorka » 12 Jan 2023, 14:00

TD-er wrote: 10 Jan 2023, 23:40 Assume you have something already in [int#1]
The "let" command does all computation things you throw at it.
The % is the "modulo" operator.

Code: Select all

let,1,[int#1]%2
if [int#1]=0
  logentry,"even"
else
  logentry,"odd"
endif
I know that I'm asking a question in the wrong topic. It's short, so forgive me. I have created several variables let,1; let,2; let,3 and ... let,10. In System#Boot, I assigned them the values let,1,0; let,2,0, etc... But I need to perform calculations with them (mathematical operations).
For example addition:

Code: Select all

[int#2]=[int#2]+[int#1]//does not work
let,2,[int#2]=let,2,[int#2]+let,1,[int#1]//does not work
let,2,[int#2]=[int#2]+[int#1]//does not work
Simple increment (decrement) works:

Code: Select all

let,1,[int#1]+1
let,2,[int#2]+[int#1]

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: inconsistency RTD, Rule- problem

#13 Post by Ath » 12 Jan 2023, 15:20

igorka wrote: 12 Jan 2023, 14:00 For example addition:

Code: Select all

[int#2]=[int#2]+[int#1]//does not work
let,2,[int#2]=let,2,[int#2]+let,1,[int#1]//does not work
let,2,[int#2]=[int#2]+[int#1]//does not work
That looks a bit funny,
The Let command assigns a value to a variable-number (either used via [var#N] or [int#N]), thus let,1,10 will assign the value 10 to variable 1, usable as [var#1] (optionally having decimals) and [int#1] (integer value, rounded if needed)
so rewriting that rule code:

Code: Select all

// [int#2]=[int#2]+[int#1]//can not work, no command used
// let,2,[int#2]=let,2,[int#2]+let,1,[int#1]//can not work, mixing commands and variables in 1 line
let,2,[int#2]+[int#1]//does work: assign the sum of variable 2 and variable 1 to variable 2
Edit:
NB: No need to assign values in on system#boot do as the variables will all be reset to 0 initially (actually, they don't exist, and are only created when first used in a let command, and returning 0 if not yet set).
The amount of available memory is the limit of the number of variables that can be created (assigned a value using let), reading without being set is unlimited between 1 and 2³¹-1.
/Ton (PayPal.me)

igorka
Normal user
Posts: 74
Joined: 17 Jul 2022, 13:41
Location: Ukraine

Re: inconsistency RTD, Rule- problem

#14 Post by igorka » 12 Jan 2023, 18:22

Maybe it's funny... The fact is that in the "C" programming language, it is considered a correct entry: x+=y; x=x+y. And that's why I make a lot of mistakes... It is also more usual to give names to variables, this also forces you to change the usual approach for writing code.
Thanks for the example:

Code: Select all

let,2,[int#2]+[int#1]
I've already figured it out.

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests