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 TTL support and custom headers support. #22988
Conversation
Hey there @robbiet480, mind taking a look at this pull request as its been labeled with a integration ( |
Codecov Report
@@ Coverage Diff @@
## dev #22988 +/- ##
=========================================
- Coverage 94.29% 94.1% -0.2%
=========================================
Files 461 448 -13
Lines 37551 36756 -795
=========================================
- Hits 35410 34590 -820
- Misses 2141 2166 +25
Continue to review full report at Codecov.
|
I don't know how I feel about this. I don't think we should just always set priority levels for every notification, since pushes could be going to platforms other than Android which may handle priority differently. Furthermore and Android specific though, priority messages are limited to app buckets, so sending too many priority notifications can actually cause all notifications for Chrome to become disabled. More info here and here. So we need to be extremely careful with a heavy handed approach that this PR takes. Can we not just support priority in the |
I'm adding my two cents here, if i consider my POV (and only my POV). I'm kind of new user (using HA for 3 months) and I have like 30 automations using push notification. These notifications are only delivered to android devices (my phone and wife's phone). Adding priority in data sounds good, but it will require me some changes (basically, adding the priority to all my automations using push notification). It would be nice to be able to define both priority in notify:
- platform: html5
name: NOTIFIER_NAME
vapid_pub_key: YOUR_PUBLIC_KEY
vapid_prv_key: YOUR_PRIVATE_KEY
vapid_email: YOUR_EMAIL
default_priority: ... Default value would be With this, user has the choice to configure HA in a way that requires less changes for him. This does not seem difficult to do (I know, i'm dev too, easy to say, a bit harder to do :)) |
I've done recently a lot of notification tests with different |
added two possible priorites: |
@pszafer @bieniu Anyway, i'm gonna try that TTL/prioriy combination this week end, but I think it's really depending on the phone (manufacturer) since they do some custom battery optimization. EDIT: sorry, it seems that |
Priority configured by user is in my opinion the best way. Great work @pszafer |
Has anyone else had issues with the service notify.html5_dismiss no longer working with this patch? I can call the service directly via the HA UI, but neither the notifications on my phone get dismissed, nor push notifications queued in the cloud to get delivered to my Chrome web browser get deleted. |
@eyager1 just checked. Dismiss is working for me, even with high priority. |
Hi, here are my test results. Here is my config
Please note, by "instantly" I mean delay from 0 to 5 sec. I really thing the good choice is the let user decide (actually, configure) |
@eyager1 For me dismiss works as usually with this fix. |
@robbiet480 What do you think about the changes that @pszafer did (priority configured by the user)? There is a chance that this PR would be merged before 0.92 beta? |
@robbiet480 what do you think about this PR now? |
Looking at #22249 comments it seems to fix issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine but tests need to get fixed so we don't take a coverage hit for such a widely used integration.
Hope it is enough. 88%. I have troubles to increase it more... |
Comment from @jrconlin looks important for this issue. Does not recommend using 86400.
|
@Konstigt I found one bug in JWT, so I can change default TTL as well. @robbiet480 waiting for your opinion. |
* Add TTL custom support and custom headers support. * fix pywebpush version * removed whitespaces surrounding docstrings. * fixes for tests * priority option to data * checking of ATTR_ENDPOINT * change checking of target to vol.Schema * more tests
Related issue: #22249 (comment)
Added TTL support in service and changed default TTL from 0 to 86400.
Creating headers manually (before webpush lib did it for us) to allow us add custom FCM headers like urgency, priority and maybe we find better priority header in the future.
Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
I will update docs if you agree with these changes.