More work on neato
This commit is contained in:
parent
4eb24160a6
commit
a5bf3238c3
@ -99,33 +99,18 @@
|
||||
},
|
||||
{
|
||||
"id": "dce4f7f3-a0a6-46bb-9216-c9089d9e9b0d",
|
||||
"name": "cleaning",
|
||||
"displayName": "Cleaning",
|
||||
"displayNameEvent": "Cleaning yes/no",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"id": "0f925abf-396c-437e-b259-2fed7eafe7f4",
|
||||
"name": "paused",
|
||||
"displayName": "Paused",
|
||||
"displayNameEvent": "Cleaning paused yes/no",
|
||||
"type": "bool",
|
||||
"defaultValue": false
|
||||
"name": "state",
|
||||
"displayName": "Cleaning state",
|
||||
"displayNameEvent": "Cleaning state changed",
|
||||
"type": "QString",
|
||||
"possibleValues": ["docked", "cleaning", "paused", "traveling", "stopped", "error"],
|
||||
"defaultValue": "docked"
|
||||
},
|
||||
{
|
||||
"id": "1b8abd35-8276-44ba-8c75-a647877b2e11",
|
||||
"name": "charging",
|
||||
"displayName": "Charging",
|
||||
"displayNameEvent": "Robot charging yes/no",
|
||||
"type": "bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"id": "805175ec-c2e4-4fbe-9505-282750ef1467",
|
||||
"name": "docked",
|
||||
"displayName": "Docked",
|
||||
"displayNameEvent": "Robot docked yes/no",
|
||||
"displayNameEvent": "Started or stopped charging",
|
||||
"type": "bool",
|
||||
"defaultValue": true
|
||||
},
|
||||
@ -141,7 +126,7 @@
|
||||
"id": "20ed8767-806f-4ec2-8626-842cd398f9df",
|
||||
"name": "batteryLevel",
|
||||
"displayName": "Battery level",
|
||||
"displayNameEvent": "Battery level percentage",
|
||||
"displayNameEvent": "Battery level changed",
|
||||
"type": "int",
|
||||
"unit": "Percentage",
|
||||
"defaultValue": 0,
|
||||
@ -153,7 +138,21 @@
|
||||
{
|
||||
"id": "1f774998-5fa7-4e3b-8ab0-a8402dd561bb",
|
||||
"name": "startCleaning",
|
||||
"displayName": "Start/pause cleaning"
|
||||
"displayName": "Start cleaning",
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "08a86cca-cdc9-4520-af1d-8413a0c274b5",
|
||||
"name": "zones",
|
||||
"displayName": "Zones to clean",
|
||||
"type": "QStringList",
|
||||
"defaultValue": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "e731faa6-88c9-406d-b505-f89b5f0868b0",
|
||||
"name": "pauseCleaning",
|
||||
"displayName": "Pause/resume cleaning"
|
||||
},
|
||||
{
|
||||
"id": "5178a803-5696-4ee1-80a4-2c7c20a5043a",
|
||||
@ -164,11 +163,6 @@
|
||||
"id": "30775042-55a7-4f1b-9042-a9bdeadc4b0d",
|
||||
"name": "stopCleaning",
|
||||
"displayName": "Stop cleaning"
|
||||
},
|
||||
{
|
||||
"id": "95ba515b-0023-4a98-a867-ca8286512a4e",
|
||||
"name": "getBoundaries",
|
||||
"displayName": "Get No-go Lines"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -132,7 +132,6 @@ def refreshRobot(thing):
|
||||
# Set robot docked/charging state
|
||||
rbtStateDetails = rbtStateJson['details']
|
||||
thing.setStateValue(robotChargingStateTypeId, rbtStateDetails['isCharging'])
|
||||
thing.setStateValue(robotDockedStateTypeId, rbtStateDetails['isDocked'])
|
||||
thing.setStateValue(robotBatteryLevelStateTypeId, rbtStateDetails['charge'])
|
||||
|
||||
# Set robot cleaning/paused state
|
||||
@ -140,15 +139,16 @@ def refreshRobot(thing):
|
||||
rbtStartAv = rbtStateCommands['start']
|
||||
rbtPauseAv = rbtStateCommands['pause']
|
||||
rbtResumeAv = rbtStateCommands['resume']
|
||||
if rbtStartAv == True:
|
||||
thing.setStateValue(robotCleaningStateTypeId, False)
|
||||
thing.setStateValue(robotPausedStateTypeId, False)
|
||||
if rbtStateDetails['isDocked'] == True:
|
||||
thing.setStateValue(robotStateStateTypeId, "docked")
|
||||
elif rbtPauseAv == True:
|
||||
thing.setStateValue(robotCleaningStateTypeId, True)
|
||||
thing.setStateValue(robotPausedStateTypeId, False)
|
||||
thing.setStateValue(robotStateStateTypeId, "cleaning")
|
||||
elif rbtResumeAv == True:
|
||||
thing.setStateValue(robotCleaningStateTypeId, True)
|
||||
thing.setStateValue(robotPausedStateTypeId, True)
|
||||
thing.setStateValue(robotStateStateTypeId, "paused")
|
||||
elif rbtStartAv == True:
|
||||
thing.setStateValue(robotStateStateTypeId, "stopped")
|
||||
else:
|
||||
thing.setStateValue(robotStateStateTypeId, "error")
|
||||
|
||||
|
||||
def pollService():
|
||||
@ -167,21 +167,17 @@ def pollService():
|
||||
|
||||
|
||||
def executeAction(info):
|
||||
return; # Temporary, to not accidentally start it
|
||||
|
||||
if info.actionTypeId == robotStartCleaningActionTypeId:
|
||||
rbtState = thingsAndRobots[info.thing].get_robot_state()
|
||||
rbtStateJson = rbtState.json()
|
||||
rbtStateCommands = rbtStateJson['availableCommands']
|
||||
rbtStartAv = rbtStateCommands['start']
|
||||
rbtPauseAv = rbtStateCommands['pause']
|
||||
rbtResumeAv = rbtStateCommands['resume']
|
||||
if rbtStartAv == True:
|
||||
logger.log("Start cleaning")
|
||||
thingsAndRobots[info.thing].start_cleaning()
|
||||
elif rbtPauseAv == True:
|
||||
logger.log("Pause cleaning")
|
||||
thingsAndRobots[info.thing].pause_cleaning()
|
||||
elif rbtResumeAv == True:
|
||||
thingsAndRobots[info.thing].resume_cleaning()
|
||||
# To do: add a parameter to the start action which takes a zone id
|
||||
thingsAndRobots[info.thing].start_cleaning()
|
||||
refreshRobot(info.thing)
|
||||
info.finish(nymea.ThingErrorNoError)
|
||||
return
|
||||
|
||||
if info.actionTypeId == robotPauseCleaningActionTypeId:
|
||||
thingsAndRobots[info.thing].pause_cleaning()
|
||||
refreshRobot(info.thing)
|
||||
info.finish(nymea.ThingErrorNoError)
|
||||
return
|
||||
@ -190,21 +186,13 @@ def executeAction(info):
|
||||
thingsAndRobots[info.thing].send_to_base()
|
||||
refreshRobot(info.thing)
|
||||
info.finish(nymea.ThingErrorNoError)
|
||||
return
|
||||
|
||||
if info.actionTypeId == robotStopCleaningActionTypeId:
|
||||
thingsAndRobots[info.thing].stop_cleaning()
|
||||
refreshRobot(info.thing)
|
||||
info.finish(nymea.ThingErrorNoError)
|
||||
|
||||
# To do: get available boundaries to use with start_cleaning action
|
||||
if info.actionTypeId == robotGetBoundariesActionTypeId:
|
||||
mapIDparam = info.thing.paramValue(robotThingMapIdParamTypeId)
|
||||
rbtMapBound = thingsAndRobots[info.thing].get_map_boundaries(mapIDparam)
|
||||
logger.log("rbtMapBound Type: ", type(rbtMapBound), "rbtMapBound Contents: ", rbtMapBound)
|
||||
rbtBoundData = rbtMapBound.text
|
||||
logger.log("rbtBoundData Type: ", type(rbtBoundData), "rbtBoundData Contents: ", rbtBoundData)
|
||||
refreshRobot(info.thing)
|
||||
info.finish(nymea.ThingErrorNoError)
|
||||
return
|
||||
|
||||
|
||||
def browseThing(browseResult):
|
||||
@ -223,10 +211,10 @@ def browseThing(browseResult):
|
||||
|
||||
|
||||
# Top level entries -> return maps
|
||||
if browseResult.itemId == "":
|
||||
if browseResult.itemId == "" or browseResult.itemId == "maps":
|
||||
maps = account.persistent_maps
|
||||
|
||||
logger.log("maps", tpye(maps), maps)
|
||||
logger.log("maps", type(maps), maps)
|
||||
for map in maps[robot.serial]:
|
||||
logger.log("Type mapInfo: ", type(map))
|
||||
logger.log("map:", map)
|
||||
@ -242,7 +230,9 @@ def browseThing(browseResult):
|
||||
|
||||
logger.log("boundaries", type(boundaries), boundaries.json())
|
||||
for boundary in boundaries.json()["data"]["boundaries"]:
|
||||
browseResult.addItem(nymea.BrowserItem(boundary["id"], boundary["name"], boundary["type"], executable=True, disabled=not boundary["enabled"], icon=nymea.BrowserIconFavorites))
|
||||
# if boundary["type"] == "polygon":
|
||||
logger.log("vertices:", json.dumps(boundary["vertices"]))
|
||||
browseResult.addItem(nymea.BrowserItem(boundary["id"], boundary["name"], json.dumps(boundary), executable=True, disabled=not boundary["enabled"], icon=nymea.BrowserIconFavorites))
|
||||
|
||||
browseResult.finish(nymea.ThingErrorNoError)
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user