Skip to content

Feature/rgb lights#69

Open
xiki808 wants to merge 16 commits into
MycroftAI:20.08from
xiki808:feature/rgb-lights
Open

Feature/rgb lights#69
xiki808 wants to merge 16 commits into
MycroftAI:20.08from
xiki808:feature/rgb-lights

Conversation

@xiki808

@xiki808 xiki808 commented Mar 6, 2021

Copy link
Copy Markdown

Say: change boxroom light to blue - to trigger the color change.

The 'to' is key, that separates the entity from the color, and so it allows for example: change boxroom light TO light blue.

@Tony763

Tony763 commented Mar 6, 2021

Copy link
Copy Markdown

Nice, I will send you a PR with Czech translation tomorrow.

@Tony763

Tony763 commented Mar 8, 2021

Copy link
Copy Markdown

@xiki808 PR sended.

@stratus-ss

Copy link
Copy Markdown
Collaborator

I'll take a look at this shortly.

We are trying to encourage people to put more effort into the descriptions of the pull requests. We made a video about it here

@stratus-ss

Copy link
Copy Markdown
Collaborator

This one passes all the tests which is expected.

The all function also works as expected and individual lights also work as expected

However, I dont know if this is a problem with this PR or the skill itself, but when I call an entity that doesn't exist it seems to grab a random light... for example:

change bathroom light to orange                                 --- 0.21
 >> LaundryRoom changed to orange.  
change outside light to green                             
 >> Steve's Bed Light is  unavailable.

Do you have the same results @xiki808 ?

@stratus-ss

Copy link
Copy Markdown
Collaborator

Let's get some tests added for the new functionality. You can find the existing tests under homeassistant.mycroftai/test/intent

Let us know if you need help with that!

@Tony763

Tony763 commented Apr 18, 2021

Copy link
Copy Markdown

@xiki808 If you need help with tests, ping me.

@xiki808

xiki808 commented Apr 18, 2021

Copy link
Copy Markdown
Author

Thanks guys, will have a look into this early this week.

@xiki808

xiki808 commented Apr 21, 2021

Copy link
Copy Markdown
Author

@stratus-ss For me it is working fine, I tried the following:

change test light to blue
>> Changed Test to blue.
change desk light to red
>> Sorry, I can't find the Home Assistant entity "desk light".
change test light to red
>> Changed Test to red.
turn off test
>> turned Test off.
change test to red
>> Test changed to red.
turn off test
>> turned off Test.
change desk to blue
>> Excuse me, I wasn't able to find "desk".

I will try to find some time to try with the same naming.

@xiki808

xiki808 commented Apr 21, 2021

Copy link
Copy Markdown
Author

@Tony763 would love it if you can handle the test, I cannot see how to run and check my test intent.

@Tony763

Tony763 commented Aug 18, 2021

Copy link
Copy Markdown

Hi @xiki808 , Kris just merged two of my commits so there is a conflict in init.py now, but I can't see it. Please, check it and try to fix or send me a screenshot. Maybe a fetching upstream could be sufficient. If anything, I will gladly help.

@xiki808

xiki808 commented Aug 18, 2021

Copy link
Copy Markdown
Author

I don't have the setup currently, been using the Pi for other projects. I will try to reinstall Mycroft next week and check it!

@Tony763

Tony763 commented Sep 23, 2021

Copy link
Copy Markdown

Hi @xiki808 were you able to reinstall Mycroft? If not, could I help you?

@xiki808

xiki808 commented Sep 27, 2021

Copy link
Copy Markdown
Author

Hi @Tony763, I haven't had the time yet, but will find some time this week

@Tony763

Tony763 commented Sep 27, 2021

Copy link
Copy Markdown

Hi @krisgesling, merge issue solved and tested. Seems Ok to me.
image

@krisgesling krisgesling left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey, a great new feature, thanks!

A few suggestions below. I'm also wondering if deleting the .gitignore file was intentional?

Comment thread __init__.py Outdated
Comment on lines +232 to +237
if "all" in entity_parts:
voc_match = "all lights"

if self.voc_match(voc_match, "all_lights"):
ha_data = {'entity_id': 'all'}
ha_entity = {'dev_name': 'all lights'}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

So presently if you said:

Change all kitchen lights to green

That would see "all" and set the entity to "all lights" which presumably be all lights in the house?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, doesn't make sense, I removed the 'all' catch phrase

Comment thread __init__.py Outdated
ha_data = {'entity_id': ha_entity['id']}

color = message.data['color']
color_parts = list(color.split())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does color_parts get used at all?
If not the previous line can probably be removed also.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Cleaned.

Comment thread __init__.py Outdated
if not ha_entity or not self._check_availability(ha_entity):
return

ha_data = {'entity_id': ha_entity['id']}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'd love if we could find a more descriptive name for this ha_data object.

action_data?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated.

@Tony763

Tony763 commented Sep 28, 2021

Copy link
Copy Markdown

Hi @xiki808 and @krisgesling I tested it again with latest commit and it's working.

I have only one thing that could be improved. When I ask Mycroft to change color of light that does not support colors, it still say that color was changed.

Found entity_id contain attributes and for lights there is supported_color_mode.

if state['entity_id'].split(".")[0] in types:

Without support:
image

With support:
image

As defined in HA light, color can be changed only when at least one of hs, xy, rgb, rgbw, rgbww modes is present and if not, Mycroft could inform uses that color change is not supported.

