fix: Detect device type changes and update #5271 (#5390)

This commit is contained in:
Neil Lathwood
2017-01-11 16:36:04 +00:00
committed by Tony Murray
parent 0f4263bdb4
commit 569a3b4a8b
2 changed files with 8 additions and 1 deletions

View File

@@ -162,7 +162,7 @@ function discover_device($device, $options = null)
$device_run = ($device_end - $device_start);
$device_time = substr($device_run, 0, 5);
dbUpdate(array('last_discovered' => array('NOW()'), 'type' => $device['type'], 'last_discovered_timetaken' => $device_time), 'devices', '`device_id` = ?', array($device['device_id']));
dbUpdate(array('last_discovered' => array('NOW()'), 'last_discovered_timetaken' => $device_time), 'devices', '`device_id` = ?', array($device['device_id']));
echo "Discovered in $device_time seconds\n";

View File

@@ -15,3 +15,10 @@ if ($icon != $device['icon']) {
$sql = dbUpdate(array('icon' => $icon), 'devices', 'device_id=?', array($device['device_id']));
echo "Changed Icon! : $icon\n";
}
if ($config['os'][$device['os']]['type'] != $device['type']) {
log_event('Device type changed '.$device['type'].' => '.$config['os'][$device['os']]['type'], $device, 'system');
$device['type'] = $config['os'][$device['os']]['type'];
$sql = dbUpdate(array('type' => $device['type']), 'devices', 'device_id=?', array($device['device_id']));
echo "Changed Type! : ".$device['type'].PHP_EOL;
}