From 916907cd9f98cd124a94c51b11386c699b652b7c Mon Sep 17 00:00:00 2001 From: "Michael J.M. Wagner" Date: Mon, 7 Mar 2022 14:00:59 +0100 Subject: [PATCH] posaune --- Turf/perl/99_myUtils.pm | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Turf/perl/99_myUtils.pm diff --git a/Turf/perl/99_myUtils.pm b/Turf/perl/99_myUtils.pm new file mode 100644 index 0000000..dea0926 --- /dev/null +++ b/Turf/perl/99_myUtils.pm @@ -0,0 +1,38 @@ +############################################## +# $Id: myUtilsTemplate.pm 7570 2015-01-14 18:31:44Z rudolfkoenig $ +# +# Save this file as 99_myUtils.pm, and create your own functions in the new +# file. They are then available in every Perl expression. + +package main; + +use strict; +use warnings; +use POSIX; + +sub +myUtils_Initialize($$) +{ + my ($hash) = @_; +} + +# Enter you functions below _this_ line. + +sub write_temp_knx { + my $temp = ReadingsVal("Aussentemperatur","temperature",10); + my $m; + my $b0; + if ( $temp < 0) { + # negative temperture + $m = ~int($temp * (-100) / 16); + $b0 = "a7"; + } else { + $m = int($temp * 100 / 16); + $b0 = "20"; + } + my $b1 = substr(sprintf("%X", $m), -2); + my $cmd = "groupwrite ip:127.0.0.1 3/0/1 $b0 $b1"; + #print("$temp\n"); + #print("$cmd\n"); + system($cmd); +} -- 2.20.1