From cc99ecef0d43cea70907bf0b856dbd8134fe681a Mon Sep 17 00:00:00 2001 From: Luis Riegger Date: Sun, 7 Feb 2021 11:15:08 +0100 Subject: [PATCH] add german plugin language --- CHANGELOG.md | 6 +++- README.md | 10 ++++-- accessories/koboldVacuumRobot.js | 53 ++++++++++++++++++++++++-------- config.schema.json | 20 ++++++++++++ index.js | 1 + package.json | 2 +- 6 files changed, 76 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd5c9bf..e090516 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -116,4 +116,8 @@ * Fixed robot not shown before setting up a floor plan ## 0.7.2 -* Fixed homebridge crash with multiple robots per account \ No newline at end of file +* Fixed homebridge crash with multiple robots per account + +## 0.8.0 +* Add German plugin language (for example, this gives you a "Sauge Küche" Siri command for a zone called "Küche") +* Added possibility to toggle between languages (English/German) in Homebridge UI Plugin Settings \ No newline at end of file diff --git a/README.md b/README.md index 51a0502..93d2b1c 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ The interaction with the Server is handled by the underlying [node-kobold-contro - Automatic or periodic refresh of robot state - Multiple robots +- German or English Language Setting + > 2 You can send the robot from one room to another as well. He will return to the base, wait there some seconds and then starts cleaning the next room. > 3 You need a third party app like eve to access these features. @@ -49,7 +51,8 @@ Add the following information to your config file. Change the values for email a "platforms": [ { "platform": "KoboldVacuumRobot", - "token": "YourToken" + "token": "YourToken", + "language": "de" } ] ``` @@ -92,6 +95,8 @@ curl -X "POST" "https://mykobold.eu.auth0.com/oauth/token" \ From the output, you want to copy the `id_token` value. +The `language` can be `de` for German, or `en` for English. + ### Advanced Below are explanations for advanced parameters to adjust the plugin to your needs. All parameters are *optional*. @@ -111,7 +116,8 @@ List of plugin features that you don't want to use in homekit (e.g. `dock`, `doc "platform": "KoboldVacuumRobot", "token": "YourToken", "refresh": "120", - "hidden": ["dock", "dockstate", "eco", "nogolines", "extracare", "schedule", "find", "spot"] + "hidden": ["dock", "dockstate", "eco", "nogolines", "extracare", "schedule", "find", "spot"], + "language": "de" } ] ``` diff --git a/accessories/koboldVacuumRobot.js b/accessories/koboldVacuumRobot.js index 37a10a6..99995b9 100644 --- a/accessories/koboldVacuumRobot.js +++ b/accessories/koboldVacuumRobot.js @@ -38,6 +38,35 @@ function KoboldVacuumRobotAccessory(platform, robotObject) this.spotPlusFeatures = ((typeof robotObject.availableServices.spotCleaning !== 'undefined') && robotObject.availableServices.spotCleaning.includes("basic")); this.boundary = (typeof robotObject.boundary === 'undefined') ? null : robotObject.boundary; + this.dict = { + 'en': { + "clean": "Clean", + "clean the": "Clean the", + "goToDock": "Go to Dock", + "dockState": "Dock", + "eco": "Eco Mode", + "noGoLines": "NoGo Lines", + "extraCare": "Extra Care", + "schedule": "Schedule", + "findMe": "Find me", + "cleanSpot": "Clean Spot", + "battery": "Battery" + }, + 'de': { + "clean": "Sauge", + "clean the": "Sauge", + "goToDock": "Zur Basis", + "dockState": "In der Basis", + "eco": "Eco Modus", + "noGoLines": "NoGo Linien", + "extraCare": "Extra Care", + "schedule": "Zeitplan", + "findMe": "Finde mich", + "cleanSpot": "Spot Reinigung", + "battery": "Batterie" + } + }[this.platform.language] + if (this.boundary == null) { this.name = this.robot.name; @@ -64,20 +93,20 @@ function KoboldVacuumRobotAccessory(platform, robotObject) this.name = this.robot.name + ' - ' + this.boundary.name; } - this.batteryService = new Service.BatteryService("Battery", "battery"); + this.batteryService = new Service.BatteryService(this.dict["battery"], "battery"); if (this.boundary == null) { - this.cleanService = new Service.Switch(this.name + " Clean", "clean"); - this.goToDockService = new Service.Switch(this.name + " Go to Dock", "goToDock"); - this.dockStateService = new Service.OccupancySensor(this.name + " Dock", "dockState"); - this.ecoService = new Service.Switch(this.name + " Eco Mode", "eco"); - this.noGoLinesService = new Service.Switch(this.name + " NoGo Lines", "noGoLines"); - this.extraCareService = new Service.Switch(this.name + " Extra Care", "extraCare"); - this.scheduleService = new Service.Switch(this.name + " Schedule", "schedule"); - this.findMeService = new Service.Switch(this.name + " Find Me", "findMe"); + this.cleanService = new Service.Switch(this.name + " " + this.dict["clean"], "clean"); + this.goToDockService = new Service.Switch(this.name + " " + this.dict["goToDock"], "goToDock"); + this.dockStateService = new Service.OccupancySensor(this.name + " " + this.dict["dockState"], "dockState"); + this.ecoService = new Service.Switch(this.name + " " + this.dict["eco"], "eco"); + this.noGoLinesService = new Service.Switch(this.name + " " + this.dict["noGoLines"], "noGoLines"); + this.extraCareService = new Service.Switch(this.name + " " + this.dict["extraCare"], "extraCare"); + this.scheduleService = new Service.Switch(this.name + " " + this.dict["schedule"], "schedule"); + this.findMeService = new Service.Switch(this.name + " " + this.dict["findMe"], "findMe"); - this.spotCleanService = new Service.Switch(this.name + " Clean Spot", "cleanSpot"); + this.spotCleanService = new Service.Switch(this.name + " " + this.dict["cleanSpot"], "cleanSpot"); this.spotCleanService.addCharacteristic(SpotRepeatCharacteristic); if (this.spotPlusFeatures) { @@ -88,10 +117,10 @@ function KoboldVacuumRobotAccessory(platform, robotObject) else { const splitName = this.boundary.name.split(' '); - let serviceName = "Clean the " + this.boundary.name; + let serviceName = this.dict["clean the"] + " " + this.boundary.name; if (splitName.length >= 2 && splitName[splitName.length - 2].match(/[']s$/g)) { - serviceName = "Clean " + this.boundary.name; + serviceName = this.dict["clean"] + " " + this.boundary.name; } this.cleanService = new Service.Switch(serviceName, "cleanBoundary:" + this.boundary.id); } diff --git a/config.schema.json b/config.schema.json index be845ff..02b9563 100644 --- a/config.schema.json +++ b/config.schema.json @@ -10,6 +10,26 @@ "type": "string", "required": true, "description": "Your Token" + }, + "language": { + "title": "language", + "type": "string", + "default": "en", + "oneOf": [ + { + "title": "English", + "enum": [ + "en" + ] + }, + { + "title": "German", + "enum": [ + "de" + ] + } + ], + "required": true } } } diff --git a/index.js b/index.js index 744f300..31e6b0f 100644 --- a/index.js +++ b/index.js @@ -20,6 +20,7 @@ function KoboldVacuumRobotPlatform(log, config) this.log = log; this.serial = "1-3-3-7"; this.token = config['token']; + this.language = config['language']; this.hiddenServices = ''; this.hiddenServices = ('disabled' in config ? config['disabled'] : this.hiddenServices); this.hiddenServices = ('hidden' in config ? config['hidden'] : this.hiddenServices); diff --git a/package.json b/package.json index 1506efb..afc6248 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-kobold", - "version": "0.7.2", + "version": "0.8.0", "description": "A Vorwerk Kobold vacuum robot plugin for homebridge.", "license": "MIT", "keywords": [