Battery counter

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
Rafi4
Posts: 281
Joined: 01 Dec 2017 05:23

Battery counter

Post by Rafi4 » 14 Nov 2018 02:27

Hi
I want to create a flow to know how long the power source AC adapter is Connected after power source is disconnected. How can I?

Example
Battery charged for 40 minutes.

Thanks in advance.
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: Battery counter

Post by anuraag » 14 Nov 2018 03:21

You need 2 triggers here and a glovar
1)
Trigger=>Power source connected
Action=> Script: glovar = triggertime

2)
Trigger=>Power source Disconnected
Action=> Script: duration = getDurationString(triggertime - glovar)
Action=> Notification

This can be set in one flow with expression: contains(trigger, "triggername")

User avatar
Rafi4
Posts: 281
Joined: 01 Dec 2017 05:23

Re: Battery counter

Post by Rafi4 » 14 Nov 2018 04:39

Hi anuraag
Thanks a lot.
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1

User avatar
Rafi4
Posts: 281
Joined: 01 Dec 2017 05:23

Re: Battery counter

Post by Rafi4 » 21 Nov 2018 00:24

hi
how can I remove seconds and milliseconds from "Script: duration = getDurationString(triggertime - glovar)". example = 4m 44s 444ms in this example I want to get 4 minutes only.is this possible? if yes, how can i?thanks in advance.

thanks from record4
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: Battery counter

Post by anuraag » 21 Nov 2018 00:42

change getDurationString to getDurationMillis

Code: Select all

duration = getDurationString(triggertime - glovar)
And add following line

Code: Select all

duration = "{duration,dateformat,timezone,UTC,m}"

Post Reply