Skip to content

WIP: Allow multiple pushover notifiers#15726

Closed
amelchio wants to merge 2 commits intohome-assistant:devfrom
amelchio:multiple-notify-pushover
Closed

WIP: Allow multiple pushover notifiers#15726
amelchio wants to merge 2 commits intohome-assistant:devfrom
amelchio:multiple-notify-pushover

Conversation

@amelchio
Copy link
Copy Markdown
Contributor

Description:

If you want to test this, copy this file to your <config>/custom_components/notify/pushover.py and restart Home Assistant. Remove that file again once this PR is merged.

This PR updates python-pushover to a version that fixes #11641.

The InitError exception has been renamed but I am just removing it from our code since Voluptuous will ensure the api_key is always specified. I am also removing a few attributes that were never accessed.

Pending Thibauth/python-pushover#27

Related issue (if applicable): fixes #11641

Example entry for configuration.yaml (if applicable):

notify:
 - name: pushoversecurity
   platform: pushover
   api_key: a7wt2i...
   user_key: upr9e...

 - name: pushoverhome
   platform: pushover
   api_key: ae5fi...
   user_key: upr9e...

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox.

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

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

@amelchio amelchio added the waiting-for-upstream We're waiting for a change upstream label Jul 29, 2018
@ghost ghost assigned amelchio Jul 29, 2018
@ghost ghost added the in progress label Jul 29, 2018
@jimbob1001
Copy link
Copy Markdown

Brilliant, works a treat 🏆

import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['python-pushover==0.3']
REQUIREMENTS = ['https://github.com/amelchio/python-pushover/archive/'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should only depend on dependencies from PyPI

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hence the waiting-for-upstream label. But it's been a while, so it's fine with me to close this while waiting for an updated release.

@balloob
Copy link
Copy Markdown
Member

balloob commented Sep 21, 2018

I'll close this as upstream hasn't been merged either.

@balloob balloob closed this Sep 21, 2018
@ghost ghost removed the in progress label Sep 21, 2018
@ashmckenzie
Copy link
Copy Markdown

For home-assistant 0.80.1 I get the following:

2018-10-16 17:24:16 ERROR (SyncWorker_38) [custom_components.notify.pushover] Could not send pushover notification
Traceback (most recent call last):
  File "/config/custom_components/notify/pushover.py", line 63, in send_message
    self.pushover.send_message(message, **data)
  File "/config/deps/lib/python3.6/site-packages/pushover.py", line 253, in send_message
    get_sounds()
  File "/config/deps/lib/python3.6/site-packages/pushover.py", line 46, in get_sounds
    request = Request("get", SOUND_URL, {})
  File "/config/deps/lib/python3.6/site-packages/pushover.py", line 93, in __init__
    raise RequestError(self.answer["errors"])
pushover.RequestError:
==> application token is invalid

@ashmckenzie
Copy link
Copy Markdown

Service call for this was in an automation and looks like:

- service: notify.pushover_emergency
  data:
    title: "Button 1"
    message: "Button 1 pressed"
    data:
      sound: "persistent"
      priority: 1

@ashmckenzie
Copy link
Copy Markdown

Works with priority defined, just not sound.

@ashmckenzie
Copy link
Copy Markdown

@deanrparry
Copy link
Copy Markdown

i see the same result with the custom component icons work as they should but sound fails... be nice to get a fix in the main branch :)

@jimbob1001
Copy link
Copy Markdown

Wonder if this can be re-opened as some changes seem to have been made to upstream finally and pushover looks to be broken now using @amelchio temporary fix?

@amelchio
Copy link
Copy Markdown
Contributor Author

Still waiting for an upstream release.

Did you try my latest update? https://raw.githubusercontent.com/amelchio/home-assistant/multiple-notify-pushover/homeassistant/components/notify/pushover.py

@jimbob1001
Copy link
Copy Markdown

Yes that was what is not working - I'll try post the error message when I get time, maybe something else caused it to break - I noticed it stopped working when I updated to 84.3, but thought maybe the commits to upstream were the issue
Cheers,
James

@jimbob1001
Copy link
Copy Markdown

Here is the error...

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/automation/__init__.py", line 294, in async_trigger
    await self._async_action(self.entity_id, variables, context)
  File "/usr/src/app/homeassistant/components/automation/__init__.py", line 378, in action
    await script_obj.async_run(variables, context)
  File "/usr/src/app/homeassistant/helpers/script.py", line 130, in async_run
    await self._handle_action(action, variables, context)
  File "/usr/src/app/homeassistant/helpers/script.py", line 172, in _handle_action
    action, variables, context)
  File "/usr/src/app/homeassistant/helpers/script.py", line 261, in _async_call_service
    context=context
  File "/usr/src/app/homeassistant/helpers/service.py", line 81, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context)
  File "/usr/src/app/homeassistant/core.py", line 1121, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/app/homeassistant/core.py", line 1143, in _execute_service
    await handler.func(service_call)
  File "/usr/src/app/homeassistant/components/notify/__init__.py", line 117, in async_notify_message
    await notify_service.async_send_message(**kwargs)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/notify/pushover.py", line 64, in send_message
    self.pushover.send_message(self.user_key, message, **data)
AttributeError: 'Pushover' object has no attribute 'send_message'

@amelchio
Copy link
Copy Markdown
Contributor Author

Thanks. It seems that self.pushover.send_message was renamed to self.pushover.message, if you could try changing that at line 64 in the custom component?

@jimbob1001
Copy link
Copy Markdown

Yes that has fixed it - thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed core integration: notify small-pr PRs with less than 30 lines. waiting-for-upstream We're waiting for a change upstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Different Pushover notify instances getting mixed up

6 participants