v19 code review (#85)
parent
725bc7f1a9
commit
800565d5fe
13
README.md
13
README.md
|
@ -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
|
||||
|
|
39
USAGE.md
39
USAGE.md
|
@ -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
|
||||
|
||||
|
|
113
__init__.py
113
__init__.py
|
@ -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))
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fügen Sie Ihre Open Hab Systemkonfiguration auf der Konfigurationsseite hinzu home Punkt mycroft Punkt AI
|
|
@ -0,0 +1 @@
|
|||
Grad
|
|
@ -0,0 +1 @@
|
|||
Feuchtigkeit
|
|
@ -0,0 +1 @@
|
|||
Prozentsatz
|
|
@ -0,0 +1 @@
|
|||
Status
|
|
@ -0,0 +1 @@
|
|||
temperatur
|
|
@ -0,0 +1 @@
|
|||
degree
|
|
@ -0,0 +1 @@
|
|||
humidity
|
|
@ -0,0 +1 @@
|
|||
percentage
|
|
@ -0,0 +1 @@
|
|||
status
|
|
@ -0,0 +1 @@
|
|||
temperature
|
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
grados
|
|
@ -0,0 +1 @@
|
|||
humedad
|
|
@ -0,0 +1 @@
|
|||
porciento
|
|
@ -0,0 +1 @@
|
|||
estado
|
|
@ -0,0 +1 @@
|
|||
temperatura
|
|
@ -0,0 +1 @@
|
|||
aggiungi la configurazione del tuo server open hab nella pagina impostazioni su home punto mycroft punto AI
|
|
@ -0,0 +1 @@
|
|||
gradi
|
|
@ -1 +1 @@
|
|||
Mi spiace, non posso ottenere la lista delle cose.
|
||||
Mi spiace, non posso ottenere la lista delle cose open hab.
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
umidità
|
|
@ -0,0 +1 @@
|
|||
percento
|
|
@ -0,0 +1 @@
|
|||
stato
|
|
@ -1,3 +1,2 @@
|
|||
metti {{command}} {{item}}
|
||||
accendi {{command}} {{item}}
|
||||
imposta {{command}} {{item}}
|
||||
messo {{command}} per {{item}}
|
||||
impostato {{command}} per {{item}}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
temperatura
|
|
@ -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)?$
|
||||
|
|
|
@ -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)?$
|
||||
|
|
|
@ -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)?$
|
||||
|
|
|
@ -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)?$
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
dimme
|
|
@ -0,0 +1 @@
|
|||
Feuchtigkeit
|
|
@ -0,0 +1 @@
|
|||
erhöhe
|
|
@ -0,0 +1,3 @@
|
|||
reguliere
|
||||
stell
|
||||
pass
|
|
@ -0,0 +1 @@
|
|||
setze
|
|
@ -0,0 +1 @@
|
|||
Status
|
|
@ -0,0 +1 @@
|
|||
temperatur
|
|
@ -0,0 +1 @@
|
|||
:0
|
|
@ -0,0 +1,6 @@
|
|||
Status
|
||||
Temperatur
|
||||
Feuchtigkeit
|
||||
eingestellt
|
||||
reguliert
|
||||
angepasst
|
|
@ -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}
|
|
@ -0,0 +1 @@
|
|||
dim
|
|
@ -0,0 +1 @@
|
|||
humidity
|
|
@ -0,0 +1 @@
|
|||
increase
|
|
@ -0,0 +1,3 @@
|
|||
regulate
|
||||
adjust
|
||||
tune
|
|
@ -0,0 +1 @@
|
|||
set
|
|
@ -0,0 +1 @@
|
|||
status
|
|
@ -0,0 +1 @@
|
|||
temperature
|
|
@ -0,0 +1 @@
|
|||
:0
|
|
@ -0,0 +1,6 @@
|
|||
status
|
||||
temperature
|
||||
humidity
|
||||
adjusted to
|
||||
regulated to
|
||||
tuned to
|
|
@ -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}
|
|
@ -0,0 +1 @@
|
|||
oscurece
|
|
@ -0,0 +1 @@
|
|||
humedad
|
|
@ -0,0 +1 @@
|
|||
aumenta
|
|
@ -0,0 +1,3 @@
|
|||
regula
|
||||
ajusta
|
||||
afina
|
|
@ -0,0 +1 @@
|
|||
pone
|
|
@ -0,0 +1 @@
|
|||
estado
|
|
@ -0,0 +1 @@
|
|||
temperatura
|
|
@ -0,0 +1 @@
|
|||
:0
|
|
@ -0,0 +1,4 @@
|
|||
estado
|
||||
temperatura
|
||||
humedad
|
||||
ajustes
|
|
@ -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|)
|
|
@ -0,0 +1 @@
|
|||
abbassa
|
|
@ -0,0 +1 @@
|
|||
l'umidità
|
|
@ -0,0 +1 @@
|
|||
incrementa
|
|
@ -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
|
|
@ -0,0 +1,3 @@
|
|||
regola
|
||||
aggiusta
|
||||
metti
|
|
@ -0,0 +1 @@
|
|||
imposta
|
|
@ -0,0 +1 @@
|
|||
lo stato
|
|
@ -0,0 +1 @@
|
|||
la temperatura
|
|
@ -0,0 +1 @@
|
|||
:0
|
|
@ -0,0 +1,6 @@
|
|||
lo stato
|
||||
la temperatura
|
||||
l'umidità
|
||||
messo
|
||||
regolato
|
||||
impostato
|
|
@ -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}
|
Reference in New Issue