Skip to content

Remove extraneous parameter from AlarmDecoder services#33516

Merged
balloob merged 1 commit intohome-assistant:devfrom
ajschmidt8:fix-ad-service
Apr 2, 2020
Merged

Remove extraneous parameter from AlarmDecoder services#33516
balloob merged 1 commit intohome-assistant:devfrom
ajschmidt8:fix-ad-service

Conversation

@ajschmidt8
Copy link
Copy Markdown
Contributor

Breaking change

Proposed change

This PR removes the entity_id field from the alarm_keypress and alarm_toggle_chime services for AlarmDecoder. The entity_id field was not used in either of the service handlers or voluptuous schemas.

It was causing issues in the Services panel UI below by prefilling fields that didn't exist and triggering a Failed to call service alarmdecoder/alarm_keypress. extra keys not allowed @ data['entity_id'] error.

image

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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

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

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@ajschmidt8
Copy link
Copy Markdown
Contributor Author

ajschmidt8 commented Apr 2, 2020

I'm not sure if removing entity_id from services.yaml was correct or if I should've instead added entity_id to the voluptuous schema. Hoping whoever reviews this can advise and share some insight. Thanks!

---EDIT

Actually, after reviewing the Envisalink keypress handler (which also uses entity_id as an argument), I see that they used entity_id to support the possibility of multiple partitions (and therefore multiple entities). Since AlarmDecoder currently doesn't support multiple partitions, I don't believe the entity_id field should be necessary since there is only one entity. Seems logical to me 🤷‍♂️.

@balloob
Copy link
Copy Markdown
Member

balloob commented Apr 2, 2020

Well actually it's all wrong. If you would have 2, only the last services would work 🤦‍♂

But yeah, this is better in the meanwhile. Thanks.

@balloob balloob merged commit 9fd0192 into home-assistant:dev Apr 2, 2020
@ajschmidt8 ajschmidt8 deleted the fix-ad-service branch April 2, 2020 17:28
@ajschmidt8
Copy link
Copy Markdown
Contributor Author

@balloob, what's the correct way to solve this? I'm happy to fix it, just need some guidance. do you have a code excerpt from another integration that I should follow?

@balloob
Copy link
Copy Markdown
Member

balloob commented Apr 2, 2020

You will need to rewrite setup_platform to be async_setup_platform and then register using this approach:

platform.async_register_entity_service(
SERVICE_SET_TIMER,
{
vol.Required(ATTR_SLEEP_TIME): vol.All(
vol.Coerce(int), vol.Range(min=0, max=86399)
)
},
"set_sleep_timer",
)

@frenck frenck added this to the 0.108.0 milestone Apr 2, 2020
@lock lock Bot locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cherry-picked cla-signed small-pr PRs with less than 30 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants