10000 [EN] Extended light set sentences by onedashone · Pull Request #3140 · home-assistant/intents · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[EN] Extended light set sentences #3140

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

onedashone
Copy link

Extends the list of sentences that can trigger light_HassLightSet intent to include the brightness synonyms "light" and "lights".

all uses of the word "brightness" are now mapped to the expansion rule brightness_synonyms. Results in some minor odd sounding acceptable sentences such as "set the lights of the bedroom to 50% lights" but with the added benefit of the following sentences:
"set the lights in the bedroom to 50%"
"set the bedroom lights to the max"
"set the bedroom lamp to minimum light"

Change to expansion rule also allows for trivial addition of other brightness synonyms such as "illumination" or "luminosity" for those with a finer word palette. Anything unique enough for the system to infer that the intent must be light based.

Added tests duplicate brightness cases but with intermittent changes with either the word "light" or "lights" to avoid a complete duplication of tests for each synonym.

…<brightness_synonyms>' that allows for synonyms to brightness like 'light' or 'lights'. Removed duplicate sentances from tests.
Copy link
@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @onedashone

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant home-assistant bot marked this pull request as draft April 19, 2025 04:00
@home-assistant
Copy link
8000

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@onedashone onedashone marked this pull request as ready for review April 21, 2025 05:09
@andreasbrett andreasbrett changed the title Extended light set sentences [EN] Extended light set sentences Apr 21, 2025
@tetele
Copy link
Contributor
tetele commented Apr 22, 2025

@mrdarrengriffin @ViViDboarder please double check

@@ -376,6 +376,7 @@ expansion_rules:
are_any: "[<are>] <any>"
how_many: "how many [of <the>]"
brightness: "{brightness}[([ ]%)| percent]"
brightness_synonyms: "(brightness|light[s])"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to use the expansion rule for lights here?

Copy link
Author
@onedashone onedashone Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This excellent question led me down a much longer path than I originally anticipated. In short, swapping out "light[s]" with "<light>" better aligns with the current setup for the light_HassTurnOff and light_HassTurnOn sentence structures. However, once I started adding some additional tests to cover the additions "<light>" would create, I quickly realized that simply swapping out "brightness" with "<brightness_synonyms>" wasn't a good long term solution.

My new commit tries to clearly differentiate between words that define general light entities and words used as a measurement of light like brightness.

@onedashone
Copy link
Author

@mrdarrengriffin @ViViDboarder @tetele I did a pretty big overhaul to the branch that probably warrants a review. If my changes cause too many concerns, I'll revert to my last commit and simply implement mrdarrengriffin's suggestion. Here's a quick rundown of the changes:

  1. Further cleaned up tests as well as added some new tests to go along with other options that can be introduced by words in .
  2. Added "here" and "in here" to the common's list of skip_words to simplify light_HassLightSet's sentence structure.
  3. Attempted to clean up the sentence structures in light_HassLightSet for brightness changes.

