no special characters
[munin-heatpump.git] / heatpump-dimplex-wpm_
1 #!/bin/sh
2 # -*- sh -*-
3
4 : << =cut
5
6 =head1 NAME
7
8  heatpump-dimplex-wpm - Munin plugin to display Diplex heatpump data
9
10  Tested with Dimplex NWPM, BIOS 4.1, BOOT 4.03, SOFTWARE: WPM_H_H54
11
12 =head1 CONFIGURATION
13
14  You need to configure the hostname in the plugin name.
15
16  Symlink heatpump-dimplex-wpm_ as "heatpump-dimplex-wpm_192.168.20.71".
17
18 =head2 EXAMPLE CONFIGURATION
19
20  [heatpump-dimplex-wpm_*]
21   env.host_name Heating
22
23 =head1 DEPENDENCIES
24
25  - curl
26  - xsltproc
27
28 =head1 AUTHOR
29
30  Christian Weiske <cweiske@cweiske.de>
31
32 =head1 LICENSE
33
34  AGPL
35  http://www.gnu.org/licenses/agpl.html
36
37 =head1 MAGIC MARKERS
38
39  #%# family=manual
40
41 =cut
42
43 . ${MUNIN_LIBDIR:=/usr/share/munin}/plugins/plugin.sh
44
45 host=`echo ${0##*/}|sed 's/^.*_//g'`
46
47
48 if [ "$1" = "config" ]; then
49     if [ "$host_name" != "" ]; then
50         echo "host_name $host_name"
51     fi
52
53     #Outdoor temperature
54     echo 'multigraph heatpump_dimplex_wpm_outtemp'
55     echo 'graph_title Aussentemperatur'
56     echo 'graph_args --base 1000'
57     echo 'graph_vlabel °C'
58     echo 'graph_info Zeigt die gemessene Außentemperatur an'
59     echo 'graph_scale no'
60     echo 'graph_category sensors'
61
62     echo 'outtemp.label Aussentemperatur'
63     echo 'outtemp.draw LINE1'
64
65     #Heating temperatures
66     echo 'multigraph heatpump_dimplex_wpm_heating'
67     echo 'graph_title Heizungstemperaturen'
68     echo 'graph_args --base 1000'
69     echo 'graph_vlabel °C'
70     echo 'graph_info Zeigt Heizungstemperatur-Betriebsdaten an'
71     echo 'graph_scale no'
72     echo 'graph_category sensors'
73
74     echo 'returntargettemp.label Ruecklaufsolltemperatur'
75     echo 'returntargettemp.draw LINE2'
76     echo 'returntemp.label Ruecklauftemperatur'
77     echo 'returntemp.draw LINE1'
78     echo 'influxtemp.label Vorlauftemperatur'
79     echo 'influxtemp.draw LINE1'
80
81     #Water temperature
82     echo 'multigraph heatpump_dimplex_wpm_water'
83     echo 'graph_title Warmwasser'
84     echo 'graph_args --base 1000'
85     echo 'graph_vlabel °C'
86     echo 'graph_info Zeigt Warmwasser-Betriebsdaten an'
87     echo 'graph_scale no'
88     echo 'graph_category sensors'
89
90     echo 'watertargettemp.label Solltemperatur'
91     echo 'watertargettemp.draw LINE2'
92     echo 'watertemp.label Warmwassertemperatur'
93     echo 'watertemp.draw LINE1'
94
95
96     #On/off states
97     echo 'multigraph heatpump_dimplex_wpm_states'
98     echo 'graph_title Stati'
99     echo 'graph_args --base 1000'
100     echo 'graph_vlabel An/Aus'
101     echo 'graph_info Zeigt binäre Daten an'
102     echo 'graph_scale no'
103     echo 'graph_category sensors'
104
105     echo 'reqheating.label Anforderung Heizung'
106     echo 'reqheating.draw LINE1'
107     echo 'reqwater.label Anforderung Warmwasser'
108     echo 'reqwater.draw LINE1'
109
110     #settings: heating level
111     echo 'multigraph heatpump_dimplex_wpm_heating_level'
112     echo 'graph_title Heizungseinstellung'
113     echo 'graph_args --base 1000 --lower-limit 0 --upper-limit 38'
114     echo 'graph_vlabel Einstellung'
115     echo 'graph_info Shows the heating setting'
116     echo 'graph_scale no'
117     echo 'graph_category settings'
118
119     echo 'circuit1.label Heizkreis 1'
120     echo 'circuit1.draw LINE1'
121
122     #error level
123     echo 'multigraph heatpump_dimplex_wpm_errorlevel'
124     echo 'graph_title Alarme/Fehler'
125     echo 'graph_args --base 1000 --lower-limit 0 --upper-limit 100'
126     echo 'graph_vlabel Fehler'
127     echo 'graph_info Shows the error level'
128     echo 'graph_scale no'
129     echo 'graph_category sensors'
130
131     echo 'errorlevel.label Sammelstoermeldung'
132     echo 'errorlevel.draw LINE1'
133     echo 'errorlevel.critical 0:0'
134
135     exit 0
136 fi
137
138 xml=`curl -fs "http://$host/usr-cgi/xml.cgi?A|1|125|D|1|150|I|1|100"`; ret=$?
139 if [ "$ret" -ne 0 ]; then
140     echo "Error fetching data from heatpump server: $host"
141     exit 1
142 fi
143
144 xslfile=paths.xsl
145 if [ ! -f "$xslfile" ]; then
146     shell="`readlink -f "$0"`"
147     path="`dirname "$shell"`"
148     xslfile="$path/paths.xsl"
149     if [ ! -f "$xslfile" ]; then
150         echo 'Could not find paths.xsl'
151         exit 2
152     fi
153 fi
154
155 data=`echo "$xml" | xsltproc "$xslfile" -`; ret=$?
156 if [ "$ret" -ne 0 ]; then
157     echo 'Error running xsltproc'
158     exit 2
159 fi
160
161 #Outdoor temperature
162 echo 'multigraph heatpump_dimplex_wpm_outtemp'
163 echo outtemp.value `echo "$data" | grep ANALOG/27 | cut -d" " -f2`
164
165 #Heating temperatures
166 echo 'multigraph heatpump_dimplex_wpm_heating'
167 echo returntargettemp.value `echo "$data" | grep ANALOG/28 | cut -d" " -f2`
168 echo returntemp.value `echo "$data" | grep ANALOG/29 | cut -d" " -f2`
169 echo influxtemp.value `echo "$data" | grep ANALOG/31 | cut -d" " -f2`
170
171 #Water temperatures
172 echo 'multigraph heatpump_dimplex_wpm_water'
173 echo watertargettemp.value `echo "$data" | grep ANALOG/40 | cut -d" " -f2`
174 echo watertemp.value `echo "$data" | grep ANALOG/30 | cut -d" " -f2`
175
176 #On/off states
177 echo 'multigraph heatpump_dimplex_wpm_states'
178 echo reqheating.value `echo "$data" | grep DIGITAL/136 | cut -d" " -f2`
179 water=`echo "$data" | grep DIGITAL/140 | cut -d" " -f2`
180 echo reqwater.value `echo $(($water * 2))`
181
182 #Settings: Heating level
183 echo 'multigraph heatpump_dimplex_wpm_heating_level'
184 echo circuit1.value `echo "$data" | grep 'INTEGER/1 ' | cut -d" " -f2`
185
186 #Error level
187 #docs: 8,Analog,Ausgang,Sammelstörmeldung
188 echo 'multigraph heatpump_dimplex_wpm_heating_level'
189 echo errorlevel.value `echo "$data" | grep 'ANALOG/8 ' | cut -d" " -f2`