https://github.com/home-assistant/core/blob/bc59387437cea91d675584bb9057338aa5992817/homeassistant/components/light/__init__.py#L53-L64

I would suggest to pass whole attributes dictionary to __init__.py as same thing will more-less be happening in future with others intents.

What do You think?

@stratus-ss

Copy link
Copy Markdown
Collaborator

How does this handle rgbww and/or rgbw?

@Tony763

Tony763 commented Sep 28, 2021

Copy link
Copy Markdown

Hi @stratus-ss , long not hear from You :). Color is directly passed to HA, so handling is done in side HA not in skill.
image

This way with rgbw and rgbww only rgb part is controlled. White and temperature of white is omitted. If its on, it stay on or off. Brightness of color can be controlled by set intensity intent.

image

Although I just realized that this will perfectly work in English. But in other languages, HA will not understood to color names!

@stratus-ss

Copy link
Copy Markdown
Collaborator

Let me see if I can carve out some time this week to test this out now that you folks have been doing some good cleanup work

@Extarys

Extarys commented Sep 30, 2021

Copy link
Copy Markdown

For the color issue, is there a way to make a dummy mycroft skill so users can translate the colors name on Mycroft Translate and use those inside other skills?

@krisgesling

Copy link
Copy Markdown

Hey @Extarys - that's not a bad idea

You could make a Color Skill that displays the color along with the RGB and/or hex values. Submit this to the Marketplace and it will get added to translate.mycroft.ai, you can then poach the translated colors back out of it.

@Tony763

Tony763 commented Oct 1, 2021

Copy link
Copy Markdown

Or maybe we could try auto translate. I have seen it in some other skill. One word translation should not be big challenge.

@stratus-ss

Copy link
Copy Markdown
Collaborator

The CSS3 color spec has 140(ish) colors that might be hard to translate one at a time

@Extarys

Extarys commented Oct 4, 2021

Copy link
Copy Markdown

@stratus-ss I wouldn't mind translating them in my own language, it would not take that much time and the CSS color name has never changed much. so it would be once per language and would last 25+ year 😂 Of course it wouldn't be done in 5 minutes so it still require some efforts.

Ppl can probably use LibreTranslate or Google Translate too as it should be simple for those automated tools - it's not a complicated sentence or something.

Very Mycroft noob so not sure how the auto translate thing would work, but I have no idea how to make a plugin so I would probably leave that to a user who wont take a month to make it 😄 but I won't mind translating it in french and then other languages with automated tools.

@Tony763

Tony763 commented Oct 4, 2021

Copy link
Copy Markdown

I have seen auto translate function in one of skills I translated last year. It was quite easy to use. I will try to find it and we can try it and compare results.

@stratus-ss

stratus-ss commented Oct 15, 2021

Copy link
Copy Markdown
Collaborator

Gez and I were discussing this one and we were wondering how non-english speakers would handle most of the colors. For example "light golden rod" or similar words would not translate automatically and would require someone versed in colours to be able to translate them appropriately.

Speaking for myself I dont know what colours most of these are (just reading the names) and I am a native speaker. So the question is, would users learn their native words for these bizarre colours, or would they just learn the english name and call it a day?

@krisgesling

Copy link
Copy Markdown

Also wanted to flag that we've started a Color Picker Skill for an upcoming video series - so we can get an early MVP version of that into the Marketplace and start getting colors translated if it would be helpful.

Currently the colors are included as their exact CSS3 forms eg "lightgoldenrodyellow" rather than "light golden rod yellow" but thinking through the best way to approach this and hence the question above.

If you're a German speaker and want to change your lights to a "lightgoldenrodyellow" color (#fafad2), what would you say?

@krisgesling

Copy link
Copy Markdown

I've updated the color names to have spaces - much easier to remove spaces programmatically.

It's also nearing an MVP so should be able to push it to the Marketplace soonish. It's here if you want to check it out:
https://github.com/krisgesling/color-picker-skill

@Extarys

Extarys commented Oct 30, 2021

Copy link
Copy Markdown

Nice! I don't see it yet on https://translate.mycroft.ai/ but I'll help translating to french as soon as I see it there ❤️

@pfefferle

Copy link
Copy Markdown

Is there something I can help to get this merged?

@krisgesling

Copy link
Copy Markdown

@pfefferle if you can verify the functionality works as expected that would be great. It didn't seem to be working for @stratus-ss but there might have been updates since that comment

It would be great to add a check to see if the given device supports color as suggested by Tony here:
#69 (comment)

But I'd be comfortable with that being a follow up PR.

@arborealfirecat

Copy link
Copy Markdown

Hey all, sorry to necro an old PR, but are you still open to merging this functionality? If so I'm happy to pick it up and finish off the last bits of the PR?

@stratus-ss

Copy link
Copy Markdown
Collaborator

Hey all, sorry to necro an old PR, but are you still open to merging this functionality? If so I'm happy to pick it up and finish off the last bits of the PR?

@krisgesling and I are still floating around. Speaking for myself, I don't mind continuing to approve PRs

@stratus-ss

Copy link
Copy Markdown
Collaborator

I re-looked at this. There is a lot of whitespace noise in this PR.

overall I don't have any major concerns. If there is still interest and the original author isn't involved we can get a new PR opened

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants