TaskValueSet and unit of measurement

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
edstobi
Normal user
Posts: 39
Joined: 28 May 2020, 20:33

TaskValueSet and unit of measurement

#1 Post by edstobi » 28 May 2020, 20:52

Hello
I calculate the correct distance in a rule and give it to a dummy every 2 seconds to Dummy Line 4 "Distance"

Code: Select all

TaskValueSet 4.4,[Ultrashall_r#Distance]+1000
two seconds later, I'll hand over

Code: Select all

TaskValueSet 4.4,[Ultrashall_l#Distance]+80
But I would like to add a unit of measure or another variable to output this to the OLED.
I can display it in the OLED:
LINE 1: Distance [Dummy#Distance], but then I don't know which one is shown at this time.

How can I influence the rule that the result "1234 left" or "4321 right" is passed to TaskValueSet 4,4
THX
EDSTOBI

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

Re: TaskValueSet and unit of measurement

#2 Post by TD-er » 28 May 2020, 21:02

taskvalueset can only handle numerical values, like integer or floating point values.
It does not format strings.

In the display task you can format the string as you wish.
See the documentation for this: https://espeasy.readthedocs.io/en/lates ... red-values

edstobi
Normal user
Posts: 39
Joined: 28 May 2020, 20:33

Re: TaskValueSet and unit of measurement

#3 Post by edstobi » 28 May 2020, 21:33

Thanks TD-er
This point
[TaskName#ValueName#transformation#justification]

I have already found it, but have not been able to send anything to the OLED
My OLED TaskNAme is OLED. I do not have a ValueName. This I think is that my command is wrong and is rejected.
Can you give me an example of what the command should say?
OLED Display: OLED
Measured value: [Dummy#Distance]
justification: left

[OLED# #Dummy#Distance# #left] is not working

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

Re: TaskValueSet and unit of measurement

#4 Post by TD-er » 28 May 2020, 21:42

You should use them in the line definition of the OLED (or Framed OLED) task configuration.
So it is not about sending it pre-formatted to some register, but only format it when you actually display it.

Since the lines for those display plugins are often a bit limited in length, I suggest also to limit the length of the taskname and varname you want to refer to.

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

Re: TaskValueSet and unit of measurement

#5 Post by Ath » 28 May 2020, 21:54

edstobi wrote: 28 May 2020, 20:52 two seconds later, I'll hand over
Hm, why would you use 1 dummy variable to display 2 different values?
Well, ok, it's possible :D

Assuming you have 2 separate events where that is happening, you could set an extra dummy variable (Dummy2 / Direction) for the direction, and use a transformation on that:

Code: Select all

// Right distance
TaskValueSet 4,4,[Ultrashall_r#Distance]+1000
TaskValueSet 5,1,0

Code: Select all

// Left distance
TaskValueSet 4,4,[Ultrashall_l#Distance]+80
TaskValueSet 5,1,1
On your OLED configuration, you could use something like:

Code: Select all

Measured value: [Dummy#Distance] [Dummy2#Direction#I]
Unfortunately, no Left/Right transformation is available, so I used the 'I' (uppercase-i) OUT/IN transformation, but 'U' (uppercase u) DOWN/UP could also be usable.

@TD-er, would an extra 'L' LEFT/RIGHT transformation fit in there? :roll:
Last edited by Ath on 28 May 2020, 21:57, edited 1 time in total.
/Ton (PayPal.me)

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

Re: TaskValueSet and unit of measurement

#6 Post by TD-er » 28 May 2020, 22:02

Ath wrote: 28 May 2020, 21:54 [...]
Unfortunately, no Left/Right transformation is available, so I used the 'I' (uppercase-i) OUT/IN transformation, but 'U' (uppercase u) DOWN/UP could also be usable.

@TD-er, would an extra 'L' LEFT/RIGHT transformation fit in there? :roll:
It should use the same transformations.
Except for a line that may not fit in the reserved storage for such a line, it should be usable in the same formatting.
But keep in mind the number of positions in the parameters/separators.
The format is [TaskName#ValueName#transformation#justification]
So the justification needs 3 hashtags.

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

Re: TaskValueSet and unit of measurement

#7 Post by Ath » 29 May 2020, 20:09

I created a PR for just this small feature: https://github.com/letscontrolit/ESPEasy/pull/3094
Didn't add the L/l transformation, but R/r as that's in line with the other transformations (using the first letter of the 1-state value, where possible, and Left/Right seems more appropriate then Right/Left)
/Ton (PayPal.me)

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

Re: TaskValueSet and unit of measurement

#8 Post by Ath » 31 May 2020, 12:21

Ath wrote: 29 May 2020, 20:09 Didn't add the L/l transformation, but R/r as that's in line with the other transformations (using the first letter of the 1-state value, where possible, and Left/Right seems more appropriate then Right/Left)
Had to resort to the L/l transformations, as R is an already existing transformation, that I overlooked while initially adding this.

Now also added a Justification, 'C' to (only) capitalize the first character of every word.
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests