Skip to content

Commit 5cbcf6a

Browse files
committed
Refactor dockOnStop config option
I think it's clearer as a dropdown
1 parent 0e87755 commit 5cbcf6a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

config.schema.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,22 @@
6060
"title": "Home",
6161
"required": false
6262
},
63-
"dockOnStop": {
64-
"type": "boolean",
65-
"title": "Dock when stopped",
66-
"default": true,
67-
"required": false
63+
"stopBehaviour": {
64+
"type": "string",
65+
"title": "When Roomba is turned off",
66+
"required": true,
67+
"default": "home",
68+
"oneOf": [
69+
{ "title": "Home", "enum": ["home"] },
70+
{ "title": "Pause", "enum": ["pause"] }
71+
]
6872
}
6973
}
7074
},
7175
"layout": [
7276
{ "type": "section", "title": "Roomba Details", "items": [ "name", "model", "serialnum", "blid", "robotpwd", "ipaddress" ] },
7377
{ "type": "section", "title": "Contact Sensors", "items": [ "dockContactSensor", "dockingContactSensor", "runningContactSensor", "binContactSensor" ] },
7478
{ "type": "section", "title": "Switches", "items": [ "homeSwitch" ] },
75-
{ "type": "section", "title": "Behaviour", "items": [ "dockOnStop" ] }
79+
{ "type": "section", "title": "Behaviour", "items": [ "stopBehaviour" ] }
7680
]
7781
}

src/accessory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default class RoombaAccessory implements AccessoryPlugin {
8080
private robotpwd: string
8181
private ipaddress: string
8282
private firmware: string
83-
private dockOnStop: boolean
83+
private stopBehaviour: "home" | "pause"
8484

8585
private accessoryInfo: Service
8686
private filterMaintenance: Service
@@ -133,7 +133,7 @@ export default class RoombaAccessory implements AccessoryPlugin {
133133
this.robotpwd = config.robotpwd;
134134
this.ipaddress = config.ipaddress;
135135
this.firmware = "N/A";
136-
this.dockOnStop = config.dockOnStop !== undefined ? config.dockOnStop : true;
136+
this.stopBehaviour = config.stopBehaviour !== undefined ? config.stopBehaviour : "home";
137137

138138
const showDockAsContactSensor = config.dockContactSensor === undefined ? true : config.dockContactSensor;
139139
const showRunningAsContactSensor = config.runningContactSensor;
@@ -476,7 +476,7 @@ export default class RoombaAccessory implements AccessoryPlugin {
476476
/* Force a refresh of state so we pick up the new state quickly */
477477
this.refreshState();
478478

479-
if (this.dockOnStop) {
479+
if (this.stopBehaviour === "home") {
480480
this.log("Roomba paused, returning to Dock");
481481
await this.dockWhenStopped(roomba, 3000);
482482
} else {

0 commit comments

Comments
 (0)