diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index ddd16f0937..25dd9b618a 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -770,6 +770,30 @@ function avtech_add_sensor($device, $sensor) { $type = $sensor['type'] ? $sensor['type'] : 'temperature'; d_echo('Sensor type: ' . $type . "\n"); + if ($type == 'switch') { + // set up state sensor + $type = 'state'; + $state_name = 'avtachSwitchState'; + $state_index_id = create_state_index($state_name); + + //Create State Translation + if ($state_index_id) { + $states = array( + array($state_index_id,'off',0,0,-1), + array($state_index_id,'on',0,1,0), + ); + foreach($states as $value){ + $insert = array( + 'state_index_id' => $value[0], + 'state_descr' => $value[1], + 'state_draw_graph' => $value[2], + 'state_value' => $value[3], + 'state_generic_value' => $value[4] + ); + dbInsert($insert, 'state_translations'); + } + } + } // set the description if ($sensor['descr_oid']) { @@ -814,6 +838,11 @@ function avtech_add_sensor($device, $sensor) { // add the sensor discover_sensor($valid['sensor'], $type, $device, $oid, $id, $device['os'], $descr, $divisor, '1', $min, null, null, $max, $value/$divisor); + + if ($type == 'state') { + create_sensor_to_state_index($device, $state_name, $index); + } + return true; } diff --git a/includes/discovery/sensors/states/avtech.inc.php b/includes/discovery/sensors/states/avtech.inc.php new file mode 100644 index 0000000000..3dd0d1daa1 --- /dev/null +++ b/includes/discovery/sensors/states/avtech.inc.php @@ -0,0 +1,18 @@ + 2, + 'type' => 'switch', + 'oid' => $device_oid.'1.2.1.0', + 'descr_oid' => $device_oid.'1.2.2.0', + ); + avtech_add_sensor($device, $switch); + } +} diff --git a/includes/discovery/sensors/temperatures/avtech.inc.php b/includes/discovery/sensors/temperatures/avtech.inc.php index 7bc85361f5..f093d104fa 100644 --- a/includes/discovery/sensors/temperatures/avtech.inc.php +++ b/includes/discovery/sensors/temperatures/avtech.inc.php @@ -1,6 +1,6 @@ $device_oid.'1.1.2.6.0', ); avtech_add_sensor($device, $sen1); - -// $switch = array( -// 'id' => 2, -// 'type' => 'state', -// 'oid' => $device_oid.'1.2.1.0', -// 'descr_oid' => $device_oid.'1.2.2.0', -// ); -// avtech_add_sensor($device, $switch); } elseif (strpos($device['sysObjectID'], '.20916.1.1') !== false) { // TemPageR 4E