apprise icon indicating copy to clipboard operation
apprise copied to clipboard

unable to use per url tags in config for home assistant use.

Open codeman256 opened this issue 11 months ago • 4 comments

:mega: Notification Service(s) Impacted

all?

:lady_beetle: Describe the bug

unable to supply tag per URL in config if using Home Assistant to call config. This doesn't work

urls:
  - tgram://...
    - tag: hassio

whearas this does work

tags: hassio
urls:
  - tgram://...

:bulb: Screenshots and Logs

2025-01-14 18:17:53.548 DEBUG (SyncWorker_1) [apprise] Apprise API POST URL: http://10.3.2.10:8002/notify/hassio (cert_verify=True)
2025-01-14 18:17:53.548 DEBUG (SyncWorker_1) [apprise] Apprise API Payload: {'title': 'Your Garage Door Friend', 'body': 'The garage door has been open for 10 minutes.', 'type': 'info', 'format': 'text'}
2025-01-14 18:17:53.563 WARNING (SyncWorker_1) [apprise] Failed to send Apprise API notification: error=424.
2025-01-14 18:17:53.564 DEBUG (SyncWorker_1) [apprise] Response Details:
b'{"error": "One or more notification could not be sent", "details": [["INFO", "2025-01-14 19:17:53,560", "Loaded 1 entries from memory://"]]}'

:computer: Your System Details:

  • OS: apprise and HA in dockers on unraid.
  • Python Version: up to date versions.

:crystal_ball: Additional context tried multiple different ways here and I narrowed the issue down to this per URL tag method that does not work.

codeman256 avatar Jan 15 '25 01:01 codeman256

tags isn't a valid; see here. Use tag for global representation.

The second example you provided is valid. It's not that it isn't working, it's that you're associating a name/label to the URL. Then you're trying to make a call without leveraging the target Home Assistance variable to specifically access this URL.

The other way works because there is no tag associated and no tag reference in the call (it's a more simplified example).

Check out this blog i did a few years ago and see if it helps

caronc avatar Jan 15 '25 03:01 caronc

oh yes sorry mistype there. I fixed and and still have the issue.

working with this apprise config:

urls:
  - tgram://...
    - tag: cody
  - tgram://...
    - tag: spouse
  - https://discord.com/api/webhooks/...

and running this action in HA.

action: notify.apprisenotify
data:
  message: The garage door has been open for 10 minutes.
  title: Your Garage Door Friend

= only the discord notification. but when this is ran:

action: notify.apprisenotify
data:
  message: The garage door has been open for 10 minutes.
  title: Your Garage Door Friend
  target: cody

= no notifications and I get nothing in the logs

codeman256 avatar Jan 15 '25 03:01 codeman256

I also use (and absolutely love) Home Assistant. I use it with Apprise too and very heavily rely on tags. Since it works for me, i want to see if we can pinpoint the differences in our setup. I may very well have a bug and it just isn't surfaced on my end.

So in my configuration directory (for me it's /etc/homeassistant/apprise.yaml I have a file that looks like this (privacy detils redacted of course):

urls:
  # Email notification to everyone
  - mailtos://credentials?name=HomeAssistant:
      tag: everyone
      to:
        - [email protected]
        - [email protected]

  # Email notification
  - mailtos://credentials?name=HomeAssistant:
      tag: alarm, email
      to: [email protected]

  # Pushbullet notification
  - pbul://credentials:
      tag: alarm, pushbullet

Then of course in the configuration.yaml (for HASIO) i have:

notify:
  name: apprise
  platform: apprise
  config: /etc/homeassistant/apprise.yaml

Now an example of a working automation :

- alias: "Garage Door Open Apprise Test"
  initial_state: true

  trigger:
    - platform: state
      entity_id: binary_sensor.garage_door
      from: 'off'
      to: 'on'

  action:
  - service: notify.apprise
    data_template:
      target: pushbullet
      title: Garage Door
      message: >-
         'Garage Door Opened {{ now().strftime('%Y-%m-%d %H:%M:%S') }}'

I'd be curious what tweaks i need to accomodate to which your configuration does not work where it should, or if perhaps just re-over-looking your configuration you can spot the problem?

caronc avatar Jan 18 '25 19:01 caronc

Yeah, very strange. my configs are equivelently the same but I'm using url: http://10.3.2.10:8002/notify/hassio instead of config: in the home assistant configuration.yaml. I also turned on debug in the apprise docker and can see the request when I send the notification without the target: cody but then when I send it with target: cody I don't see anything. So I know it's working just not with the target specified.

I even enabled debug on apprise in HA, can see the logs output when I send a notification without the target and then I do NOT see any logs in HA when I include the target for the notification.

I updated HA docker before testing today as well.

codeman256 avatar Jan 20 '25 23:01 codeman256