v19 code review (#85)

pull/89/merge
mortommy 2019-12-20 16:06:27 +01:00 committed by GitHub
parent 725bc7f1a9
commit 800565d5fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
73 changed files with 215 additions and 79 deletions

View File

@ -66,22 +66,25 @@ pip install -r requirements.txt
```
## Examples
* " Hey Mycroft, turn on Diningroom Light"
* "Hey Mycroft, turn on Diningroom Light"
* "Hey Mycroft, switch off Kitchen Light"
* "Hey Mycroft, put on Good Night"
* "Hey Mycroft, what is Good Night status?"
* "Hey Mycroft, what is the status of Good Night?"
* "Hey Mycroft, set Diningroom to 50 percent"
* "Hey Mycroft, dim Kitchen"
* "Hey Mycroft, brighten Kitchen"
* "Hey Mycroft, bright Kitchen"
* "Hey Mycroft, dim Kitchen by 20 percent"
* "Hey Mycroft, what's Bedroom temperature?"
* "Hey Mycroft, what's Bedroom humidity?"
* "Hey Mycroft, tell me the temperature of Bedroom"
* "Hey Mycroft, what's the Bedroom humidity?"
* "Hey Mycroft, I'd like to know the humidity of Bedroom"
* "Hey Mycroft, adjust Main Thermostat to 21 degrees"
* "Hey Mycroft, regulate Main Thermostat to 20 degrees"
* "Hey Mycroft, decrease Main Thermostat by 2 degrees"
* "Hey Mycroft, increase Main Thermostat by 1 degrees"
* "Hey Mycroft, what is Main Thermostat regulated to?"
* "Hey Mycroft, what is Main Thermostat tuned to?"
* "Hey Mycroft, what is Main Thermostat is regulated to?"
* "Hey Mycroft, how the Main Thermostat tuned to?"
## Credits
@mortommy

View File

@ -118,8 +118,8 @@ Each item tag supports different command, here is the summary:
| | put | on, off |
| | dim | |
| | dim by | value in percentage |
| | brighten | |
| | brighten by | value in percentage |
| | bright | |
| | bright by | value in percentage |
| | | |
| `Thermostat` | adjust to | values in degrees |
| | regulate to | values in degrees |
@ -136,22 +136,25 @@ Each item tag supports different command, here is the summary:
With references to the above item definitions, here are an examples of working commands:
- *"Hey Mycroft, turn on Diningroom Light"*
- *"Hey Mycroft, switch off Kitchen Light"*
- *"Hey Mycroft, put on Good Night"*
- *"Hey Mycroft, what is Good Night status?"*
- *"Hey Mycroft, set Diningroom to 50 percent"*
- *"Hey Mycroft, dim Kitchen"*
- *"Hey Mycroft, brighten Kitchen"*
- *"Hey Mycroft, dim Kitchen by 20 percent"*
- *"Hey Mycroft, what's Bedroom temperature?"*
- *"Hey Mycroft, what's Bedroom humidity?"*
- *"Hey Mycroft, adjust Main Thermostat to 21 degrees"*
- *"Hey Mycroft, regulate Main Thermostat to 20 degrees"*
- *"Hey Mycroft, decrease Main Thermostat by 2 degrees"*
- *"Hey Mycroft, increase Main Thermostat by 1 degrees"*
- *"Hey Mycroft, what is Main Thermostat regulated to?"*
- *"Hey Mycroft, what is Main Thermostat tuned to?"*
- * "Hey Mycroft, turn on Diningroom Light"
- * "Hey Mycroft, switch off Kitchen Light"
- * "Hey Mycroft, put on Good Night"
- * "Hey Mycroft, what is Good Night status?"
- * "Hey Mycroft, what is the status of Good Night?"
- * "Hey Mycroft, set Diningroom to 50 percent"
- * "Hey Mycroft, dim Kitchen"
- * "Hey Mycroft, bright Kitchen"
- * "Hey Mycroft, dim Kitchen by 20 percent"
- * "Hey Mycroft, what's Bedroom temperature?"
- * "Hey Mycroft, tell me the temperature of Bedroom"
- * "Hey Mycroft, what's the Bedroom humidity?"
- * "Hey Mycroft, I'd like to know the humidity of Bedroom"
- * "Hey Mycroft, adjust Main Thermostat to 21 degrees"
- * "Hey Mycroft, regulate Main Thermostat to 20 degrees"
- * "Hey Mycroft, decrease Main Thermostat by 2 degrees"
- * "Hey Mycroft, increase Main Thermostat by 1 degrees"
- * "Hey Mycroft, what is Main Thermostat is regulated to?"
- * "Hey Mycroft, how the Main Thermostat tuned to?"
### Additional Comments

View File

@ -16,7 +16,7 @@
from os.path import dirname
from adapt.intent import IntentBuilder
from mycroft.skills.core import MycroftSkill
from mycroft.skills.core import MycroftSkill, intent_handler
from mycroft.util.log import getLogger
from fuzzywuzzy import fuzz
@ -71,6 +71,7 @@ class openHABSkill(MycroftSkill):
self.shutdown()
self.handle_websettings_update()
if self.url is not None:
self.getTaggedItems()
else:
@ -85,8 +86,11 @@ class openHABSkill(MycroftSkill):
dimmer_status_intent = IntentBuilder("Dimmer_StatusIntent").require("DimmerStatusKeyword").require("Item").optionally("BrightPercentage").build()
self.register_intent(dimmer_status_intent, self.handle_dimmer_status_intent)
what_status_intent = IntentBuilder("What_StatusIntent").require("WhatStatusKeyword").require("Item").require("RequestType").build()
self.register_intent(what_status_intent, self.handle_what_status_intent)
#what_status_intent = IntentBuilder("What_StatusIntent").require("WhatStatusKeyword").require("Item").require("RequestType").build()
#self.register_intent(what_status_intent, self.handle_what_status_intent)
self.register_entity_file('item.entity')
self.register_entity_file('requesttype.entity')
self.register_intent_file('what.status.intent',self.handle_what_status_intent)
setTemp_status_intent = IntentBuilder("SetTemp_StatusIntent").require("ThermostatStatusKeyword").require("Item").require("TempValue").build()
self.register_intent(setTemp_status_intent, self.handle_setTemp_status_intent)
@ -231,8 +235,9 @@ class openHABSkill(MycroftSkill):
ohItem = self.findItemName(self.lightingItemsDic, messageItem)
if ohItem != None:
if ((command == "set") or (command == "imposta") or (command == "setze") or (command == "pone")):
if ((int(brightValue) < 0) or (int(brightValue) > 100)):
#if ((command == "set") or (command == "imposta") or (command == "setze") or (command == "pone")):
if self.voc_match(command, 'Set'):
if ((brightValue == None) or (int(brightValue) < 0) or (int(brightValue) > 100)):
self.speak_dialog('ErrorDialog')
else:
statusCode = self.sendCommandToItem(ohItem, brightValue)
@ -247,7 +252,8 @@ class openHABSkill(MycroftSkill):
if(brightValue == None):
brightValue = "10"
if ((command == "dim") or (command == "abbassa") or (command == "dimme") or (command == "oscurece")):
#if ((command == "dim") or (command == "abbassa") or (command == "dimme") or (command == "oscurece")):
if self.voc_match(command, 'Dim'):
newBrightValue = curBright-(int(brightValue))
else:
newBrightValue = curBright+(int(brightValue))
@ -277,51 +283,64 @@ class openHABSkill(MycroftSkill):
LOGGER.error("Item not found!")
self.speak_dialog('ItemNotFoundError')
def handle_what_status_intent(self, message):
messageItem = message.data.get('Item')
requestType = message.data.get('RequestType')
def handle_what_status_intent(self, message):
unitOfMeasure = "degree"
infoType = "temperature"
if (self.lang == "it-it"):
unitOfMeasure = "gradi"
infoType = "temperatura"
if (self.lang == "de-de"):
unitOfMeasure = "Grad"
infoType = "Temperatur"
if (self.lang == "es-es"):
unitOfMeasure = "grados"
infoType = "temperatura"
messageItem = message.data.get('item')
LOGGER.debug("Item: %s" % (messageItem))
requestType = message.data.get('requesttype')
LOGGER.debug("Request Type: %s" % (requestType))
unitOfMeasure = self.translate('Degree')
#unitOfMeasure = "degree"
infoType = self.translate('Temperature')
#infoType = "temperature"
# if (self.lang == "it-it"):
# unitOfMeasure = "gradi"
# infoType = "temperatura"
# if (self.lang == "de-de"):
# unitOfMeasure = "Grad"
# infoType = "Temperatur"
# if (self.lang == "es-es"):
# unitOfMeasure = "grados"
# infoType = "temperatura"
self.currStatusItemsDic = dict()
if((requestType == "temperature") or (requestType == "la temperatura") or (requestType == "temperatur") or (requestType == "temperatura")):
#if((requestType == "temperature") or (requestType == "la temperatura") or (requestType == "temperatur") or (requestType == "temperatura")):
if self.voc_match(requestType, 'Temperature'):
self.currStatusItemsDic.update(self.currentTempItemsDic)
elif((requestType == "humidity") or (requestType == "l'umidità") or (requestType == "Feuchtigkeit") or (requestType == "humedad")):
unitOfMeasure = "percentage"
infoType = "humidity"
if (self.lang == "it-it"):
unitOfMeasure = "percento"
infoType = "umidità"
if (self.lang == "de-de"):
unitOfMeasure = "Prozentsatz"
infoType = "Feuchtigkeit"
if (self.lang == "es-es"):
unitOfMeasure = "porciento"
infoType = "humedad"
#elif((requestType == "humidity") or (requestType == "l'umidità") or (requestType == "Feuchtigkeit") or (requestType == "humedad")):
elif self.voc_match(requestType, 'Humidity'):
#unitOfMeasure = "percentage"
unitOfMeasure = self.translate('Percentage')
#infoType = "humidity"
infoType = self.translate('Humidity')
# if (self.lang == "it-it"):
# unitOfMeasure = "percento"
# infoType = "umidità"
# if (self.lang == "de-de"):
# unitOfMeasure = "Prozentsatz"
# infoType = "Feuchtigkeit"
# if (self.lang == "es-es"):
# unitOfMeasure = "porciento"
# infoType = "humedad"
self.currStatusItemsDic.update(self.currentHumItemsDic)
elif((requestType == "status") or (requestType == "lo stato") or (requestType == "Status") or (requestType == "estado")):
infoType = "status"
#elif((requestType == "status") or (requestType == "lo stato") or (requestType == "Status") or (requestType == "estado")):
elif self.voc_match(requestType, 'Status'):
#infoType = "status"
infoType = self.translate('Status')
unitOfMeasure = ""
if (self.lang == "it-it"):
unitOfMeasure = "stato"
if (self.lang == "de-de"):
unitOfMeasure = "Status"
if (self.lang == "es-es"):
unitOfMeasure = "estado"
# if (self.lang == "it-it"):
# unitOfMeasure = "stato"
# if (self.lang == "de-de"):
# unitOfMeasure = "Status"
# if (self.lang == "es-es"):
# unitOfMeasure = "estado"
self.currStatusItemsDic.update(self.switchableItemsDic)
else:
self.currStatusItemsDic.update(self.targetTemperatureItemsDic)
@ -346,13 +365,15 @@ class openHABSkill(MycroftSkill):
ohItem = self.findItemName(self.targetTemperatureItemsDic, messageItem)
if ohItem != None:
if((command == "regulate") or (command == "adjust") or (command == "tune") or (command == "regola") or (command == "aggiusta") or (command == "metti") or (command == "reguliere") or (command == "stell") or (command == "pass") or (command == "regula") or (command == "ajusta") or (command == "afina")):
#if((command == "regulate") or (command == "adjust") or (command == "tune") or (command == "regola") or (command == "aggiusta") or (command == "metti") or (command == "reguliere") or (command == "stell") or (command == "pass") or (command == "regula") or (command == "ajusta") or (command == "afina")):
if self.voc_match(command, 'Regulate'):
statusCode = self.sendCommandToItem(ohItem, tempVal)
newTempValue = tempVal
else:
state = self.getCurrentItemStatus(ohItem)
if ((state != None) and (state.isdigit())):
if ((command == "increase") or (command == "incrementa") or (command == "erhöhe") or (command == "aumenta")):
#if ((command == "increase") or (command == "incrementa") or (command == "erhöhe") or (command == "aumenta")):
if self.voc_match(command, 'Increase'):
newTempValue = int(state)+(int(tempVal))
else:
newTempValue = int(state)-(int(tempVal))

View File

@ -0,0 +1 @@
Fügen Sie Ihre Open Hab Systemkonfiguration auf der Konfigurationsseite hinzu home Punkt mycroft Punkt AI

View File

@ -0,0 +1 @@
Grad

View File

@ -0,0 +1 @@
Feuchtigkeit

View File

@ -0,0 +1 @@
Prozentsatz

View File

@ -0,0 +1 @@
Status

View File

@ -0,0 +1 @@
temperatur

View File

@ -0,0 +1 @@
degree

View File

@ -0,0 +1 @@
humidity

View File

@ -0,0 +1 @@
percentage

View File

@ -0,0 +1 @@
status

View File

@ -0,0 +1 @@
temperature

View File

@ -0,0 +1 @@
agregue la configuración de su sistema open hab en la página de configuración a home punto mycroft punto AI

View File

@ -0,0 +1 @@
grados

View File

@ -0,0 +1 @@
humedad

View File

@ -0,0 +1 @@
porciento

1
dialog/es-es/Status.voc Normal file
View File

@ -0,0 +1 @@
estado

View File

@ -0,0 +1 @@
temperatura

View File

@ -0,0 +1 @@
aggiungi la configurazione del tuo server open hab nella pagina impostazioni su home punto mycroft punto AI

View File

@ -0,0 +1 @@
gradi

View File

@ -1 +1 @@
Mi spiace, non posso ottenere la lista delle cose.
Mi spiace, non posso ottenere la lista delle cose open hab.

View File

@ -0,0 +1 @@
umidità

View File

@ -0,0 +1 @@
percento

View File

@ -0,0 +1 @@
stato

View File

@ -1,3 +1,2 @@
metti {{command}} {{item}}
accendi {{command}} {{item}}
imposta {{command}} {{item}}
messo {{command}} per {{item}}
impostato {{command}} per {{item}}

View File

@ -0,0 +1 @@
temperatura

View File

@ -1,2 +1,2 @@
(setz) (?P<Item>.*) (auf) (?P<BrightPercentage>\d*)(?: Prozent)?
(setz) (?P<Item>.*)(?: auf )?(?P<BrightPercentage>\d+)(?: Prozent)?
(dimme|erhelle) (?P<Item>.*?)\s*(?: um )?(?P<BrightPercentage>\d*)?(?: Prozent)?$

View File

@ -1,2 +1,2 @@
(set) (?P<Item>.*) (to) (?P<BrightPercentage>\d*)(?: percent)?
(dim|bright) (?P<Item>.*?)\s*(?: by )?(?P<BrightPercentage>\d*)?(?: percent)?$
(set) (?P<Item>.*)(?: to )?(?P<BrightPercentage>\d+)(?: percent)?
(dim|bright) (?P<Item>.*?)(?: by )?(?P<BrightPercentage>\d*)?(?: percent)?$

View File

@ -1,2 +1,2 @@
(pone) (?P<Item>.*) (to) (?P<BrightPercentage>\d*)(?: porciento)?
(pone) (?P<Item>.*)(?: al )?(?P<BrightPercentage>\d+)(?: porciento)?
(oscurece|ilumina) (?P<Item>.*?)\s*(?: al )?(?P<BrightPercentage>\d*)?(?: porciento)?$

View File

@ -1,2 +1,2 @@
(imposta) (?P<Item>.*) (al) (?P<BrightPercentage>\d*)(?: percento)?
(imposta) (?P<Item>.*)(?: al )?(?P<BrightPercentage>\d+)(?: percento)?
(abbassa|alza) (?P<Item>.*?)\s*(?: del )?(?P<BrightPercentage>\d*)?(?: percento)?$

1
vocab/de-de/Dim.voc Normal file
View File

@ -0,0 +1 @@
dimme

1
vocab/de-de/Humidity.voc Normal file
View File

@ -0,0 +1 @@
Feuchtigkeit

1
vocab/de-de/Increase.voc Normal file
View File

@ -0,0 +1 @@
erhöhe

3
vocab/de-de/Regulate.voc Normal file
View File

@ -0,0 +1,3 @@
reguliere
stell
pass

1
vocab/de-de/Set.voc Normal file
View File

@ -0,0 +1 @@
setze

1
vocab/de-de/Status.voc Normal file
View File

@ -0,0 +1 @@
Status

View File

@ -0,0 +1 @@
temperatur

1
vocab/de-de/item.entity Normal file
View File

@ -0,0 +1 @@
:0

View File

@ -0,0 +1,6 @@
Status
Temperatur
Feuchtigkeit
eingestellt
reguliert
angepasst

View File

@ -0,0 +1,8 @@
(was ist|wie ist|worauf ist) (der|die|) {item} {requesttype}
(was ist|wie ist|worauf ist) (der|die|) {requesttype} des {item}
Sag mir (der|die|) {item} {requesttype}
Sag mir (der|die|) {requesttype} des {item}
Sag mir wie ist (der|die|) {item} {requesttype}
Ich möchte wissen (der|die|) {item} {requesttype}
Ich möchte wissen (der|die|) {requesttype} des {item}
Ich möchte wissen wie ist (der|die|) {item} {requesttype}

1
vocab/en-us/Dim.voc Normal file
View File

@ -0,0 +1 @@
dim

1
vocab/en-us/Humidity.voc Normal file
View File

@ -0,0 +1 @@
humidity

1
vocab/en-us/Increase.voc Normal file
View File

@ -0,0 +1 @@
increase

3
vocab/en-us/Regulate.voc Normal file
View File

@ -0,0 +1,3 @@
regulate
adjust
tune

1
vocab/en-us/Set.voc Normal file
View File

@ -0,0 +1 @@
set

1
vocab/en-us/Status.voc Normal file
View File

@ -0,0 +1 @@
status

View File

@ -0,0 +1 @@
temperature

1
vocab/en-us/item.entity Normal file
View File

@ -0,0 +1 @@
:0

View File

@ -0,0 +1,6 @@
status
temperature
humidity
adjusted to
regulated to
tuned to

View File

@ -0,0 +1,9 @@
(what's|what is) (the|) {item} {requesttype}
(what's|what is) (the|) {requesttype} of {item}
how (the| ) {item} is {requesttype}
tell me (the|) {item} {requesttype}
tell me (the|) {requesttype} of {item}
tell me how (the|) {item} is {requesttype}
I'd like to know {item} {requesttype}
I'd like to know (the|) {requesttype} of {item}
I'd like to know how (the|) {item} is {requesttype}

1
vocab/es-es/Dim.voc Normal file
View File

@ -0,0 +1 @@
oscurece

1
vocab/es-es/Humidity.voc Normal file
View File

@ -0,0 +1 @@
humedad

1
vocab/es-es/Increase.voc Normal file
View File

@ -0,0 +1 @@
aumenta

3
vocab/es-es/Regulate.voc Normal file
View File

@ -0,0 +1,3 @@
regula
ajusta
afina

1
vocab/es-es/Set.voc Normal file
View File

@ -0,0 +1 @@
pone

1
vocab/es-es/Status.voc Normal file
View File

@ -0,0 +1 @@
estado

View File

@ -0,0 +1 @@
temperatura

1
vocab/es-es/item.entity Normal file
View File

@ -0,0 +1 @@
:0

View File

@ -0,0 +1,4 @@
estado
temperatura
humedad
ajustes

View File

@ -0,0 +1,3 @@
(el elemento|) {item} (qué|cuál) {requesttype} tiene
Quiero saber (qué|cuál|cómo|) (el elemento|) {item} {requesttype} tiene
dime (qué|cuál|cómo|) (el elemento|) {item} {requesttype} (tiene|)

1
vocab/it-it/Dim.voc Normal file
View File

@ -0,0 +1 @@
abbassa

1
vocab/it-it/Humidity.voc Normal file
View File

@ -0,0 +1 @@
l'umidità

1
vocab/it-it/Increase.voc Normal file
View File

@ -0,0 +1 @@
incrementa

View File

@ -1,2 +1,4 @@
aggiorna elementi openhab
aggiorna elementi open hab
aggiorna elementi open hab
aggiorna gli elementi di openhab
aggiorna gli elementi di open hab

3
vocab/it-it/Regulate.voc Normal file
View File

@ -0,0 +1,3 @@
regola
aggiusta
metti

1
vocab/it-it/Set.voc Normal file
View File

@ -0,0 +1 @@
imposta

1
vocab/it-it/Status.voc Normal file
View File

@ -0,0 +1 @@
lo stato

View File

@ -0,0 +1 @@
la temperatura

1
vocab/it-it/item.entity Normal file
View File

@ -0,0 +1 @@
:0

View File

@ -0,0 +1,6 @@
lo stato
la temperatura
l'umidità
messo
regolato
impostato

View File

@ -0,0 +1,3 @@
(quale è|qual'è|com'è|come è) {requesttype} {item}
vorrei sapere (quale è|qual'è|com'è|come è|) {requesttype} {item}
dimmmi (quale è|qual'è|com'è|come è|) {requesttype} {item}