Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On off keyword extraction (#103) #111

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion regex/de-de/onoff_command.rx
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
(schalte|mache|tue) (?P<Command>on|off) (?P<Item>.*)
(schalte|mache|tue) (?P<Command>an|aus) (?P<Item>.*)
(schalte|mache|mach) (?P<Item>.*) (?P<Command>an|aus)
(?P<Item>.*) (?P<Command>an|aus)
1 change: 1 addition & 0 deletions vocab/de-de/ListItemsKeyword.voc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
liste Openhab Elemente auf
liste Openhab Elemente auf
liste Openhab items auf
1 change: 1 addition & 0 deletions vocab/de-de/Off.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aus
1 change: 1 addition & 0 deletions vocab/de-de/On.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
an
2 changes: 1 addition & 1 deletion vocab/de-de/OnOffStatusKeyword.voc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
schalte
schalte
mach
mache
2 changes: 1 addition & 1 deletion vocab/de-de/RefreshTaggedItemsKeyword.voc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Aktualisiere Openhab Elemente
Aktualisiere Openhab Elemente
Aktualisiere Openhab Items
1 change: 1 addition & 0 deletions vocab/en-us/Off.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
off
1 change: 1 addition & 0 deletions vocab/en-us/On.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
on
1 change: 1 addition & 0 deletions vocab/es-es/Off.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apaga
1 change: 1 addition & 0 deletions vocab/es-es/On.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enciende
1 change: 1 addition & 0 deletions vocab/it-it/Off.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
off
1 change: 1 addition & 0 deletions vocab/it-it/On.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
on