align actions with cleaning robot interface & use settings when cleaning
parent
a5bf3238c3
commit
6e6c32bc13
|
|
@ -16,6 +16,9 @@
|
||||||
"createMethods": ["User"],
|
"createMethods": ["User"],
|
||||||
"interfaces": ["account"],
|
"interfaces": ["account"],
|
||||||
"setupMethod": "oauth",
|
"setupMethod": "oauth",
|
||||||
|
"settingsTypes": [
|
||||||
|
|
||||||
|
],
|
||||||
"stateTypes":[
|
"stateTypes":[
|
||||||
{
|
{
|
||||||
"id": "e8f47781-e3fd-416f-a9ac-51ef942d0573",
|
"id": "e8f47781-e3fd-416f-a9ac-51ef942d0573",
|
||||||
|
|
@ -36,11 +39,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"actionTypes": [
|
"actionTypes": [
|
||||||
{
|
|
||||||
"id": "a4b5f07f-e71a-4c3a-8d6b-50162a455159",
|
|
||||||
"name": "getMaps",
|
|
||||||
"displayName": "Get available maps"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -99,13 +98,21 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "dce4f7f3-a0a6-46bb-9216-c9089d9e9b0d",
|
"id": "dce4f7f3-a0a6-46bb-9216-c9089d9e9b0d",
|
||||||
"name": "state",
|
"name": "robotState",
|
||||||
"displayName": "Cleaning state",
|
"displayName": "Cleaning state",
|
||||||
"displayNameEvent": "Cleaning state changed",
|
"displayNameEvent": "Cleaning state changed",
|
||||||
"type": "QString",
|
"type": "QString",
|
||||||
"possibleValues": ["docked", "cleaning", "paused", "traveling", "stopped", "error"],
|
"possibleValues": ["docked", "cleaning", "paused", "traveling", "stopped", "error"],
|
||||||
"defaultValue": "docked"
|
"defaultValue": "docked"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "cb22b48c-1c21-4d52-bde6-847287435685",
|
||||||
|
"name": "errorMessage",
|
||||||
|
"displayName": "Error message",
|
||||||
|
"displayNameEvent": "Error message changes",
|
||||||
|
"type": "QString",
|
||||||
|
"defaultValue": "no error"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "1b8abd35-8276-44ba-8c75-a647877b2e11",
|
"id": "1b8abd35-8276-44ba-8c75-a647877b2e11",
|
||||||
"name": "charging",
|
"name": "charging",
|
||||||
|
|
@ -170,6 +177,3 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,16 +139,27 @@ def refreshRobot(thing):
|
||||||
rbtStartAv = rbtStateCommands['start']
|
rbtStartAv = rbtStateCommands['start']
|
||||||
rbtPauseAv = rbtStateCommands['pause']
|
rbtPauseAv = rbtStateCommands['pause']
|
||||||
rbtResumeAv = rbtStateCommands['resume']
|
rbtResumeAv = rbtStateCommands['resume']
|
||||||
if rbtStateDetails['isDocked'] == True:
|
if rbtStateJson['error'] == None:
|
||||||
thing.setStateValue(robotStateStateTypeId, "docked")
|
rbtError = "no error"
|
||||||
elif rbtPauseAv == True:
|
|
||||||
thing.setStateValue(robotStateStateTypeId, "cleaning")
|
|
||||||
elif rbtResumeAv == True:
|
|
||||||
thing.setStateValue(robotStateStateTypeId, "paused")
|
|
||||||
elif rbtStartAv == True:
|
|
||||||
thing.setStateValue(robotStateStateTypeId, "stopped")
|
|
||||||
else:
|
else:
|
||||||
thing.setStateValue(robotStateStateTypeId, "error")
|
rbtError = rbtStateJson['error']
|
||||||
|
# alert state hasn't been implemented yet (not sure what would trigger an alert, haven't seen one yet)
|
||||||
|
if rbtStateJson['alert'] == None:
|
||||||
|
rbtAlert = "no alert"
|
||||||
|
else:
|
||||||
|
rbtAlert = rbtStateJson['alert']
|
||||||
|
logger.log("error: %s: -- alert: %s" % (rbtError, rbtAlert))
|
||||||
|
if rbtStateDetails['isDocked'] == True:
|
||||||
|
thing.setStateValue(robotRobotStateStateTypeId, "docked")
|
||||||
|
elif rbtPauseAv == True:
|
||||||
|
thing.setStateValue(robotRobotStateStateTypeId, "cleaning")
|
||||||
|
elif rbtResumeAv == True:
|
||||||
|
thing.setStateValue(robotRobotStateStateTypeId, "paused")
|
||||||
|
elif rbtStartAv == True:
|
||||||
|
thing.setStateValue(robotRobotStateStateTypeId, "stopped")
|
||||||
|
else:
|
||||||
|
thing.setStateValue(robotRobotStateStateTypeId, "error")
|
||||||
|
thing.setStateValue(robotErrorMessageStateTypeId, rbtError)
|
||||||
|
|
||||||
|
|
||||||
def pollService():
|
def pollService():
|
||||||
|
|
@ -159,7 +170,6 @@ def pollService():
|
||||||
refreshRobot(thing)
|
refreshRobot(thing)
|
||||||
except:
|
except:
|
||||||
logger.warn("Error refreshing robot state")
|
logger.warn("Error refreshing robot state")
|
||||||
|
|
||||||
# restart the timer for next poll
|
# restart the timer for next poll
|
||||||
global pollTimer
|
global pollTimer
|
||||||
pollTimer = threading.Timer(60, pollService)
|
pollTimer = threading.Timer(60, pollService)
|
||||||
|
|
@ -167,17 +177,25 @@ def pollService():
|
||||||
|
|
||||||
|
|
||||||
def executeAction(info):
|
def executeAction(info):
|
||||||
return; # Temporary, to not accidentally start it
|
# return; # Temporary, to not accidentally start it
|
||||||
|
|
||||||
if info.actionTypeId == robotStartCleaningActionTypeId:
|
if info.actionTypeId == robotStartCleaningActionTypeId:
|
||||||
# To do: add a parameter to the start action which takes a zone id
|
refreshRobot(info.thing)
|
||||||
thingsAndRobots[info.thing].start_cleaning()
|
if info.thing.stateValue(robotRobotStateStateTypeId) == "paused":
|
||||||
|
thingsAndRobots[info.thing].resume_cleaning()
|
||||||
|
else:
|
||||||
|
# To do: add a parameter to the start action which takes a zone id
|
||||||
|
cleanWithRobot(info.thing, None, None)
|
||||||
refreshRobot(info.thing)
|
refreshRobot(info.thing)
|
||||||
info.finish(nymea.ThingErrorNoError)
|
info.finish(nymea.ThingErrorNoError)
|
||||||
return
|
return
|
||||||
|
|
||||||
if info.actionTypeId == robotPauseCleaningActionTypeId:
|
if info.actionTypeId == robotPauseCleaningActionTypeId:
|
||||||
thingsAndRobots[info.thing].pause_cleaning()
|
refreshRobot(info.thing)
|
||||||
|
if info.thing.stateValue(robotRobotStateStateTypeId) == "paused":
|
||||||
|
thingsAndRobots[info.thing].resume_cleaning()
|
||||||
|
else:
|
||||||
|
thingsAndRobots[info.thing].pause_cleaning()
|
||||||
refreshRobot(info.thing)
|
refreshRobot(info.thing)
|
||||||
info.finish(nymea.ThingErrorNoError)
|
info.finish(nymea.ThingErrorNoError)
|
||||||
return
|
return
|
||||||
|
|
@ -194,6 +212,28 @@ def executeAction(info):
|
||||||
info.finish(nymea.ThingErrorNoError)
|
info.finish(nymea.ThingErrorNoError)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
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
|
||||||
|
robot = thingsAndRobots[robotThing]
|
||||||
|
logger.log("Cleaning with robot:", robot, robotThing)
|
||||||
|
boolEco = robotThing.setting(robotSettingsEcoParamTypeId)
|
||||||
|
boolCare = robotThing.setting(robotSettingsCareParamTypeId)
|
||||||
|
boolNogo = robotThing.setting(robotSettingsNoGoLinesParamTypeId)
|
||||||
|
if boolEco == False:
|
||||||
|
intEco = 2
|
||||||
|
else:
|
||||||
|
intEco = 1
|
||||||
|
if boolCare == False:
|
||||||
|
intCare = 1
|
||||||
|
else:
|
||||||
|
intCare = 2
|
||||||
|
if boolNogo == False:
|
||||||
|
intNogo = 2
|
||||||
|
else:
|
||||||
|
intNogo = 4
|
||||||
|
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)
|
||||||
|
refreshRobot(robotThing)
|
||||||
|
|
||||||
def browseThing(browseResult):
|
def browseThing(browseResult):
|
||||||
robotThing = browseResult.thing
|
robotThing = browseResult.thing
|
||||||
|
|
@ -241,6 +281,8 @@ def browseThing(browseResult):
|
||||||
def executeBrowserItem(info):
|
def executeBrowserItem(info):
|
||||||
# TODO: An item in the browser has been clicked.
|
# 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:", )
|
||||||
|
# cleanWithRobot(info.thing, mapID, boundaryID)
|
||||||
info.finish(nymea.ThingErrorNoError)
|
info.finish(nymea.ThingErrorNoError)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -248,4 +290,4 @@ 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