Fixed robot not shown before setting up a floor plan
This commit is contained in:
parent
9af5fe8a26
commit
6e5b0d522c
@ -110,4 +110,7 @@
|
||||
* Added logic to be able to change the currently cleaned room
|
||||
* Improved number of requests when having multiple rooms
|
||||
* Fixed room switches not taking eco and extraCare mode into account
|
||||
* Fixed room switches to support pause/resume
|
||||
* Fixed room switches not supporting pause/resume
|
||||
|
||||
## 0.7.1
|
||||
* Fixed robot not shown before setting up a floor plan
|
54
index.js
54
index.js
@ -116,7 +116,7 @@ NeatoVacuumRobotPlatform.prototype = {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get robots
|
||||
// Get all robots
|
||||
client.getRobots((error, robots) =>
|
||||
{
|
||||
if (error)
|
||||
@ -133,11 +133,11 @@ NeatoVacuumRobotPlatform.prototype = {
|
||||
else
|
||||
{
|
||||
debug("Found " + robots.length + " robots");
|
||||
let requestedRobot = 0;
|
||||
let loadedRobots = 0;
|
||||
|
||||
robots.forEach((robot) =>
|
||||
{
|
||||
// Get Maps for each robot
|
||||
// Get all maps for each robot
|
||||
robot.getPersistentMaps((error, result) =>
|
||||
{
|
||||
if (error)
|
||||
@ -145,18 +145,20 @@ NeatoVacuumRobotPlatform.prototype = {
|
||||
this.log.error("Error updating persistent maps: " + error + ": " + result);
|
||||
callback();
|
||||
}
|
||||
// Robot has no maps
|
||||
else if (result.length === 0)
|
||||
{
|
||||
robot.maps = [];
|
||||
callback();
|
||||
this.saveRobot(robot, loadedRobots, robots.length, callback);
|
||||
}
|
||||
// Robot has maps
|
||||
else
|
||||
{
|
||||
robot.maps = result;
|
||||
let requestedMap = 0;
|
||||
let loadedMaps = 0;
|
||||
robot.maps.forEach((map) =>
|
||||
{
|
||||
// Get Map Boundary Lines
|
||||
// Save zones in each map
|
||||
robot.getMapBoundaries(map.id, (error, result) =>
|
||||
{
|
||||
if (error)
|
||||
@ -167,12 +169,27 @@ NeatoVacuumRobotPlatform.prototype = {
|
||||
{
|
||||
map.boundaries = result.boundaries;
|
||||
}
|
||||
requestedMap++;
|
||||
loadedMaps++;
|
||||
|
||||
// Robot is completely requested if all maps are requested
|
||||
if (requestedMap === robot.maps.length)
|
||||
// Robot is completely requested if zones for all maps are loaded
|
||||
if (loadedMaps === robot.maps.length)
|
||||
{
|
||||
// Get additional information
|
||||
this.saveRobot(robot, loadedRobots, robots.length, callback);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
saveRobot: function (robot, loadedRobots, size, callback)
|
||||
{
|
||||
// Get additional information for the robot
|
||||
robot.getState((error, result) =>
|
||||
{
|
||||
if (error)
|
||||
@ -182,26 +199,17 @@ NeatoVacuumRobotPlatform.prototype = {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Store the robot with his information, maps and zones
|
||||
this.robots.push({device: robot, meta: result.meta, availableServices: result.availableServices});
|
||||
requestedRobot++;
|
||||
loadedRobots++;
|
||||
|
||||
// Initial request is complete if all robots are requested.
|
||||
if (requestedRobot === robots.length)
|
||||
// Initial request is complete if all robots are loaded.
|
||||
if (loadedRobots === size)
|
||||
{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
updateRobot: function (serial, callback)
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "homebridge-neato",
|
||||
"version": "0.7.0",
|
||||
"version": "0.7.1-beta.1",
|
||||
"description": "A Neato vacuum robot plugin for homebridge.",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
Loading…
Reference in New Issue
Block a user