Autor Thema: myAverage function throws error: Experimental aliasing via reference not enabled  (Gelesen 1289 mal)

Offline @lex99

  • New Member
  • *
  • Beiträge: 15
Hi,

I'm trying to use the function myAverage (from the Wiki).

Upon typing this:

define KS300_W_notify notify KS300:wind.* {\
  my $avg = myAverage("10800", "FileLog_KS300", "8:::");;\
  my $event = sprintf("Wc: %0.1f Wd: %0.1f Wm: %0.1f Wlh: %0.1f", ReadingsVal("KS300","wind","0"), ReadingsVal("KS300", "W_avg_day","0"), ReadingsVal("KS300","W_avg_month","0"), $avg);;\
  Log 2, ("K300_W: Event: $event");;\
  fhem("trigger KS300_W data: $event");;\
  fhem("trigger KS300 average-wind: $avg");;\
 }

I get: Experimental aliasing via reference not enabled

Can a Perl expert help here ?

Thanks !

Offline rudolfkoenig

  • Administrator
  • Hero Member
  • *****
  • Beiträge: 25413
Zitat
Upon typing this:
What exactly do you mean by "typing"?
I get no message at all, when I'm typing that :)
What is your perl version?

Offline herrmannj

  • Global Moderator
  • Hero Member
  • ****
  • Beiträge: 6129
the backslashes throw that error
smartVisu mit fronthem, einiges an HM, RFXTRX, Oregon, CUL, Homeeasy, ganz viele LED + Diverse

Offline @lex99

  • New Member
  • *
  • Beiträge: 15
I have Perl 5.24.1

Offline @lex99

  • New Member
  • *
  • Beiträge: 15
the backslashes throw that error

OK, thanks - it works in a single line.  Best to modify in the wiki then to avoid confusion.

Should I upgrade my Perl to the latest one ?  Via Perlbrew ?

Offline herrmannj

  • Global Moderator
  • Hero Member
  • ****
  • Beiträge: 6129
Works but not that easy. Either via os upgrade or let it go, unless you know how to do it via perlbrew. Fhem usually runs with the user fhem
smartVisu mit fronthem, einiges an HM, RFXTRX, Oregon, CUL, Homeeasy, ganz viele LED + Diverse

Offline Beta-User

  • Developer
  • Hero Member
  • ****
  • Beiträge: 18405
Best to modify in the wiki then to avoid confusion.
...not sure about that..

You are referring to the notify at the end of https://wiki.fhem.de/wiki/Gleitende_Mittelwerte_berechnen_und_loggen#Funktion_myAverage.28.29_aufrufen_und_nutzen?

The format shown there is the "RAW"-Format as explained in https://wiki.fhem.de/wiki/Import_von_Code_Snippets. You will find that kind of notation throughout the entire Wiki, so it's not possible to eleminate that completely despite the fact it might be possible in this single case.

Note: there had been some "use POSIX;"-lines in the shown code in the wiki. Please delete these also in your code.
Server: HP-T620@Debian 11, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files