Ankündigung

Einklappen
Keine Ankündigung bisher.

Random() always gives same value

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Random() always gives same value

    Hi,

    I am applying EibPC to automatically control my rollos.
    They go down 30min after sunset and should go up randomly between 8.30 and 9am per following statement:
    "if htime(8,convert(random(29u32),0)+30,00) and RolloAutomation then write("Alle rolluiken lange druk-3/1/20",RAUF) endif"

    However, this results in Rollos going up always at the same time:

    12/10/2010 8:56 EibPC "Alle rolluiken lange druk-3/1/20" Binärwert OFF Writing bc 00 00 19 14 e1 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    13/10/2010 8:56 EibPC "Alle rolluiken lange druk-3/1/20" Binärwert OFF Writing bc 00 00 19 14 e1 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    14/10/2010 8:56 EibPC "Alle rolluiken lange druk-3/1/20" Binärwert OFF Writing bc 00 00 19 14 e1 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    15/10/2010 8:56 EibPC "Alle rolluiken lange druk-3/1/20" Binärwert OFF Writing bc 00 00 19 14 e1 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

    After a restart the calculated random time seems to differ, but is again fixed till next restart.
    What is wrong with the random() function or with my implementation?

    Thanks for your help.

    Sammy

    #2
    Zitat von martenss Beitrag anzeigen
    Hi,
    However, this results in Rollos going up always at the same time:
    After a restart the calculated random time seems to differ, but is again fixed till next restart.
    What is wrong with the random() function or with my implementation?
    Sammy
    Random itself is calculation it's value only at start of system, as you've observed it.

    To get a random number each day you can code

    [highlight=epc]
    // Init with a random value
    Random=convert(random(29u32),0)
    // Dayly re-calculate a random value
    if htime(0,0,0) then Random=convert(random(29u32),0) endif
    if htime(8,Random+30,00) and RolloAutomation then write("Alle rolluiken lange druk-3/1/20",RAUF) endif
    [/highlight]
    offizielles Supportforum für den Enertex® EibPC: https://knx-user-forum.de/eibpc/
    Enertex Produkte kaufen

    Kommentar

    Lädt...
    X