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

[notify.pushover] Fix 'NoneType' error on data retrieval #2352

Merged
merged 2 commits into from
Jun 22, 2016
Merged

[notify.pushover] Fix 'NoneType' error on data retrieval #2352

merged 2 commits into from
Jun 22, 2016

Conversation

dale3h
Copy link
Member

@dale3h dale3h commented Jun 22, 2016

Description:
Previous code causes a 'NoneType' object is not iterable error when no data: config is provided to Pushover.

Related issue (if applicable): fixes #2309

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

data_ref = kwargs.get(ATTR_DATA)

# Make a copy and use empty dict if necessary (thanks @balloob)
data = dict(data_ref) if data_ref else {}
Copy link
Member

Choose a reason for hiding this comment

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

This code is exactly the same. Passing in a second argument to get specified the default value if the key is not found.

@balloob
Copy link
Member

balloob commented Jun 22, 2016

Looks good! 🐬

@balloob balloob merged commit d7b0066 into home-assistant:dev Jun 22, 2016
@dale3h dale3h deleted the patch-1 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