Page 1 of 1

Battery counter

Posted: 14 Nov 2018 02:27
by Rafi4
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.

Re: Battery counter

Posted: 14 Nov 2018 03:21
by anuraag
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")

Re: Battery counter

Posted: 14 Nov 2018 04:39
by Rafi4
Hi anuraag
Thanks a lot.

Re: Battery counter

Posted: 21 Nov 2018 00:24
by Rafi4
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

Re: Battery counter

Posted: 21 Nov 2018 00:42
by anuraag
change getDurationString to getDurationMillis

Code: Select all

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

Code: Select all

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