From 5af549f35f3b0b2a7b560eafa7102ca3f5b324f4 Mon Sep 17 00:00:00 2001 From: Julius Seiffert Date: Sat, 4 Dec 2021 19:01:03 +0100 Subject: [PATCH 1/2] Fixing On and Off translation error I added two new voc file types for a new ON and OFF keyword, which can be translated easily. This will fix the translation error in german and is compatible with almost every other language. Signed-off-by: Julius Seiffert (github: juuls28) --- __init__.py | 9 +++++++-- regex/de-de/onoff_command.rx | 4 +++- vocab/de-de/Off.voc | 1 + vocab/de-de/On.voc | 1 + vocab/en-us/Off.voc | 1 + vocab/en-us/On.voc | 1 + vocab/es-es/Off.voc | 1 + vocab/es-es/On.voc | 1 + vocab/it-it/Off.voc | 1 + vocab/it-it/On.voc | 1 + 10 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 vocab/de-de/Off.voc create mode 100644 vocab/de-de/On.voc create mode 100644 vocab/en-us/Off.voc create mode 100644 vocab/en-us/On.voc create mode 100644 vocab/es-es/Off.voc create mode 100644 vocab/es-es/On.voc create mode 100644 vocab/it-it/Off.voc create mode 100644 vocab/it-it/On.voc diff --git a/__init__.py b/__init__.py index 25a3fe4..b3d31ba 100644 --- a/__init__.py +++ b/__init__.py @@ -212,10 +212,11 @@ def handle_onoff_status_intent(self, message): ohItem = self.findItemName(self.lightingSwitchableItemsDic, messageItem) if ohItem != None: - if (command != "on") and (command != "off"): + #if (command != "on") and (command != "off"): + if not self.voc_match(command, 'On') and not self.voc_match(command, 'Off'): self.speak_dialog('ErrorDialog') else: - statusCode = self.sendCommandToItem(ohItem, command.upper()) + statusCode = self.sendCommandToItem(ohItem, command) if statusCode == 200: self.speak_dialog('StatusOnOff', {'command': command, 'item': messageItem}) elif statusCode == 404: @@ -367,6 +368,10 @@ def sendStatusToItem(self, ohItem, command): return req.status_code def sendCommandToItem(self, ohItem, command): + if self.voc_match(command, 'On'): + command = "ON" + elif self.voc_match(command, 'Off'): + command = "OFF" requestUrl = self.url+"/items/%s" % (ohItem) req = requests.post(requestUrl, data=command, headers=self.command_headers) diff --git a/regex/de-de/onoff_command.rx b/regex/de-de/onoff_command.rx index 8b667c2..b5b618e 100644 --- a/regex/de-de/onoff_command.rx +++ b/regex/de-de/onoff_command.rx @@ -1 +1,3 @@ -(schalte|mache|tue) (?Pon|off) (?P.*) +(schalte|mache|tue) (?Pan|aus) (?P.*) +(schalte|mache|mach) (?P.*) (?Pan|aus) +(?P.*) (?Pan|aus) diff --git a/vocab/de-de/Off.voc b/vocab/de-de/Off.voc new file mode 100644 index 0000000..d908ee1 --- /dev/null +++ b/vocab/de-de/Off.voc @@ -0,0 +1 @@ +aus \ No newline at end of file diff --git a/vocab/de-de/On.voc b/vocab/de-de/On.voc new file mode 100644 index 0000000..eec0c59 --- /dev/null +++ b/vocab/de-de/On.voc @@ -0,0 +1 @@ +an \ No newline at end of file diff --git a/vocab/en-us/Off.voc b/vocab/en-us/Off.voc new file mode 100644 index 0000000..b5a9a3b --- /dev/null +++ b/vocab/en-us/Off.voc @@ -0,0 +1 @@ +off \ No newline at end of file diff --git a/vocab/en-us/On.voc b/vocab/en-us/On.voc new file mode 100644 index 0000000..e8fd903 --- /dev/null +++ b/vocab/en-us/On.voc @@ -0,0 +1 @@ +on \ No newline at end of file diff --git a/vocab/es-es/Off.voc b/vocab/es-es/Off.voc new file mode 100644 index 0000000..4378013 --- /dev/null +++ b/vocab/es-es/Off.voc @@ -0,0 +1 @@ +apaga \ No newline at end of file diff --git a/vocab/es-es/On.voc b/vocab/es-es/On.voc new file mode 100644 index 0000000..36cf220 --- /dev/null +++ b/vocab/es-es/On.voc @@ -0,0 +1 @@ +enciende \ No newline at end of file diff --git a/vocab/it-it/Off.voc b/vocab/it-it/Off.voc new file mode 100644 index 0000000..b5a9a3b --- /dev/null +++ b/vocab/it-it/Off.voc @@ -0,0 +1 @@ +off \ No newline at end of file diff --git a/vocab/it-it/On.voc b/vocab/it-it/On.voc new file mode 100644 index 0000000..e8fd903 --- /dev/null +++ b/vocab/it-it/On.voc @@ -0,0 +1 @@ +on \ No newline at end of file From 1d5dce625b64a8b2893d223784508b9b415b4c90 Mon Sep 17 00:00:00 2001 From: Julius Seiffert Date: Sat, 4 Dec 2021 19:05:35 +0100 Subject: [PATCH 2/2] Added German VOC entries added some voc entries for better usage in german Signed-off-by: Julius Seiffert (github: juuls28) --- vocab/de-de/ListItemsKeyword.voc | 1 + vocab/de-de/OnOffStatusKeyword.voc | 2 +- vocab/de-de/RefreshTaggedItemsKeyword.voc | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/vocab/de-de/ListItemsKeyword.voc b/vocab/de-de/ListItemsKeyword.voc index 3015f73..84ec55c 100644 --- a/vocab/de-de/ListItemsKeyword.voc +++ b/vocab/de-de/ListItemsKeyword.voc @@ -1,2 +1,3 @@ liste Openhab Elemente auf liste Openhab Elemente auf +liste Openhab items auf diff --git a/vocab/de-de/OnOffStatusKeyword.voc b/vocab/de-de/OnOffStatusKeyword.voc index e63cb16..84faf6c 100644 --- a/vocab/de-de/OnOffStatusKeyword.voc +++ b/vocab/de-de/OnOffStatusKeyword.voc @@ -1,3 +1,3 @@ schalte -schalte mach +mache diff --git a/vocab/de-de/RefreshTaggedItemsKeyword.voc b/vocab/de-de/RefreshTaggedItemsKeyword.voc index 075eed1..6a19bf4 100644 --- a/vocab/de-de/RefreshTaggedItemsKeyword.voc +++ b/vocab/de-de/RefreshTaggedItemsKeyword.voc @@ -1,2 +1,2 @@ Aktualisiere Openhab Elemente -Aktualisiere Openhab Elemente +Aktualisiere Openhab Items