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

Remove service helper (5) #16917

Merged
merged 7 commits into from
Sep 27, 2018
Merged

Remove service helper (5) #16917

merged 7 commits into from
Sep 27, 2018

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Sep 27, 2018

Description:

Additional work for: home-assistant/architecture#58

Checklist:

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



CONFIG_PATH = 'scripts.yaml'


@bind_hass
def async_reload(hass):
Copy link
Member

Choose a reason for hiding this comment

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

This should be tagged with @callback as it calls an async method.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, from looking at the code, it should be an async function. The old code worked because it would actually schedule the async_call, but that seems weird.

Copy link
Member

Choose a reason for hiding this comment

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

async def async_reload(hass):
    await hass.services.async_call(DOMAIN, SERVICE_RELOAD)

Copy link
Member Author

Choose a reason for hiding this comment

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

Just noticed it myself while looking at config/group.py

Copy link
Member

Choose a reason for hiding this comment

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

@balloob that is slow:

def async_reload(hass):
   """This function return a coroutine."""
    return hass.services.async_call(DOMAIN, SERVICE_RELOAD)

?

Copy link
Member

Choose a reason for hiding this comment

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

It's a bit slower but it gives proper stack traces. I don't want to do the old way anymore.

light.async_turn_on(light_id,
transition=LIGHT_TRANSITION_TIME.seconds,
profile=light_profile)
hass.async_add_job(
Copy link
Member

@pvizeli pvizeli Sep 27, 2018

Choose a reason for hiding this comment

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

hass.async_create_task(...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean hass.async_create_task()?

@balloob balloob merged commit 70b9010 into home-assistant:dev Sep 27, 2018
@ghost ghost removed the in progress label Sep 27, 2018
@cdce8p cdce8p deleted the remove-service-helper-5 branch September 27, 2018 21:14
@balloob balloob mentioned this pull request Oct 12, 2018
@vanto
Copy link

vanto commented Oct 13, 2018

A deprecation warning beforehand would have been nice. It broke a custom_component (circadian-lighting) out of the sudden, which was not so nice.

@cdce8p
Copy link
Member Author

cdce8p commented Oct 13, 2018

@vanto I'm sorry it broke your custom component. However in that case deprecation warnings weren't an option. Just going over all of them once took long enough, not to think of doing it twice.

It's true, this could have been better communicated although using hass.services.call has long been the standard way of doing it. If you still need advice on how to fix your component, let me know. I'm happy to help.

claytonjn referenced this pull request in claytonjn/home-assistant Oct 14, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
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

5 participants