Random (pseudoRandom) needed

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
quajetson
New user
Posts: 7
Joined: 28 Nov 2018, 17:33

Random (pseudoRandom) needed

#1 Post by quajetson » 28 Nov 2018, 17:37

Any options to get random value in Rules?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Random (pseudoRandom) needed

#2 Post by grovkillen » 28 Nov 2018, 20:07

Nothing right now. Could you please fill me in on your use case that makes you want a randomized value?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

quajetson
New user
Posts: 7
Joined: 28 Nov 2018, 17:33

Re: Random (pseudoRandom) needed

#3 Post by quajetson » 01 Dec 2018, 12:49

I need randomly play mp3 on trigger.

quajetson
New user
Posts: 7
Joined: 28 Nov 2018, 17:33

Re: Random (pseudoRandom) needed

#4 Post by quajetson » 01 Dec 2018, 12:53

I'm doing speaking head
https://www.youtube.com/watch?v=Y4ojtVn9f58
but playing always hard programmed mp3 sequence is not funny.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Random (pseudoRandom) needed

#5 Post by grovkillen » 01 Dec 2018, 13:16

Ok, makes sense. Please open a feature request on GitHub.

Suggested command:

Code: Select all

Random,<lower>,<upper>
Where <lower> is the lowest randomized value and <upper> it the highest randomized value wanted.

And possibly also able to store to internal value like this:

Code: Select all

Random,<lower>,<upper>,<store 1..16>
And you the will be able to use it with %v1% ... %v16%
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Random (pseudoRandom) needed

#6 Post by enesbcs » 01 Dec 2018, 16:26

quajetson wrote: 01 Dec 2018, 12:49 I need randomly play mp3 on trigger.
Is this trigger time based?
If not, i suggest an ugly temporary workaround:

Seconds based fake-random if NTP enabled:
((%syssec%/59)*(upper-lower))+lower

For example the following will give a number between 1 and 17:
((%syssec%/59)*16)+1

The result can be stored in a Dummy variable device with Taskvalueset, and also on the Dummy device page, you can care about digits.
taskvalueset,1,1,(((%syssec%/59)*16)+1)

I think it also can be combined with %rssi%, %sysload% and %sysheap% to be "random"-like but i am lazy to implement. :)

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Random (pseudoRandom) needed

#7 Post by grovkillen » 01 Dec 2018, 19:31

That's a nice try and would perhaps work in some cases :)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

quajetson
New user
Posts: 7
Joined: 28 Nov 2018, 17:33

Re: Random (pseudoRandom) needed

#8 Post by quajetson » 03 Dec 2018, 10:51

Solved with Dummy device and increment his value with 1 second timer:)
So this is not random but make step needded to play various mp3 or do other actions different way:)

quajetson
New user
Posts: 7
Joined: 28 Nov 2018, 17:33

Re: Random (pseudoRandom) needed

#9 Post by quajetson » 03 Dec 2018, 10:54

Thanks enesbcs, Your solution is helpfull too:)

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests