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

Allow duplicate notification update if specified field changes #2098

Closed
greghesp opened this issue Dec 31, 2021 · 5 comments
Closed

Allow duplicate notification update if specified field changes #2098

greghesp opened this issue Dec 31, 2021 · 5 comments
Labels
enhancement New feature or request sensor-tracking

Comments

@greghesp
Copy link

greghesp commented Dec 31, 2021

Is your feature request related to a problem? Please describe.
We use the last notification sensor as a way to trigger automations depending on alarms from my wife's glucose sensor app.
The app only sends a handleful of notification types, most commonly High Glucose and Low Glucose. Due to the way the app sends these notifications, the android.text field does not change, but the title field does.

This is a problem because it is common for a low Glucose notification to be triggered, and then the next notification from the app could also be a Low Glucose notification, a few hours or so later

Describe the solution you'd like
A toggle that allows for duplicate notification sending, should a specific field be updated, the sensor updates. As it works right, the sensor only updates if the android.text field changes

Alternatively, logic should look to see if the title or text has changed, if so, update the sensor

Describe alternatives you've considered, if any
None

Additional context
The app in question: https://play.google.com/store/apps/details?id=com.freestylelibre.app.gb

I'm sure there will also be other use cases.

Notification example for High Alarm

android.appInfo: ApplicationInfo{8c04a60 com.freestylelibre.app.gb}
android.bigText: Dismiss Alarm & Check Glucose.
android.infoText: 'null'
android.largeIcon: 'null'
android.progress: 0
android.progressIndeterminate: false
android.progressMax: 0
android.reduced.images: true
android.remoteInputHistory: 'null'
android.showChronometer: false
android.showWhen: true
android.subText: 'null'
android.template: android.app.Notification$BigTextStyle
android.text: Dismiss Alarm & Check Glucose.
android.title: High Glucose Alarm  ⚠️
is_clearable: true
is_ongoing: false
package: com.freestylelibre.app.gb
post_time: 1640466469911
icon: mdi:bell-ring
friendly_name: Pixel 4a (5G) Last Notification

Notification example for Low alarm

android.appInfo: ApplicationInfo{8c04a60 com.freestylelibre.app.gb}
android.bigText: Dismiss Alarm & Check Glucose.
android.infoText: 'null'
android.largeIcon: 'null'
android.progress: 0
android.progressIndeterminate: false
android.progressMax: 0
android.reduced.images: true
android.remoteInputHistory: 'null'
android.showChronometer: false
android.showWhen: true
android.subText: 'null'
android.template: android.app.Notification$BigTextStyle
android.text: Dismiss Alarm & Check Glucose.
android.title: Low Glucose Alarm  ⚠️
is_clearable: true
is_ongoing: false
package: com.freestylelibre.app.gb
post_time: 1640466469911
icon: mdi:bell-ring
friendly_name: Pixel 4a (5G) Last Notification
@greghesp greghesp added the enhancement New feature or request label Dec 31, 2021
@dshokouhi
Copy link
Member

Sensors are all based on a state, for this sensor the state is set to the Text of the notification. All other aspects of the notification are attributes so we evaluate if the state has changed or not. Attributes should not trigger a state change as attributes describe a notification which is whats happening here and the reason as to why many of the sensors were broken down because they had a separate state. This isnt a limitation just for this sensor but we apply it to all sensors, if we remove this then every single time a sensor update check is performed then all sensors will do a check for an update and you will get more updates than needed. In this case its recommended to use another app to post a notification when this one is received or ask the developer if they can provide a broadcast intent for this action so you can have those events forwarded to HA and make a sensor out of it. Changing the logic here doesn't make sense either to check the Title because most apps provide an update to the Text of the notification which is considered a required field on Android and also our app.

@greghesp
Copy link
Author

Thanks, that makes sense.
When you say send another notification from Tasker, how would that change things, as the notification would come from the Tasker package, not the Libre one?

@dshokouhi
Copy link
Member

Basically your allow list would consist of tasker and the libre one and in Tasker you would make it post a notification sometime after libre posts one. This way the state of the Last Notification sensor changes to Tasker so it can change back to whatever Libre wanted to send.

@greghesp
Copy link
Author

greghesp commented Dec 31, 2021

Ahhh of course. Ok that makes sense, thanks. I assume the HA app is excluded by default, so I couldn't use that?

I usually send an actionable notification to the HA app when I receive this one

@dshokouhi
Copy link
Member

Ahhh of course. Ok that makes sense, thanks. I assume the HA app is excluded by default, so I couldn't use that?

I usually send an actionable notification to the HA app when I receive this one

correct we exclude our own package otherwise itll pick up the sensor worker notifications and will be stuck in a loop 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sensor-tracking
Projects
None yet
Development

No branches or pull requests

2 participants