Skip to content

Allow light toggle service to accept all turn on params#20912

Merged
fabaff merged 1 commit into
home-assistant:devfrom
zewelor:allow_light_toggle_to_accept_all_turn_on_params
Mar 7, 2019
Merged

Allow light toggle service to accept all turn on params#20912
fabaff merged 1 commit into
home-assistant:devfrom
zewelor:allow_light_toggle_to_accept_all_turn_on_params

Conversation

@zewelor
Copy link
Copy Markdown
Contributor

@zewelor zewelor commented Feb 9, 2019

Description:

Looks like toggle service now accepts kwargs. Wanted to retry this PR. Ability to use service light.toggle to turn on light with specified brightness / color etc. It allow for easier scripting, than writing own toggle method, to toggle with specific settings.

Related issue (if applicable): fixes #

**Pull request in home-assistant.io with home-assistant/home-assistant.io#8612

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

@zewelor
Copy link
Copy Markdown
Contributor Author

zewelor commented Feb 17, 2019

Added docs PR.

@bbbenji
Copy link
Copy Markdown

bbbenji commented Feb 19, 2019

Tested and works for me! Solved the problem of me having to have separate automations for light.turn_on and light.turn_off.

Thanks.

ATTR_ENTITY_ID: cv.comp_entity_ids,
ATTR_TRANSITION: VALID_TRANSITION,
})
LIGHT_TOGGLE_SCHEMA = LIGHT_TURN_ON_SCHEMA
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.

On a second look, do all attributes of LIGHT_TURN_ON_SCHEMA make sense ? Shouldn't it be a subset ?

Copy link
Copy Markdown
Contributor Author

@zewelor zewelor Mar 7, 2019

Choose a reason for hiding this comment

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

Under the hood it calls turn_on, so I think everything that is accepted by turn_on could be passed there https://github.com/home-assistant/home-assistant/blob/519315f9c82ba9f0ea0bdcc622b4952b1c0a605c/homeassistant/helpers/entity.py#L470

@fabaff fabaff merged commit f2abc91 into home-assistant:dev Mar 7, 2019
@zewelor zewelor deleted the allow_light_toggle_to_accept_all_turn_on_params branch March 10, 2019 17:35
@balloob balloob mentioned this pull request Mar 20, 2019
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.

6 participants