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

Add additional Pushover parameters #2309

Merged
merged 2 commits into from
Jun 20, 2016
Merged

Add additional Pushover parameters #2309

merged 2 commits into from
Jun 20, 2016

Conversation

dale3h
Copy link
Member

@dale3h dale3h commented Jun 15, 2016

Description:
Add support for more Pushover parameters: target (device), sound, url, url_title, priority, timestamp

Related issue (if applicable): fixes #

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#

Example entry for configuration.yaml (if applicable):

automation:
  alias: Garage Door is Open
  trigger:
    platform: state
    entity_id: sensor.garage_door
    state: 'open'
  action:
    service: notify.pushover
    data:
      title: Garage Door
      message: The garage door is open.
      target: iPhone,MacBookPro
      data:
        url: https://home-assistant.io/
        url_title: Home Assistant
        priority: 1
        timestamp: 1466024112
        sound: siren

Checklist:

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

If code communicates with devices:

  • 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.

Add support for more Pushover parameters: target (device), sound, url, url_title, priority, timestamp
@@ -51,7 +51,21 @@ def send_message(self, message="", **kwargs):
"""Send a message to a user."""
from pushover import RequestError

data = kwargs.get(ATTR_DATA)
Copy link
Member

Choose a reason for hiding this comment

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

Please don't modify the original data dictionary that is being passed in.

You can supply a second argument to get that will be returned if the key doesn't exist, that way you don't have to check for None on the next line.

# Make a copy and use empty dict as default value
data = dict(kwargs.get(ATTR_DATA, {}))

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you @balloob, I've committed the fix.

I'll be able to run the local tests in a few days when I figure it all out.

@balloob
Copy link
Member

balloob commented Jun 20, 2016

Looks good! 🐬

@balloob balloob merged commit 6fa095f into home-assistant:dev Jun 20, 2016
@dale3h
Copy link
Member Author

dale3h commented Jun 21, 2016

This appears to break if at least one data: key is not provided. I am going to try adding the check for None back and see if that fixes it.

@dale3h dale3h deleted the pushover-params branch June 22, 2016 15:55
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants