# Help reducing battery low warnings in flow

**URL:** <https://community.homey.app/t/help-reducing-battery-low-warnings-in-flow/92384>\
**Category:** Questions & Help\
**Created:** [October 21, 2023, 3:06am UTC](https://community.homey.app/t/help-reducing-battery-low-warnings-in-flow/92384 "2023-10-21T03:06:56Z")\
**Posts on this page:** 1\
**Showing post:** 26

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [October 27, 2023, 1:17am UTC](https://community.homey.app/t/help-reducing-battery-low-warnings-in-flow/92384/26 "2023-10-27T01:17:32Z")

</div>

> [@JanPieter88](#):
>
> Yes, the same with my robot-lawnmower that floods the timeline with ‘warnings’ about its battery every day. I wish it were possible to exclude certain devices’ energy warnings from the timeline.

You can file a request at homey.app/support, but I think chances are pretty low

But here’s a workaround 🙂

> [@\[HomeyScript\] Timeline Wrangler](https://community.homey.app/t/homeyscript-timeline-wrangler/90714/5):
>
> ### Auto remove certain ‘Low Battery’ notifications by Homey, most of the time annoying and useless when a device uses rechargable batteries, like robo mowers, and robo vacs
> 
> - This flow is triggered by new timeline notifications,
> - If it matches the phrase you enter as argument to this Homeyscript card,  
> ![Screenshot from 2023-10-27 03-18-53](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/0/a0c5706532f0e6b531daf55af96c645c8d0a9bd4.png)  
> (_find the used script below_)
> - 
> - in this example: ` **My_Mower** is low on battery` (an exact part of the original message in the Timeline notification),
> 
> - _Then, it removes the timeline notification right away_  
> .
> 
> ![Screenshot from 2023-10-27 02-48-04](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/0/b0864cb9ff148f2d7be13206e5b840b8e847ac35.png)
> 
> - Detail of how to enter the search phrase argument  
> ![Screenshot from 2023-10-27 02-46-52](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/9/d9a3a9b660cde2e412de7c63ad804537df639b37.png)
> 
> #### The slightly adjusted script:
> 
> - 
> - the argument is used with line  
> `const containsText = args[0]; // Only deletes notifications that contains the specified text`
> 
> - 
> - The script returns the used argument along with the ‘flows removed’ message
> 
> - 
> - Note: the categories list is my own, but it is not used here
> 
> (original script by @Caseda)
> 
> > **show me the script**
> >
> > ```auto
> > // DEL timeline msgs ALL matching | Argument = searchphrase - Timeline_Wrangler v1.3p
> > 
> > // ==================== User Settings ====================
> > const deleteNotifications = true; // If "true": actually removes notifications, if "false": display only
> > const daysOld = 0; // Amount of days that need to have past before a notification is deemed old
> > const hoursOld = 0; // Amount of hours that need to have past before a notification is deemed old
> > const maximumNotifications = 250; // The maximum amount of notifications that stay, anything more will get deleted
> > const containsText = args[0]; // Only deletes notifications that contains the specified text, Empty ( '' ) = not used
> > const showCategories = false; // If "true" it will show all timeline categories you have and had in the past
> > const useCategory = false; // If "true" it will only remove from the specified categories below
> > 
> > // Separate categories by comma ( , )
> > const categories = [
> > 'homey:manager:flow',
> > 'homey:manager:presence',
> > 'homey:manager:apps',
> > 'homey:manager:updates',
> > 'homey:manager:zigbee',
> > 'homey:manager:energy',
> > 'homey:manager:backup',
> > 'homey:manager:users',
> > 'homey:app:com.athom.flowchecker',
> > 'homey:manager:security',
> > 'homey:app:nl.qluster-it.DeviceCapabilities',
> > 'homey:app:net.i-dev.betterlogic',
> > 'homey:app:com.spkes.telegramNotifications',
> > 'homey:manager:safety',
> > 'homey:app:nl.nielsdeklerk.log',
> > 'homey:manager:experiments',
> > ];
> > 
> > // ==================== Don't change anything below here ====================
> > const removedNotifications = [];
> > const notificationCategories = [];
> > let amountNotifications = 0;
> > let amountKept = 0;
> > 
> > if (showCategories) {
> > await Homey.notifications.getOwners()
> > .then(owners => {
> > log(Object.keys(owners).length, 'Timeline Categorie(s):');
> > Object.keys(owners).forEach(key => {
> > if (owners[key].uriObj.hasOwnProperty('name')) {
> > log('-', owners[key].uriObj.name, (owners[key].uriObj.name.length <= 5) ? '\t\t\t|' : (owners[key].uriObj.name.length <= 12) ? '\t\t|' : '\t|', '\'' + key + '\'');
> > }
> > else {
> > log('- Unkown Name', '\t\t|', '\'' + key + '\'');
> > }
> > });
> > log('\n');
> > })
> > .catch(err => {
> > log(err);
> > return 'Getting categories failed';
> > });
> > }
> > 
> > await Homey.notifications.getNotifications()
> > .then(notifications => {
> > amountNotifications = Object.keys(notifications).length;
> > log(amountNotifications, 'Timeline Notification(s):');
> > 
> > Object.keys(notifications).forEach(key => {
> > const currentDate = new Date();
> > const dateCreated = new Date(notifications[key].dateCreated);
> > const timeDifference = (currentDate - dateCreated) / 1000;
> > const daysDifference = Math.floor(timeDifference / 86400);
> > const hours = Math.floor((timeDifference % 86400) / 3600);
> > const hoursDifference = Math.floor(timeDifference / 3600);
> > const minutes = Math.floor((timeDifference % 3600) / 60);
> > 
> > if (
> > ((containsText.length > 0 && notifications[key].excerpt.toLowerCase().includes(containsText.toLowerCase()))
> > && (daysDifference >= daysOld && hoursDifference >= hoursOld))
> > || maximumNotifications < amountKept
> > ) {
> > log('- Removing:', notifications[key].id, ' |', notifications[key].ownerUri, '|', notifications[key].excerpt, '(' + notifications[key].dateCreated + ' - ' + daysDifference + ' day(s), ' + hours + ' hour(s) and ' + minutes + ' minute(s) old)');
> > 
> > if (deleteNotifications) {
> > Homey.notifications.deleteNotification({id: notifications[key].id});
> > removedNotifications.push(notifications[key].id);
> > }
> > }
> > else if (
> > ((containsText.length === 0 && useCategory)
> > && (categories.includes(notifications[key].ownerUri))
> > && (daysDifference >= daysOld && hoursDifference >= hoursOld))
> > || maximumNotifications < amountKept
> > ) {
> > log('- Removing:', notifications[key].id, ' |', notifications[key].ownerUri, '|', notifications[key].excerpt, '(' + notifications[key].dateCreated + ' - ' + daysDifference + ' day(s), ' + hours + ' hour(s) and ' + minutes + ' minute(s) old)');
> > 
> > if (deleteNotifications) {
> > Homey.notifications.deleteNotification({id: notifications[key].id});
> > removedNotifications.push(notifications[key].id);
> > }
> > }
> > else if (
> > ((containsText.length === 0 && !useCategory)
> > && (daysDifference >= daysOld && hoursDifference >= hoursOld))
> > || maximumNotifications < amountKept
> > ) {
> > log('- Removing:', notifications[key].id, ' |', notifications[key].ownerUri, '|', notifications[key].excerpt, '(' + notifications[key].dateCreated + ' - ' + daysDifference + ' day(s), ' + hours + ' hour(s) and ' + minutes + ' minute(s) old)');
> > 
> > if (deleteNotifications) {
> > Homey.notifications.deleteNotification({id: notifications[key].id});
> > removedNotifications.push(notifications[key].id);
> > }
> > }
> > else {
> > log('- Keeping: ', notifications[key].id, ' |', notifications[key].ownerUri, '|', notifications[key].excerpt, '(' + notifications[key].dateCreated + ' - ' + daysDifference + ' day(s), ' + hours + ' hour(s) and ' + minutes + ' minute(s) old)');
> > amountKept++;
> > }
> > });
> > })
> > .catch(err => {
> > log(err);
> > return 'Script failed';
> > });
> > 
> > if (removedNotifications.length > 0) {
> > return 'Removed ' + removedNotifications.length + ' out of ' + amountNotifications + ' notification(s).\nUsed Argument: ' + args[0];
> > }
> > 
> > return 'No notifications were (actually) removed. \nUsed Argument: ' + args[0];
> > 
> > ```

---

_[View the full topic](https://community.homey.app/t/help-reducing-battery-low-warnings-in-flow/92384)._