The changes to sentence structure comes down to this:

  1. Sentences either deal with modifying an entity, a general area (area/floor), or the implied current environment.
  2. Sentences for each scenario are now permutations structured as (what's being effected);(what value is being set);(an optional unit of measurement).
  3. The setting of lights to specific brightness-es or max/min values have been combined into a localized expansion rule.

@onedashone
Copy link
Author

Just realized the update to skip_words caused a few tests outside of light_HassLightSet to fail. Should be pretty easy to fix if it's anything like the change I had to make for light_HassLightSet. I'll look into that soon.

Copy link
Contributor
@tetele tetele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really glad you want to make this work well, covering all use cases. There are some things you may have not been aware about, i've underlined them in comments.

- "[<numeric_value_set>] <name> brightness [to] <brightness>"
- "[<numeric_value_set>] [the] brightness [of] <name> [to] <brightness>"
- "[<numeric_value_set>] <name> [to] <brightness> [brightness]"
- "[<numeric_value_set>] ([of] <name>;<light_value>;[[the] <brightness_synonyms>])"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although i am a fan of contraction, this template is excessive. I'll underline the issues.

  1. In a permutation, having a completely optional member is a no-no. The reason for that is that there are too many generated variants which would match.

As an example, (a;b;[c]) expands into 6 variants: a b [c], a [c] b, b a [c], b [c] a, [c] a b and [c] b a. Of those, when c is missing, 3 variants will match a b: a b [c], a [c] b and [c] a b, which is way too many.

Now, if c is another expanding template, that will break into many more other variants which will match, and hassil will check them all.

TL;DR: as a general rule of thumb, don't add completely optional parts to a permutation.

  1. Your proposed sentence would match stuff like set of living room lights to 43 percent the brightness or, worse still, set 43% of the living room lights to light, which doesn't make sense.

All templates you add should NOT match any sentence you don't want to match. That's the reason they were split into 3 templat 8000 es originally.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see what you mean about the permutation issues. I made sure to split up sentences further so optional permutations don't exist as well as tried to prevent sentences like you used in your second bullet point from occurring.

- "[<numeric_value_set>] <name> brightness to [the] {brightness_level:brightness}"
- "[<numeric_value_set>] [the] brightness of <name> to [the] {brightness_level:brightness}"
- "[<numeric_value_set>] <name> [to] [the] {brightness_level:brightness} brightness"
light_value: "[to] (<brightness>|[the] {brightness_level:brightness})"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd extract [to] into the encompassing sentence and leave just the light value in this expansion rule, to make it clearer.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10000

Done!

- "[<numeric_value_set>] [the] brightness of <area> to [the] {brightness_level:brightness}"
- "[<numeric_value_set>] <area> brightness to [the] {brightness_level:brightness}"
- "[<numeric_value_set>] <area> [to] [the] {brightness_level:brightness} brightness"
- "[<numeric_value_set>] ([of] [(<all>|<the>)] <location>;<light_value>;[[the] <brightness_synonyms>])"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is getting very hard to read. I'll happily review it after you'll have fixed the split i mentioned earlier and apply the same to these.

- "[<numeric_value_set>] <area> [to] [the] {brightness_level:brightness} brightness"
- "[<numeric_value_set>] ([of] [(<all>|<the>)] <location>;<light_value>;[[the] <brightness_synonyms>])"
expansion_rules:
location: "([<light>];[<in>] (<area>|<floor>))"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an <in_area_floor> expansion rule you can use.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Swapped out [<in>] (<area>|<floor>) with <in_area_floor>.

expansion_rules:
in_here: "[in] here"
light_value: "[to] (<brightness>|[the] {brightness_level:brightness})"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be a global expansion rule, if it keeps repeating?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went ahead and moved light_value to the global expansion rule set.
Also, I went ahead and just removed "here" and "in here" from the global skip_words and further updated the templates to still account for those words showing up in sentences.

@home-assistant home-assistant bot marked this pull request as draft April 24, 2025 06:45
@onedashone onedashone marked this pull request as ready for review April 25, 2025 03:20
@home-assistant home-assistant bot requested a review from tetele April 25, 2025 03:20
- "[<numeric_value_set>] [the] brightness [of] <name> [to] <brightness>"
- "[<numeric_value_set>] <name> [to] <brightness> [brightness]"
- "[<numeric_value_set>] ([of] <name>;[to] <light_value>)"
- "[<numeric_value_set>] ([of] <name>;[to] <light_value>;[the] <brightness_synonyms>)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Your proposed sentence would match stuff like set of living room lights to 43 percent the brightness or, worse still, set 43% of the living room lights to light, which doesn't make sense.

All templates you add should NOT match any sentence you don't want to match. That's the reason they were split into 3 templates originally.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New push prevents the second command example from occurring.

The idea of permutation stops making sense to me if the first example isn't acceptable. It might also be worth considering simply making all articles and prepositions part of the skip_words list if the goal is to significantly reduce sentence combinations across the board. One upgrade at a time though.

@home-assistant home-assistant bot marked this pull request as draft April 28, 2025 07:11
@onedashone onedashone marked this pull request as ready for review May 2, 2025 01:49
@home-assistant home-assistant bot requested a review from tetele May 2, 2025 01:49
Copy link
Contributor
@tetele tetele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, I've been on a small vacation.

- "[<numeric_value_set>] [the] brightness to <brightness>"
- "[<numeric_value_set>] [the] brightness (<in_here>;to <brightness>)"
- "[<numeric_value_set>] ([of] [(<all>|<the>)] <location>;[to] <light_value>)"
- "[<numeric_value_set>] ([of] [(<all>|<the>)] <location>;[the] <brightness_synonyms>) [to] <light_value>"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would match set the upstairs light light to 50%. I don't really think that <location> should contain <light> 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is one of those sentence types that are grammatically correct but sound pretty weird since "light" works both as a way of defining objects that produce luminescence and a unit of measurement for luminescence; similar to saying something like the orange orange. Sure, set the upstairs light light sounds weird; but, set the upstairs upstairs lamp light still makes sense to say despite probably fitting better in the Victorian era.

While there are some ways to clean this up, I don't think removing <light> from <location> is a good idea. It's the whole reason I created this pull request in the first place since there wasn't a way before to say a command like set the lights to 50% which we can do when strictly turning lights on and off.

Personally I'd like to leave this as is; but if that would prevent this from getting accepted, what I'd recommend doing instead is removing "light" as a brightness synonym instead and removing any test sentences that depended on that. Something like light light couldn't happen anymore but we still would maintain backwards compatibility with the voice commands for turning lights on and off while only losing sentences that are less likely to be missed such as set bedroom to 50% light.

@home-assistant home-assistant bot marked this pull request as draft May 8, 2025 17:16
@onedashone onedashone marked this pull request as ready for review May 9, 2025 15:45
@home-assistant home-assistant bot requested a review from tetele May 9, 2025 15:45
Comment on lines 27 to 28
- "[<numeric_value_set>] [<the>] <light> ([to] <brightness_value>;<here>)"
- "[<numeric_value_set>] [(<all>|<the>)] <light> ([to] <brightness_value>;<here>)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can be contracted, right?

Suggested change
- "[<numeric_value_set>] [<the>] <light> ([to] <brightness_value>;<here>)"
- "[<numeric_value_set>] [(<all>|<the>)] <light> ([to] <brightness_value>;<here>)"
- "[<numeric_value_set>] [(<all>|<the>)] <light> ([to] <brightness_value>;<here>)"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, another good catch. I went ahead and made this change as well as the similar suggestion below.

Comment on lines 31 to 32
- "[<numeric_value_set>] [<the>] <light> (([to] <brightness_value>;<brightness_synonyms>);<here>)"
- "[<numeric_value_set>] [(<all>|<the>)] <light> (([to] <brightness_value>;<brightness_synonyms>);<here>)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- "[<numeric_value_set>] [<the>] <light> (([to] <brightness_value>;<brightness_synonyms>);<here>)"
- "[<numeric_value_set>] [(<all>|<the>)] <light> (([to] <brightness_value>;<brightness_synonyms>);<here>)"
- "[<numeric_value_set>] [(<all>|<the>)] <light> (([to] <brightness_value>;<brightness_synonyms>);<here>)"

expansion_rules:
in_here: "[in] here"
- "[<numeric_value_set>] ([to] <brightness_value>;[the] <brightness_synonyms>)"
- "[<numeric_value_set>] ([to] <brightness_value>;[the] <brightness_synonyms>;<here>)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too permissive, I think
set to 50% here the brightness
set here to 50% the brightness

Maybe this is better?

Suggested change
- "[<numeric_value_set>] ([to] <brightness_value>;[the] <brightness_synonyms>;<here>)"
- "[<numeric_value_set>] ([to] <brightness_value>;[the] <brightness_synonyms> [<here>])"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. Went ahead and made this suggested change as well and updated a few of the tests accordingly.

@home-assistant home-assistant bot marked this pull request as draft May 12, 2025 15:08
@onedashone onedashone marked this pull request as ready for review May 14, 2025 02:38
@home-assistant home-assistant bot requested a review from tetele May 14, 2025 02:38
Copy link
Contributor
@tetele tetele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrdarrengriffin @ViViDboarder please take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0