Skip to content

Added effects to Yeelight bulbs#7152

Merged
balloob merged 7 commits into
home-assistant:devfrom
Mister-Espria:yeelight-adding-effects
Jun 3, 2017
Merged

Added effects to Yeelight bulbs#7152
balloob merged 7 commits into
home-assistant:devfrom
Mister-Espria:yeelight-adding-effects

Conversation

@Mister-Espria
Copy link
Copy Markdown
Contributor

@Mister-Espria Mister-Espria commented Apr 17, 2017

Description:

This PR is now reopened, because there are now effects implemented in the yeelight module version 3.0.0.
I did update the original code of this PR to support the newly implemented effects.

Any suggetions/improvements are welcome of course.

PR text before closing:

Added some basic effects to Yeelight bulbs. Deleted requirement for the bulb to be in a specific colormode in order to use flash parameter.

There are three different type of effects added:

  1. Predefined colors and brightness;
  2. Predefined colors with current brightness;
  3. Random colors with current brightness.

I also did a "stop" effect which stops the effect and returns to the previous state.
I did add this to the effectlist i don't know if this is the best approach as it is not really an effect.

This is my first PR ever. So if i did something wrong please tell me. So i can improve it.
Also i would like to thank @armills for all his help!

Related issue (if applicable): fixes #

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>

Example entry for configuration.yaml (if applicable):

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@mention-bot
Copy link
Copy Markdown

@Mister-Espria, thanks for your PR! By analyzing the history of the files in this pull request, we identified @rytilahti, @jjensn and @HydrelioxGitHub to be potential reviewers.

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @Mister-Espria,

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!

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @Mister-Espria,

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!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you mean duration=2000 here, not 200

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes typo i will fix it!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You want randrange(0, 256) or randint(0, 255)

Copy link
Copy Markdown
Contributor Author

@Mister-Espria Mister-Espria Apr 17, 2017

Choose a reason for hiding this comment

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

random.randrange(0, 255) is used in the flux component. i did't give it any thought. So i should change it into random.randint(0, 255) right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, if you want 255 as a possible outcome. Not that anyone will be able to tell the difference 😃

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nope but then it is as random as it can get 😄 . So i will change it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think that the logic for the effects should be located in the yeelight module itself. This way the effects can be maintained at one place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your response. I think you are right, that the best place for it is in the yeelight module. I have tried to make a start with adding it there. But with trial and error i'm getting nowhere. I have no clue on how to start the implementation there. I will still be trying, but i'm not certain i will get it done 😃
What do you want me to do with this PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is being discussed here: https://gitlab.com/stavros/python-yeelight/issues/11 so I'd propose closing this PR for now and reopening/creating a new one after the implementation hits the upstream :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok. I will do that now. Thank you.

@Mister-Espria
Copy link
Copy Markdown
Contributor Author

Mister-Espria commented May 14, 2017

I'm re-opening this PR, because there are now effects implemented in the yeelight module.
Will be adding changes shortly!
Edit: Done!

@Mister-Espria Mister-Espria reopened this May 14, 2017
@Mister-Espria Mister-Espria changed the title Added effects to Yeelight bulbs WIP:Added effects to Yeelight bulbs May 14, 2017
@Mister-Espria Mister-Espria changed the title WIP:Added effects to Yeelight bulbs Added effects to Yeelight bulbs May 14, 2017
EFFECT_TWITTER = "Twitter"
EFFECT_STOP = "Stop"

YEE_EFFECT_LIST = [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

YEELIGHT_EFFECT_LIST to be consistent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your quick review. This is something i thought of and then forgot it of course.
Thank you i will change it.

strobe_color, alarm, police,
police2, christmas, rgb,
randomloop, slowdown)
# transition = int(self.config[CONF_TRANSITION])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove commented out lines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed.

randomloop, slowdown)
# transition = int(self.config[CONF_TRANSITION])
if effect == EFFECT_DISCO:
flow = Flow(count=0, transitions=disco(),)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any reason these are passed as tuples? A list is expected? Maybe it'd make sense to do [disco()] to make it clear transitions expects an iterable? (Or in even better case, it should also allow single transitions...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Probably my incompetence. The reason i have this is because this is how i did it to get it to work. the disco function returns a list with the transitions. I just tried you example [disco()] but i can't get it to work. maybe i need to do something other then replace disco() with [disco()] ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, and passing the list directly does not work? To my understanding it should..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes just passing the list with transitions does work, but that is what i originally had.

@fabaff commented:

I think that the logic for the effects should be located in the yeelight module itself. This way the effects can be maintained at one place.

So this way we don't have to maintain the list for every transition, in case of changes in the yeelight module

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, I mean passing "disco()" as a parameter to transitions like:

Flow(count=0, transitions=disco())

should work. @fabaff is correct by saying that the implementation details belong to the module itself, where they are now thanks to you! :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah i see, That works! thank you i have changed it. And i completely agree with having the effects over there.

if effect == EFFECT_TWITTER:
flow = Flow(count=2, transitions=pulse(0, 172, 237),)

if effect == EFFECT_STOP:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be before other checks?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes i think that will make more sense. Changing it now.

Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

Looks good. Sorry for this taking so long. 🐬

@balloob balloob merged commit 7d24efc into home-assistant:dev Jun 3, 2017
@balloob balloob mentioned this pull request Jun 16, 2017
@bokub
Copy link
Copy Markdown
Contributor

bokub commented Aug 21, 2017

Neat effects!
I just discovered them a few minutes ago by chance

Thanks for your work @Mister-Espria 👍

@home-assistant home-assistant locked and limited conversation to collaborators Dec 11, 2017
@Mister-Espria Mister-Espria deleted the yeelight-adding-effects branch September 24, 2018 14:24
@Mister-Espria Mister-Espria restored the yeelight-adding-effects branch September 24, 2018 14:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants