-
-
Notifications
You must be signed in to change notification settings - Fork 431
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
[voice] Support custom rules on item metadata #3897
Conversation
|
@dalgwen after these PR you can use the standard interpreter to create custom rules that target items by its tags or semantic as you ask once in the forum. Thank you for bringing the idea to the table. |
b5fc996
to
c4ccf7b
Compare
65ea767
to
3624682
Compare
Signed-off-by: Miguel Álvarez <[email protected]>
Closed by error, I reverted a couple of lines in the getMatchingItems method because of a bug I just discover testing it, I have rebased the change into a single commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, just some minor syntax requests.
...enhab.core.voice/src/main/java/org/openhab/core/voice/text/AbstractRuleBasedInterpreter.java
Outdated
Show resolved
Hide resolved
...enhab.core.voice/src/main/java/org/openhab/core/voice/text/AbstractRuleBasedInterpreter.java
Outdated
Show resolved
Hide resolved
...enhab.core.voice/src/main/java/org/openhab/core/voice/text/AbstractRuleBasedInterpreter.java
Outdated
Show resolved
Hide resolved
...enhab.core.voice/src/main/java/org/openhab/core/voice/text/AbstractRuleBasedInterpreter.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core.voice/src/main/resources/LanguageSupport_es.properties
Outdated
Show resolved
Hide resolved
Signed-off-by: Miguel Álvarez <[email protected]>
Signed-off-by: Miguel Álvarez <[email protected]>
Thank you for the review! |
Signed-off-by: Miguel Álvarez <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/dialog-processing-with-the-pulseaudiobinding/148191/1 |
Refs openhab/openhab-core#3925, openhab/openhab-core#3897 and openhab/openhab-core#3853. --------- Signed-off-by: Miguel Álvarez <[email protected]>
Hello OpenHAB maintainers, I would like to merge these PR which is a continuation of #3853 to include support for custom rules declared on the item metadata namespace voice system.
It introduces a breaking change over it because it changes the dynamic token from
*
to$*$
. These way it looks similar to the other supported special tokens$name$
and$cmd$
.I let here a small summary of the interpreter functionality after these PR.
BR
The Standard Interpreter
The built-in text rule engine in OpenHAB.
Target item resolution
The interpreter resolves the item name based on the its label/synonyms and it's parent label/synonyms.
An example of the possible situations will be:
If you have
Group
item labeled asTV
with aDimmer
childBrightness
.The interpreter understands these phrases as the same
turn off tv
,turn off brightness
,turn off tv brightness
andturn off brightness tv
.If you add a Switch child labeled as
Power
to the group.The interpreter understands now also the phrases
turn off power
,turn off tv power
andturn off power tv
.But the
turn off tv
phase now detect a collision because two matching items accept theOFF
command.Name prevalence
One way you can solve this is by using the name prevalence, items with start with other items names take prevalence over them.
If the Switch item has the name
tv
and the and Dimmer item the nametv_brightness
there will be no collisions between them and theOFF
command will target the Switch item.Exact match label/synonym prevalence
Other way you can solve this is by using the exact match prevalence, items with have an exact match on their label/synonyms take prevalence.
If the Switch item has the synonym
TV
there will be no collisions between them and theOFF
command will target the Switch item.Location prevalence
The dialog processor forward its locationItem to the standard interpreter to be used for reducing collisions on the target resolution.
If you have two items labeled as
Light
but one is a child of the location item you have configured for the dialog execution, the item takes prevalence.The location takes prevalence over an exact match.
Built-in rules
The interpreter includes built-in rules for English, German, French, Italian and Spanish for common uses cases like.
Implementation could be found in the standard interpreter source code.
Examples:
Item description rules
The interpreter also creates rules for your item descriptions for English, German, French, Italian and Spanish.
If you have a Dimmer item called
Light
with command description100=high
the interpreter will also understand the phraseSet light to high
.Item custom rules.
You can register custom rules into the interpreter using items and the metadata namespace
voice-system
.The examples of valid values:
As you can see there are some reserved tokens and characters:
$name$
defines the place of the item name (resolved as explained before), is optional.$cmd$
defines the place of a command label, extracted from the item command description.$*$
defines the place of a command, whose value is not constrained.|
defines alternative word tokens.?
defines optional word token.The item metadata namespace
voice-system
allows two possible configurations:Note that if the
isTemplate
config is false, the rule target is limited to the item that registers it. When it's true the item registering the rule gets excluded of matching with it.Note that when you use the option
isTemplate
in rules without the$name$
token, collisions are still solved based on location. So you can have aplay $cmd$ here
rule which is scoped to the dialog location.There are some limitations:
$cmd$
or$*$
but not both.$name$
and$*$
should have at least one non optional token between them.$name$
or$*$
, neither by them prefixed only of optional tokens.$name$
,$cmd$
or$*$
multiple times.