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

How to build hierarchical events/ profiles? #62

Closed
pikim opened this issue Feb 20, 2018 · 16 comments
Closed

How to build hierarchical events/ profiles? #62

pikim opened this issue Feb 20, 2018 · 16 comments
Labels
bug General label for all bugs (i.e. things not working as intended)

Comments

@pikim
Copy link

pikim commented Feb 20, 2018

I would like to build up kind of a tree, something like:

                        +-------------------+
                        | phone in specific |
                        |  cell location?   |
                        +---------+---------+
                     yes          |           no
                       +----------+-----------+
                       |                      |
             +---------+---------+ +----------+----------+
             |    enable wifi    | |    disable wifi     |
             +---------+---------+ +----------+----------+
                       |                      |
             +---------+---------+ +----------+----------+
             | phone in specific | | enable mobile data  |
             |       SSID?       | +---------------------+
             +---------+---------+
         yes           |           no
           +-----------+-----------+
           |                       |
+----------+----------+ +----------+----------+
| disable mobile data | | enable mobile data  |
+---------------------+ +---------------------+

How can I achieve something like this?

I've already set up easy things like: activate silent mode after 10:00 pm or activate normal after 6:00 am, but nothing more complicated.

What can scenarios be used for?

@renyuneyun
Copy link
Owner

renyuneyun commented Feb 20, 2018

Scenarios are reusable components of an Event; it's a very thin abstraction layer so it's nothing more than a set of conditions (and the type). You can use inline Scenario if you don't want to make advanced reuse of the Scenario inside an Event, but I'd suggest define Scenarios for your case.

The hierarchy is done by means of Events. You can do something like this (names are suggestions only):

Create 2 Scenarios first:

  1. SpecificLocation: use cell location, and put the desired location there
  2. SpecificSSID: use wifi, and put the desired wifi ssid

Then you need to create 4 Profiles (I'm going from top to bottom, right to left):

  1. P1: Disable wifi + Enable mobile data
  2. P2: Enable wifi
  3. P3: Enable mobile data
  4. P4: Disable mobile data

Finally define 4 Events (I'm aware this is a bit annoying as we humans know some of them are only "reverses" to another one, and am planning to add more intuitive ways to handle this in future releases):

  1. E1 (watch the difference to E2):
    • Use Scenario SpecificLocation;
    • Set Reverse Scenario to true
    • Keep "repeatable when satisfied" false and keep volatile (you may change this depending on your needs, but I think this best matches)
    • Choose Profile P1
  2. E2:
    • Use Scenario SpecificLocation;
    • Keep Reverse Scenario false
    • Keep "repeatable when satisfied" false and keep volatile
    • Choose Profile P2

(Reverse Scenario, Repeatable when satisfied and volatile/persistent all default to false, and I won't mention them if they are kept false.)

  1. E3:
    • Choose E2 as Parent
    • Use Scenario SpecificSSID
    • Set Reverse Scenario to true
    • Choose Profile P3
  2. E4:
    • Choose E2 as Parent
    • Use Scenario SpecificSSID
    • Choose Profile P4

This should give you the desired behaviour.

@pikim
Copy link
Author

pikim commented Feb 21, 2018

Thank you very much! It nearly works. In E3 and E4 it must be E2 as Parent.

What doesn't work is enable and disable the mobile data. WiFi works well, but the state of mobile data doesn't change.

@renyuneyun
Copy link
Owner

renyuneyun commented Feb 21, 2018

Yes, you are right LOL. I put the wrong parent.

The mobile data thing is not an official API, so it is not guarenteed to work on all devices. However, the root way does work (but you will need a rooted device).
Android used to allow normal apps to toggle mobile data, but it doesn't now...

@pikim
Copy link
Author

pikim commented Feb 22, 2018

Unfortunately E1 doesn't fire. It fires if I choose None in SpecificLocation or if I set Reverse Scenario to false.

@renyuneyun
Copy link
Owner

Thanks a lot! That is indeed a big problem 0_o

I've found where it went wrong and have fixed it. Another silly problem is also fixed along the way.

You may wait for v0.5.5.2 entering f-droid repo, or use the one published (and signed) by me on github releases (or bintray).

@pikim
Copy link
Author

pikim commented Mar 1, 2018

It still doesn't work in 0.5.5.2.

Edit:
It works now - I didn't test it properly. But why does E2 fire every second, while E1 fires only once?

@renyuneyun
Copy link
Owner

Hooray (partly) :)

E2 is fired every second is because the phone is continously scanning (and maybe switching if you are moving, or in a "in-between" area) for base stations, which may cause a change in the connected base station (which is what is used by "cell location").
Could you confirm that "repeatable when satisfied" is set to false for E2? It should reduce one case -- you are moving and keeping connecting to different base stations during the time.
If you can confirm, I believe there is something wrong in my code (in the part handling these different "advanced" things).

You may also try to use the "persistent" thing before the problem is solved:

  1. Set persistent (instead of volatile) in E2
  2. Add an operation in P3 and P4: "change event state" and choose E2 (and the currently only selectable "set to false")

@pikim
Copy link
Author

pikim commented Mar 6, 2018

and maybe switching if you are moving, or in a "in-between" area

But then I should also see WiFi being toggled on and off, or see the other event flashing some time in the outline.

Could you confirm that "repeatable when satisfied" is set to false for E2?

Yes it's set to false.

  1. Set persistent (instead of volatile) in E2

Doesn't show any effect. The event is also fired every second.

@renyuneyun
Copy link
Owner

Hmm... Seems I made wrong condition checks.
I'll try to figure out once I have time.

@renyuneyun renyuneyun added the bug General label for all bugs (i.e. things not working as intended) label Mar 7, 2018
@renyuneyun
Copy link
Owner

Strangely, I don't find anything wrong... Also, the test on my phone goes without problem.

Can you post a log (either LogCat or the log under /sdcard/logger/ if you enabled "logging" in Easer) from the time you start Easer's service til the unwanted repeated triggering?

Note: there will be the name of the events, profiles and/or scenarios in the log. If you don't want them to appear, you can manually replace them with A, B, C, etc.

@gggirlgeek
Copy link

gggirlgeek commented Jun 7, 2018

Followed the instructions and it works perfectly when I leave the house. I replaced "mobile data" with "Brightness" turned up/turned down. Still works.

BUT when I make a phone call (inside the house) wifi gets turned off, which causes Easer to see me as not connected to my SSID, which triggers brightness enabled. My mobile signal also goes from 4G to H+, and back again when the phone is finished. Sometimes phone calls won't go through because of this.

I stopped Easer and made a couple of phone calls. Wifi does not get turned off nor do the other actions get triggered. What's wrong with my script?

logs_0.zip

@gggirlgeek
Copy link

gggirlgeek commented Jun 7, 2018

Seems like the phone call is either changing my location or disabling my location for a moment. This doesn't happen when I base the rule on SSID alone, and remove "disable wifi" from the profile (leaving only "enable BRIGHT" based on SSID.)

logs_0.zip

@renyuneyun
Copy link
Owner

Hi @gggirlgeek , thanks for reporting.
Would you mind opening another issue specifically for your case? This doesn't seem to be the same as a demonstration of how-to. Simply copying and pasting would be fine.
(p.s. I don't quite get what exactly is going on. Could you make it more clear 1) what script hierarchy you are using when doing these tests? 2) what's the actual/physical situation you / your phone are in when doing the tests?

@gggirlgeek
Copy link

gggirlgeek commented Jun 12, 2018

Didn't want to open an issue until I know if the problem is Easer or me, or my hardware. To simplify: I have a scenario: Home Location, profile: Enable Brightness, script: Combines these two (Enable Brightness when NOT at home location -- (scenario reversed)).

When I am at home and I make an outgoing phone call with Easer running, Easer enables my brightness. It should not do that because I'm still at the home location. Apparently the phone call is changing my location for a moment which causes Easer to think I'm not at the home location.

Another strange thing: When I turn off my phone's Location manually Easer does NOT detect it (does not Enable Brightness.) When I walk a block from home Easer does NOT detect location either (regardless of phone's Location setting.)

I live in the city so I need location within a few hundred feet. I'm probably connected to the same cell tower most of the time. Maybe Easer is basing cell location on cell towers?

Samsung J7 2015 rooted custom Rom (Nougat)
Location=high accuracy all the time

@FadeFx
Copy link

FadeFx commented Sep 26, 2018

@gggirlgeek i think your problem is that your provider does not do voice over lte, thats why your network changes to 3g (H+) and thus the cell id changes.

@pikim @renyuneyun
Btw, it is absolutely useless to disable mobile data while in wifi, as it wont be used anyway. That means the whole tree in the example is totally obsolete from wifi on/off downwards.
The only situation in that it would actually do something is if the wifi has no internet connection, it would cut you from internet anyway, but i am not sure on when that would make any sense...

@renyuneyun renyuneyun added this to Bugs to solve in Misc Bugs Mar 5, 2019
@renyuneyun
Copy link
Owner

I'm closing this in favour of #124 .

Feel free to re-open this if not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug General label for all bugs (i.e. things not working as intended)
Projects
None yet
Development

No branches or pull requests

4 participants