Add support for cleaning individual rooms only
parent
6e6c32bc13
commit
2a9a1f2d0b
|
|
@ -149,10 +149,10 @@
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
"id": "08a86cca-cdc9-4520-af1d-8413a0c274b5",
|
"id": "08a86cca-cdc9-4520-af1d-8413a0c274b5",
|
||||||
"name": "zones",
|
"name": "zone",
|
||||||
"displayName": "Zones to clean",
|
"displayName": "Zones to clean",
|
||||||
"type": "QStringList",
|
"type": "QString",
|
||||||
"defaultValue": []
|
"defaultValue": ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ def setupThing(info):
|
||||||
# If no poll timer is set up yet, start it now
|
# If no poll timer is set up yet, start it now
|
||||||
logger.log("Creating polltimer")
|
logger.log("Creating polltimer")
|
||||||
global pollTimer
|
global pollTimer
|
||||||
if pollTimer is not None:
|
if pollTimer is None:
|
||||||
pollTimer = threading.Timer(5, pollService)
|
pollTimer = threading.Timer(5, pollService)
|
||||||
pollTimer.start()
|
pollTimer.start()
|
||||||
|
|
||||||
|
|
@ -112,7 +112,6 @@ def setupThing(info):
|
||||||
info.finish(nymea.ThingErrorHardwareFailure, "Unable to connect to neato API.")
|
info.finish(nymea.ThingErrorHardwareFailure, "Unable to connect to neato API.")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
logger.log(robot.get_robot_state())
|
|
||||||
info.thing.setStateValue(robotConnectedStateTypeId, True)
|
info.thing.setStateValue(robotConnectedStateTypeId, True)
|
||||||
# set up polling for robot status
|
# set up polling for robot status
|
||||||
info.finish(nymea.ThingErrorNoError)
|
info.finish(nymea.ThingErrorNoError)
|
||||||
|
|
@ -176,16 +175,24 @@ def pollService():
|
||||||
pollTimer.start()
|
pollTimer.start()
|
||||||
|
|
||||||
|
|
||||||
def executeAction(info):
|
def executeAction(info):
|
||||||
# return; # Temporary, to not accidentally start it
|
|
||||||
|
|
||||||
if info.actionTypeId == robotStartCleaningActionTypeId:
|
if info.actionTypeId == robotStartCleaningActionTypeId:
|
||||||
refreshRobot(info.thing)
|
zone = info.paramValue(robotStartCleaningActionZoneParamTypeId)
|
||||||
if info.thing.stateValue(robotRobotStateStateTypeId) == "paused":
|
logger.log("zone", zone)
|
||||||
thingsAndRobots[info.thing].resume_cleaning()
|
|
||||||
|
if zone != "":
|
||||||
|
ids = zone[9:];
|
||||||
|
mapId = ids.split(";")[0]
|
||||||
|
boundaryId = ids.split(";")[1]
|
||||||
|
cleanWithRobot(info.thing, mapId, boundaryId)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# To do: add a parameter to the start action which takes a zone id
|
refreshRobot(info.thing)
|
||||||
cleanWithRobot(info.thing, None, None)
|
if info.thing.stateValue(robotRobotStateStateTypeId) == "paused":
|
||||||
|
thingsAndRobots[info.thing].resume_cleaning()
|
||||||
|
else:
|
||||||
|
cleanWithRobot(info.thing, None, None)
|
||||||
|
|
||||||
refreshRobot(info.thing)
|
refreshRobot(info.thing)
|
||||||
info.finish(nymea.ThingErrorNoError)
|
info.finish(nymea.ThingErrorNoError)
|
||||||
return
|
return
|
||||||
|
|
@ -212,10 +219,11 @@ def executeAction(info):
|
||||||
info.finish(nymea.ThingErrorNoError)
|
info.finish(nymea.ThingErrorNoError)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def cleanWithRobot(robotThing, mapID, boundaryID):
|
def cleanWithRobot(robotThing, mapID, boundaryID):
|
||||||
# To do: add a parameter to the start action which takes a zone id --> this should now be represented by mapID & boundaryID
|
# To do: add a parameter to the start action which takes a zone id --> this should now be represented by mapID & boundaryID
|
||||||
robot = thingsAndRobots[robotThing]
|
robot = thingsAndRobots[robotThing]
|
||||||
logger.log("Cleaning with robot:", robot, robotThing)
|
logger.log("Cleaning with robot:", robot, robotThing, mapID, boundaryID)
|
||||||
boolEco = robotThing.setting(robotSettingsEcoParamTypeId)
|
boolEco = robotThing.setting(robotSettingsEcoParamTypeId)
|
||||||
boolCare = robotThing.setting(robotSettingsCareParamTypeId)
|
boolCare = robotThing.setting(robotSettingsCareParamTypeId)
|
||||||
boolNogo = robotThing.setting(robotSettingsNoGoLinesParamTypeId)
|
boolNogo = robotThing.setting(robotSettingsNoGoLinesParamTypeId)
|
||||||
|
|
@ -233,7 +241,7 @@ def cleanWithRobot(robotThing, mapID, boundaryID):
|
||||||
intNogo = 4
|
intNogo = 4
|
||||||
logger.log("Settings: Eco:", boolEco, "Care:", boolCare, "Enable nogo:", boolNogo, "mapID:", mapID, "boundaryID:", boundaryID)
|
logger.log("Settings: Eco:", boolEco, "Care:", boolCare, "Enable nogo:", boolNogo, "mapID:", mapID, "boundaryID:", boundaryID)
|
||||||
thingsAndRobots[robotThing].start_cleaning(mode=intEco, navigation_mode=intCare, category=intNogo, boundary_id=boundaryID, map_id=mapID)
|
thingsAndRobots[robotThing].start_cleaning(mode=intEco, navigation_mode=intCare, category=intNogo, boundary_id=boundaryID, map_id=mapID)
|
||||||
refreshRobot(robotThing)
|
|
||||||
|
|
||||||
def browseThing(browseResult):
|
def browseThing(browseResult):
|
||||||
robotThing = browseResult.thing
|
robotThing = browseResult.thing
|
||||||
|
|
@ -270,24 +278,34 @@ def browseThing(browseResult):
|
||||||
|
|
||||||
logger.log("boundaries", type(boundaries), boundaries.json())
|
logger.log("boundaries", type(boundaries), boundaries.json())
|
||||||
for boundary in boundaries.json()["data"]["boundaries"]:
|
for boundary in boundaries.json()["data"]["boundaries"]:
|
||||||
# if boundary["type"] == "polygon":
|
if boundary["type"] == "polygon":
|
||||||
logger.log("vertices:", json.dumps(boundary["vertices"]))
|
logger.log("vertices:", boundary)
|
||||||
browseResult.addItem(nymea.BrowserItem(boundary["id"], boundary["name"], json.dumps(boundary), executable=True, disabled=not boundary["enabled"], icon=nymea.BrowserIconFavorites))
|
browseResult.addItem(nymea.BrowserItem("boundary-" + mapId + ";" + boundary["id"], boundary["name"], json.dumps(boundary), executable=True, disabled=not boundary["enabled"], icon=nymea.BrowserIconFavorites))
|
||||||
|
|
||||||
browseResult.finish(nymea.ThingErrorNoError)
|
browseResult.finish(nymea.ThingErrorNoError)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def executeBrowserItem(info):
|
def executeBrowserItem(info):
|
||||||
# TODO: An item in the browser has been clicked.
|
|
||||||
logger.log("Browser item clicked:", info.itemId)
|
logger.log("Browser item clicked:", info.itemId)
|
||||||
logger.log("Parent item:", )
|
if info.itemId.startswith("boundary-"):
|
||||||
# cleanWithRobot(info.thing, mapID, boundaryID)
|
ids = info.itemId[9:];
|
||||||
info.finish(nymea.ThingErrorNoError)
|
logger.log("IDS:", ids)
|
||||||
|
mapId = ids.split(";")[0]
|
||||||
|
boundaryId = ids.split(";")[1]
|
||||||
|
logger.log("Cleaning boundary:", mapId, boundaryId)
|
||||||
|
cleanWithRobot(info.thing, mapId, boundaryId)
|
||||||
|
refreshRobot(info.thing)
|
||||||
|
info.finish(nymea.ThingErrorNoError)
|
||||||
|
return
|
||||||
|
|
||||||
|
logger.warn("Can't execute browser item:", info.itemId)
|
||||||
|
info.finish(nymea.ThingErrorItemNotExecutable)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def deinit():
|
def deinit():
|
||||||
global pollTimer
|
global pollTimer
|
||||||
# If we started a poll timer, cancel it on shutdown.
|
# If we started a poll timer, cancel it on shutdown.
|
||||||
if pollTimer is not None:
|
if pollTimer is not None:
|
||||||
pollTimer.cancel()
|
pollTimer.cancel()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue