Protect against 'false' power related triggers?

Post your questions and help other users.

Moderator: Martin

Post Reply
Ghlave
Posts: 28
Joined: 06 Aug 2013 18:06

Protect against 'false' power related triggers?

Post by Ghlave » 31 Jan 2018 14:28

I use an old phone in my car which relies on power connected/disconnected triggers to 'enable' or 'disable' the phone. I recently got a new car which has a green feature of turning the engine off at stop lights. My phone charger still gets power during this time, but when the engine starts again it sometimes (not always) causes a very brief blip in power connectivity which triggers a power disconnect immediately followed by a power connect.

I'm having a bit of trouble thinking logically on this one.... I'm guessing my best course would be to create two flows that only watch for the power triggers, placing some sort of buffer mechanism in those, and have these execute my actual flows? Any ideas on how to achieve this?

User avatar
Desmanto
Posts: 2476
Joined: 21 Jul 2017 17:50

Re: Protect against 'false' power related triggers?

Post by Desmanto » 31 Jan 2018 15:13

You can just add as sleep for 1 second as the buffer. But first need to know how you make the flow. Are both triggers in the same flow? (preferred) Or separated? If in the same flow, you can use AEP - skip to protect from surge event like this.

Add 1 second sleep after the Power Disconnect trigger, then add condition to check Power disconnect as well. So if disconnect event triggered, it will buffer for 1 second and check if it is still disconnected. In case of surge event, this will be false, since the power is connected back immediately. So false do nothing, true continue to your main flow for disconnected event.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Ghlave
Posts: 28
Joined: 06 Aug 2013 18:06

Re: Protect against 'false' power related triggers?

Post by Ghlave » 31 Jan 2018 17:21

I may have not explained it very well. Imagine this scenario-

Get in the car and turn on to go somewhere- This triggers a [power connect]
Stop at a red light- car turns off but power remains
Light turns green, removing foot from brake triggers the engine to start- this may or may not cause a split second [power disconnect] event followed immediately by a [power connect] event. I do not want either of these events to happen

User avatar
Desmanto
Posts: 2476
Joined: 21 Jul 2017 17:50

Re: Protect against 'false' power related triggers?

Post by Desmanto » 31 Jan 2018 17:56

Yep, that's exactly what I understand.

You can't prevent the events from happening. But you can prevent the triggered event to reach your main execution. That is the sleep 1 second and condition Power Disconnected do. It protect the main execution. In case of split second event, flow still get triggerrred. But the condition prevent the event going to the main true branch. Just make sure you put the main execution at the true branch. False branch do nothing.

This only protect the disconnected event. For the Power connected event, if it is in the same flow, Flow Execution Policy (FEP) - Skip will protect the second event, as it will be skipped out. If it is in separated flow, you can use condition Flow executing, and choose the Power Disconnected flow. When in the split second of execution, this power connected flow also triggered and check if the Power disconnected flow still running. If yes, then do nothing. If no (means it is not a surge event), continue to main flow.

Maybe you can share your flow so I can modify to your need. I can make one, but maybe not the one you want.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply