Skip to content

Conversation

@caronc
Copy link
Owner

@caronc caronc commented Feb 21, 2025

Description:

Related issue (if applicable): #1235

Addition of the following accepted Home Assistant URLs (allowing direct service notifications - to those that support it):

  • {schema}://{host}/{accesstoken}/{target}
  • {schema}://{host}:{port}/{accesstoken}/{target}
  • {schema}://{user}@{host}/{accesstoken}/{target}
  • {schema}://{user}@{host}:{port}/{accesstoken}/{target}
  • {schema}://{user}:{password}@{host}/{accesstoken}/{target}
  • {schema}://{user}:{password}@{host}:{port}/{accesstoken}/{target}

A target follows the following set of logic:

  • service
    • default domain is always 'notify' if one isn't detected
  • service:target
  • service:target1,target2,target3
  • domain.service
  • domain.service:target
  • domain.service:target1,target2,target3
    • targets can be comma/space separated if more hten one

You can specify more then one target by just separating it with a / (slash) on the URL... i.e:

  • hassio://hostname/long.lived.token/my_subsystem/my_subsystem2:targetA

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@1235-hassio-notify-services

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
  'hassio://host/long-lived-token/service'

@caronc caronc linked an issue Feb 21, 2025 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.65%. Comparing base (8e1dad9) to head (4ecc90a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1294   +/-   ##
=======================================
  Coverage   99.65%   99.65%           
=======================================
  Files         170      170           
  Lines       21993    22081   +88     
  Branches     3470     3493   +23     
=======================================
+ Hits        21917    22005   +88     
  Misses         68       68           
  Partials        8        8           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@svenjochems
Copy link

svenjochems commented Apr 22, 2025

Hi,
I tried testing this branch but was unsuccessful.

Persistent notifications with the original url still works as expected.
Calling a different service fails with Bad Request - Unsupported Parameters., error=400, not sure if I am passing the service incorrectly.

root@7f43bf5a3b5e:/# apprise -vvv -t "Test Title" -b "Test Message" 'hassio://ha.lan/<token>/notify.mobile_app_gsm_sven'
2025-04-22 20:01:59,216 - DEBUG - Could not load translation path: /usr/local/lib/python3.13/site-packages/apprise/i18n/en
2025-04-22 20:01:59,801 - DEBUG - Notification Plugin 110(s) and 157 Schema(s) loaded in 0.5742s
2025-04-22 20:01:59,803 - DEBUG - Loaded HomeAssistant URL: hassio://ha.lan/x...x/notify.mobile_app_gsm_sven?batch=no&format=text&overflow=upstream
2025-04-22 20:01:59,804 - DEBUG - Home Assistant POST URL: http://ha.lan:8123/api/services/notify/mobile_app_gsm_sven (cert_verify=True)
2025-04-22 20:01:59,805 - DEBUG - Home Assistant Payload: {'title': 'Test Title', 'message': 'Test Message', 'notification_id': 'f07e49aa-920a-47a8-a4b0-63689d42056d'}
2025-04-22 20:01:59,824 - WARNING - Failed to send Home Assistant notification: Bad Request - Unsupported Parameters., error=400.
2025-04-22 20:01:59,824 - DEBUG - Response Details:
b'400: Bad Request'

Edit: I think the parameter notification_id may not be supported by other notification services.

@caronc caronc force-pushed the 1235-hassio-notify-services branch from 5d835e0 to 4ecc90a Compare July 29, 2025 17:38
@caronc
Copy link
Owner Author

caronc commented Jul 29, 2025

@svenjochems : very sorry for delay; is this still happening using the latest snapshot of this branch?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom notifications with Home Assistant

3 participants