check_mk-fhem.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. # PNP4Nagios template for check_fhem FHEM check
  3. # Author: Jonas Nickl <kontakt@jonasnickl.de>
  4. #$defopt = "--vertical-label 'Bytes' -l0 -b 1024 ".
  5. $defopt = "--color MGRID\"#cccccc\" --color GRID\"#dddddd\" ";
  6. #$def[] = "";
  7. #$opt[] = "";
  8. # Work with names rather then numbers.
  9. global $fhem_defines;
  10. $fhem_defines = array();
  11. foreach ($NAME as $i => $n) {
  12. $fhem_defines[$n] = "DEF:$n=$RRDFILE[$i]:$DS[$i]:MAX ";
  13. }
  14. # avoid redeclaration errors if this file is include multiple times (e.g. by basket)
  15. if (!function_exists('fhem_area')) {
  16. function fhem_area($varname, $color, $title, $unit, $stacked)
  17. {
  18. return fhem_curve("AREA", $varname, $color, $title, $unit, $stacked);
  19. }
  20. function fhem_line($varname, $color, $title, $unit, $stacked)
  21. {
  22. return fhem_curve("LINE1", $varname, $color, $title, $unit, $stacked);
  23. }
  24. function fhem_curve($how, $varname, $color, $title, $unit, $stacked)
  25. {
  26. global $fhem_defines;
  27. $tit = sprintf("%-30s", $title);
  28. if (isset($fhem_defines[$varname])) {
  29. $x = $fhem_defines[$varname] . "$how:$varname#$color:\"$tit\"";
  30. if ($stacked)
  31. $x .= ":STACK";
  32. $x .= " ";
  33. # $x .= "CDEF:${varname}_gb=$varname,1073741824,/ ";
  34. $x .= "GPRINT:${varname}:LAST:\"%6.1lf ${unit} last\" ";
  35. $x .= "GPRINT:${varname}:AVERAGE:\"%6.1lf ${unit} avg\" ";
  36. $x .= "GPRINT:${varname}:MAX:\"%6.1lf ${unit} max\\n\" ";
  37. return $x;
  38. }
  39. else {
  40. return "";
  41. }
  42. }
  43. }
  44. # 1. Overview
  45. if (isset($fhem_defines['temperature']) && isset($fhem_defines['humidity']) ) {
  46. $ds_name[] = 'temperature';
  47. $opt[] = $defopt . "--title \"Temperature + Humidity\"";
  48. $def[] = ""
  49. . fhem_area("humidity", "00bfff", "Humidity", "%% ", FALSE)
  50. . fhem_area("temperature", "80ff40", "Temperature", "°C", FALSE)
  51. . fhem_line("desiredtemp", "408f20", "Desired temp", "°C", FALSE)
  52. . fhem_area("dewpoint", "B40404", "Dewpoint", "°C", FALSE)
  53. . fhem_line("valveposition", "00bfff", "Valve position", "%% ", FALSE)
  54. ;
  55. }
  56. # 2. Temperature
  57. if (isset($fhem_defines['temperature']) or isset($fhem_defines['moisture'])) {
  58. $ds_name[] = 'temperature';
  59. $opt[] = $defopt . "--title \"Temperature\"";
  60. $def[] = ""
  61. . fhem_area("temperature", "80ff40", "Temperature", "°C", FALSE)
  62. . fhem_line("desiredtemp", "408f20", "Desired temp", "°C", FALSE)
  63. . fhem_area("dewpoint", "B40404", "Dewpoint", "°C", FALSE)
  64. . fhem_line("valveposition", "00bfff", "Valve position", "%% ", FALSE)
  65. ## XiaomiFlowerSens
  66. . fhem_curve("LINE2", "moisture", "00bfff", "moisture", "%%", FALSE)
  67. ;
  68. }
  69. ## 2. Valveposition
  70. #if (isset($fhem_defines['valveposition']) ) {
  71. # $opt[] = $defopt . "--title \"Valveposition\"";
  72. # $def[] = ""
  73. # . fhem_area("temperature", "80ff40", "Temperature", "°C", FALSE)
  74. # . fhem_area("desiredtemp", "408f20", "Desired temp", "°C", FALSE)
  75. # . fhem_line("valveposition", "00bfff", "Valve Position", "%% ", FALSE)
  76. # ;
  77. #}
  78. # 3. BatteryLevel
  79. if (isset($fhem_defines['batteryLevel']) ) {
  80. $ds_name[] = 'batteryLevel';
  81. $opt[] = $defopt . "--title \"batteryLevel\"";
  82. $def[] = ""
  83. . fhem_area("batteryLevel", "e0e0e0", "Battery Level", "V", FALSE)
  84. ;
  85. }
  86. # 4. Power (kWh)
  87. if (isset($fhem_defines['power']) ) {
  88. $ds_name[] = 'power';
  89. $opt[] = $defopt . "--title \"Power\"";
  90. $def[] = ""
  91. . fhem_area("power", "e0e0e0", "Power", "kWh", FALSE)
  92. # . fhem_area("dewpoint", "80ff40", "", FALSE)
  93. # . fhem_area("swap_used", "408f20", "", TRUE)
  94. ;
  95. }
  96. # 5. Brightness
  97. if (isset($fhem_defines['brightness']) ) {
  98. $ds_name[] = 'brightness';
  99. $opt[] = $defopt . "--title \"Brightness\"";
  100. $def[] = ""
  101. . fhem_area("brightness", "ffb90f", "Brightness", "%%", FALSE)
  102. . fhem_line("brightness_on","551a8b", "Brightness_on", "%%", FALSE)
  103. ;
  104. }
  105. # 6. Color temperature (ct)
  106. if (isset($fhem_defines['ct']) ) {
  107. $ds_name[] = 'ct';
  108. $opt[] = $defopt . "--title \"Color temperature (ct)\"";
  109. $def[] = ""
  110. . fhem_curve("LINE2", "ct", "ff4500", "Color temperature (ct)", "K", FALSE)
  111. ;
  112. }
  113. # 7. Speedtest (down-/upload)
  114. if (isset($fhem_defines['download']) ) {
  115. $ds_name[] = 'speedtest';
  116. $opt[] = $defopt . "--title \"Speedtest\"";
  117. $def[] = ""
  118. . fhem_area("download", "00ffc0", "Download", "Mbit/s", FALSE)
  119. . fhem_area("upload", "00c0ff", "Upload", "Mbit/s", FALSE)
  120. ;
  121. }
  122. # 8. Speedtest (ping)
  123. if (isset($fhem_defines['ping']) ) {
  124. $ds_name[] = 'speedtest_ping';
  125. $opt[] = $defopt . "--title \"Speedtest Ping\"";
  126. $def[] = ""
  127. . fhem_area("ping", "2b85c8", "Ping", "ms", FALSE)
  128. ;
  129. }
  130. # 9. Traffic (duration)
  131. if (isset($fhem_defines['duration']) ) {
  132. $ds_name[] = 'duration';
  133. $opt[] = $defopt . "--title \"Traffic duration\"";
  134. $def[] = ""
  135. . fhem_area("duration", "00bfff", "Duration", "min", FALSE)
  136. . fhem_area("delay", "f78181", "Delay", "min", TRUE)
  137. . fhem_curve("LINE2", "duration_in_traffic", "B40404", "Duration in traffic", "min", FALSE)
  138. ;
  139. }
  140. # 9. Traffic (duration)
  141. if (isset($fhem_defines['presence']) ) {
  142. $ds_name[] = 'presence';
  143. $opt[] = $defopt . "--title \"Presence\"";
  144. $def[] = ""
  145. . fhem_area("presence", "00bfff", "Presence", "", FALSE)
  146. ;
  147. }
  148. # 10. LUXTRONIK2 (ambientTemperature)
  149. if (isset($fhem_defines['ambientTemperature']) ) {
  150. $ds_name[] = 'ambientTemperature';
  151. $opt[] = $defopt . "--title \"Ambient temperature\"";
  152. $def[] = ""
  153. . fhem_area("ambientTemperature", "80ff40", "ambientTemperature", "°C", FALSE)
  154. . fhem_curve("LINE2", "averageAmbientTemperature", "408f20", "averageAmbientTemperature", "°C", FALSE)
  155. ;
  156. }
  157. # 11. LUXTRONIK2 (hotWaterTemperature)
  158. if (isset($fhem_defines['hotWaterTemperature']) ) {
  159. $ds_name[] = 'hotWaterTemperature';
  160. $opt[] = $defopt . "--title \"hot wasser temperature\"";
  161. $def[] = ""
  162. . fhem_area("hotWaterTemperature", "00bfff", "hotWaterTemperature", "°C", FALSE)
  163. . fhem_curve("LINE2", "hotWaterTemperatureTarget","00008B", "hotWaterTemperatureTarget", "°C", FALSE)
  164. ;
  165. }
  166. # 12. LUXTRONIK2 (returnTemperature)
  167. if (isset($fhem_defines['returnTemperature']) ) {
  168. $ds_name[] = 'returnTemperature';
  169. $opt[] = $defopt . "--title \"return temperature + flow temperature\"";
  170. $def[] = ""
  171. . fhem_area("returnTemperature", "ffd700", "returnTemperature", "°C", FALSE)
  172. . fhem_curve("LINE2", "flowTemperature", "00bfff", "flowTemperature", "°C", FALSE)
  173. . fhem_curve("LINE2", "returnTemperatureTarget","ee0000", "returnTemperatureTarget", "°C", FALSE)
  174. ;
  175. }
  176. # 13. LUXTRONIK2 (counterHoursHeatPump)
  177. if (isset($fhem_defines['counterHoursHeatPump']) ) {
  178. $ds_name[] = 'counterHoursHeatPump';
  179. $opt[] = $defopt . "--title \"counter Hours Heating\"";
  180. $def[] = ""
  181. . fhem_area("counterHoursHeatPump", "00EE76", "counterHoursHeatPump", "h", FALSE)
  182. # . fhem_curve("LINE2", "counterHoursHeating", "00bfff", "counterHoursHeating", "h", FALSE)
  183. # . fhem_area("counterHoursHotWater","ee0000", "counterHoursHotWater", "h", FALSE)
  184. # . fhem_curve("LINE3", "counterHoursHeating", "00bfff", "counterHoursHeating", "h", FALSE)
  185. ;
  186. }
  187. # 14. LUXTRONIK2 (counterHoursHeating)
  188. if (isset($fhem_defines['counterHoursHeating']) or isset($fhem_defines['counterHoursHotWater'])) {
  189. $ds_name[] = 'counterHoursHeating';
  190. $opt[] = $defopt . "--title \"counterHoursHotWater + counterHoursHeating\"";
  191. $def[] = ""
  192. . fhem_area("counterHoursHotWater","ffd700", "counterHoursHotWater", "h", FALSE)
  193. . fhem_area("counterHoursHeating", "ee0000", "counterHoursHeating", "h", FALSE)
  194. ;
  195. }
  196. # 15. XiaomiFlowerSens (fertility)
  197. if (isset($fhem_defines['fertility']) or isset($fhem_defines['lux'])) {
  198. $ds_name[] = '';
  199. $opt[] = $defopt . "--title \"fertility\"";
  200. $def[] = ""
  201. . fhem_area("fertility","ffd700", "fertility", "", FALSE)
  202. . fhem_curve("LINE2", "lux", "ee0000", "lux", "lx", FALSE)
  203. . fhem_curve("LINE2", "moisture", "00bfff", "moisture", "%%", FALSE)
  204. ;
  205. }
  206. ?>