Skip to content
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

Entity service #15991

Merged
merged 3 commits into from Aug 16, 2018
Merged

Entity service #15991

merged 3 commits into from Aug 16, 2018

Conversation

balloob
Copy link
Member

@balloob balloob commented Aug 15, 2018

Description:

Introduces a new helper to help entity components defining services. Bonus: when executing a service, will run entities of different platforms in parallel. This should give a significant boost if you are controlling, for example, a Hue and a LIFX bulb at the same time.

Approach 1: Will call entity.async_open_cover

component = EntityComponent(_LOGGER, DOMAIN, hass)

component.async_register_entity_service(
    SERVICE_OPEN_COVER, COVER_SERVICE_SCHEMA,
    'async_open_cover'
)

Approach 2: Will call passed in function with entity, call and expects coroute returned

component = EntityComponent(_LOGGER, DOMAIN, hass)

component.async_register_entity_service(
    SERVICE_OPEN_COVER, COVER_SERVICE_SCHEMA,
    lambda entity, call: entity.async_open_cover()
)

Related issue (if applicable): #15989

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@balloob balloob requested a review from a team as a code owner August 15, 2018 19:07
@ghost ghost assigned balloob Aug 15, 2018
@ghost ghost added the in progress label Aug 15, 2018
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Wow!

@MartinHjelmare
Copy link
Member

MartinHjelmare commented Aug 15, 2018

Looks awesome. Just needs tests I guess.

Copy link
Member

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

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

That is a perfect

@balloob
Copy link
Member Author

balloob commented Aug 16, 2018

It doesn't need tests as all entity components have tests for all services already (famous last words)

@balloob
Copy link
Member Author

balloob commented Aug 16, 2018

Right now we call all commands in sequence. We should explore leveraging the PARALLEL_UPDATES constant on platforms to see if we can go faster.

@balloob balloob merged commit b682e48 into dev Aug 16, 2018
@ghost ghost removed the in progress label Aug 16, 2018
@balloob balloob deleted the entity-service branch August 16, 2018 07:50
@balloob balloob mentioned this pull request Aug 16, 2018
3 tasks
@balloob balloob mentioned this pull request Aug 29, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Dec 10, 2018
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.

None yet

4 participants