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

fix: trigger outside mobile cell event when connected cell is not any… #131

Closed
wants to merge 1 commit into from

Conversation

KarolBedkowski
Copy link

… list

When current connected mobile cell is not on any defined list, "Mobile cell sensor" with enabled "start when outside..." stay inactive. Adding this cell to any other list make this sensor work ok. In this form this feature has very limited usability.

Problem is result of getting list of cells filtered by current connected cell (db.addMobileCellsToList(_cellsList, registeredCell)) and do next checks only when this list is not empty. If we are connected to unknown cell (list is empty), no more check are performed even when we check "outside".

Now, when cells list is empty, default result depend on _whenOutside, so empty list and "outside" enabled trigger event. When "outside" is false, there is no change in behaviour.

… list

When current connected mobile cell is not on any defined list, "Mobile cell
sensor" with enabled "start when outside..." stay inactive. Adding this
cell to any other list make this sensor work ok. In this form this feature
has very limited usability.

Problem is result of getting list of cells filtered by current connected
cell (db.addMobileCellsToList(_cellsList, registeredCell)) and do next
checks only when this list is not empty. If we are connected to unknown
cell (list is empty), no more check are performed even when we check
"outside".

Now, when cells list is empty, default result depend on _whenOutside, so
empty list and "outside" enabled trigger event. When "outside" is false,
there is no change in behaviour.
@henrichg
Copy link
Owner

henrichg commented Jun 9, 2024

But "Start when outside mobile cells" is ony for CONFIGURED mobile cells. Not configured are ignored.

This is the same also for:

  • Wi-Fi sensor - "Not connected", "Not nearby (not within scanning range)" - not configured SSIDs are ignored
  • Bluetooth sensor - "Not connected", "Not nearby (not within scanning range)" - not configured Bluetooth names are ignored
  • Location sensor - "Start when outside location" - not configured locations are ignored

Not exists parameter similar to "Not configured..." and is not planed to implement it.

@henrichg
Copy link
Owner

Sorry, will not be merged.

@henrichg henrichg closed this Jun 12, 2024
@KarolBedkowski
Copy link
Author

Hi, sorry, i couldn't answer earlier.

Ok, but imho this behavior is at least confusing. Maybe this should be more highlighted.
When I set some cells list and set "outside" I assume all cells that don't bellow to this list trigger this sensor, no matter its known/configured or not.

My usecase is quite simple - I have "home" cells list and want to set some profiles when I outside this area. I don't want to configure all cells in the world. (this is simplified - due to other rules I need to add many more rules to handle it; my change simplify it a lot).

From other side - I not sure what is purpose to this switch - if I need to specify all "outside" cells in any list I guess I can simple select this "other" list and don't use "outside" switch at all.

I don't use other sensors from list above, maybe there is different situation. However years ago (other soft) I have rule "when I have not connected to one of may trusted wifi network - start vpn". If I need add all "temporary" wifi networks to some list to get if work - imho something is wrong.

Regards,
K.

@henrichg
Copy link
Owner

henrichg commented Jun 15, 2024

Example: in event are configured all cells at home. This is 5-6 cells in my home.
I want to start event, when mobile is outside of home = outside of ALL configured home cells. And for this is good to use "start when outside".

@KarolBedkowski
Copy link
Author

Yes, i try it already. But it not work. Cell must be added to any other list to trigger home + outside. So seems to be bug.

Maybe I'm wrong, but looking into code you get
db.addMobileCellsToList(_cellsList, registeredCell)
when registeredCell is not know in PPP, cellsList is empty so in loop is skipped and no other action taken.

@henrichg
Copy link
Owner

henrichg commented Jun 15, 2024

Sorry, I do not understand.
If "Start when outside mobile cell" si checked, "Mobile cells sensor" sets pass status to true (green) when ALL cells in this sensor are outside of mobile (= mobile is not connected to any cell configured in this sensor).

But: sensor uses only saved mobile cells, saved to db by mobile cells scanner.

"db.addMobileCellsToList(_cellsList, registeredCell)" adds cells from DB to _cellsList. And if registeredCell is not 0, then adds only this cell.
registeredCell is cell from system, to this cell is mobile currently connected.

Mobile cells scanner is running in background and saves connected cells to db.
Detected mobile cells by scanner are not automatically added. Are added only by user interaction. User must allow to add it.

And yes, if registeredCell is not in saved cells, then returned is empty list.
Then yes, if mobile is connected to cell, which is not saved to DB by scanner this cell is then ignored.
If mobile cells scanner add it latter, then will be used by sensor.

@henrichg
Copy link
Owner

henrichg commented Jun 15, 2024

Important: registeredCell is not cell saved to db by scanner or configured in sensor. It is cell returned by system. To this cell is mobile actually connected.

@henrichg
Copy link
Owner

henrichg commented Jun 15, 2024

Example: Mobile is connected to cell, which is not in sensor and in db. Then how to check it? If you are at home and mobile is connected to new, not saved, not configured cell, then is not possible to mark it as "inside" of home. It is unknown cell. It must be saved by scanner and added to configured cells in sensor. By me, better is ignoring this cell.

@KarolBedkowski
Copy link
Author

I understand.

There is no problem with ignoring cell when "Start when outside..." is off. But for rules with enable "outside", connection to unknown cell should not be ignored, and imo PPP should take it into consideration. After all we are "outside" given list (all lists to be precise).

My patch change behavior only when "Start when outside..." is on - if current connected cell is not registered in PPP - result of sensor is positive. So rules are property activated.
If "Start when outside.." is off - nothing changed and cell is ignored.

Anyway - this patch solve this problem for me, but if there is other idea for this - no problem. I thought this was a some kind of bug...

regards,
Karol

henrichg added a commit that referenced this pull request Jun 15, 2024
…n is checked "Start when outside mobile cell".
@henrichg
Copy link
Owner

henrichg commented Jun 15, 2024

Hm, but. When mobile IS outside of home, then is better to set pass status to true. :-) Hm, Hm.
Problem is only when mobile is in home. In this situation, unknown cell will be checked as outside even when mobile is in home. :-)
Then: I will implemnet it as in your patch.

@henrichg
Copy link
Owner

Impleneted. If you want, install and test this beta version:
https://drive.google.com/file/d/13V2Zkb5W4VxNdMiXfsRs5iuWflt2xasY/view?usp=drivesdk

@KarolBedkowski
Copy link
Author

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants