]> wagnertech.de Git - xhome.git/blob - Turf/perl/99_myUtils.pm
posaune
[xhome.git] / Turf / perl / 99_myUtils.pm
1 ##############################################
2 # $Id: myUtilsTemplate.pm 7570 2015-01-14 18:31:44Z rudolfkoenig $
3 #
4 # Save this file as 99_myUtils.pm, and create your own functions in the new
5 # file. They are then available in every Perl expression.
6
7 package main;
8
9 use strict;
10 use warnings;
11 use POSIX;
12
13 sub
14 myUtils_Initialize($$)
15 {
16   my ($hash) = @_;
17 }
18
19 # Enter you functions below _this_ line.
20
21 sub write_temp_knx {
22   my $temp = ReadingsVal("Aussentemperatur","temperature",10);
23   my $m;
24   my $b0;
25   if ( $temp < 0) {
26     # negative temperture
27     $m = ~int($temp * (-100) / 16);
28     $b0 = "a7";
29   } else {
30     $m = int($temp * 100 / 16);
31     $b0 = "20";
32   }
33   my $b1 = substr(sprintf("%X", $m), -2);
34   my $cmd = "groupwrite ip:127.0.0.1 3/0/1 $b0 $b1";
35   #print("$temp\n");
36   #print("$cmd\n");
37   system($cmd);
38 }