Hauptmenü

[gelöst] im notify runden

Begonnen von franky08, 14 März 2015, 10:18:25

Vorheriges Thema - Nächstes Thema

franky08

Hallo, wie im Betreff geschrieben, versuche ich einen Wert der über F2F von einem Raspi kommt, zu runden.
notify:
Sensor_Strom:hour.* {fhem("setreading Strom_day_dummy state $EVTPART1")}

liefert über F2F vom Raspi:
0.186666666666667
Das würde ich gerne runden:
int(100 * $EVTPART1 + 0.5) / 100

Leider scheint das direkt im notify nicht zu funktionieren.

VG
Frank

Debian Bookworm auf HUNSN / Debian Bullseye auf 2.ter HUNSN F2F an 2x RaspiB
mit FHEM aktuell
22Zoll ViewSonic als Infodislay (WVC)
3xHMLAN mit vccu, raspmatic_rpi3, HMIP-HCU1

betateilchen

Wieviele Stellen nach dem Komma hättest Du denn gerne?

Sensor_Strom:hour.* {my $v = round($EVTPART1,2);; fhem("setreading Strom_day_dummy state $v")}

Rundet auf zwei Stellen nach dem Komma.

Aber mal ehrlich - das sind doch simpelste Basics von perl und fhem, oder?
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

franky08

Ja, so ähnlich hatte ich das auch aber wurde mit einer Fehlermeldung "my unknown... " quittiert. Mittlerweile hatte ich es in eine sub ausgelagert und von da aus hat es auch funktioniert.

Danke und schönes WE

Frank
Debian Bookworm auf HUNSN / Debian Bullseye auf 2.ter HUNSN F2F an 2x RaspiB
mit FHEM aktuell
22Zoll ViewSonic als Infodislay (WVC)
3xHMLAN mit vccu, raspmatic_rpi3, HMIP-HCU1

franky08

Hallo betateilchen
Habe das von dir mal getestet
ZitatSensor_Strom:hour.* {my $v = round($EVTPART1,2);; fhem("setreading Strom_day_dummy state $v")}

bringt leider eine Fehlermeldung:
Strom_read_RASPI return value: Undefined subroutine &main::round called at (eval 1716565) line 1.


VG
Frank
Debian Bookworm auf HUNSN / Debian Bullseye auf 2.ter HUNSN F2F an 2x RaspiB
mit FHEM aktuell
22Zoll ViewSonic als Infodislay (WVC)
3xHMLAN mit vccu, raspmatic_rpi3, HMIP-HCU1

betateilchen

Dann ist Dein fhem (genauer: die Datei 99_Utils.pm) nicht auf dem aktuellen Stand.
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

franky08

Debian Bookworm auf HUNSN / Debian Bullseye auf 2.ter HUNSN F2F an 2x RaspiB
mit FHEM aktuell
22Zoll ViewSonic als Infodislay (WVC)
3xHMLAN mit vccu, raspmatic_rpi3, HMIP-HCU1