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

[gpstracker] Incorrect Item switched ON/OFF if region partially matches the target regionName #10240

Open
Dopeyr opened this issue Feb 25, 2021 · 1 comment · May be fixed by #17805
Open

[gpstracker] Incorrect Item switched ON/OFF if region partially matches the target regionName #10240

Dopeyr opened this issue Feb 25, 2021 · 1 comment · May be fixed by #17805
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@Dopeyr
Copy link

Dopeyr commented Feb 25, 2021

Hi,

I'm not sure if this is a bug, or a documentation issue. I think it can be covered with the latter.

I have two regions defined:

Thing gpstracker:tracker:XX   "GPS tracker - XX" [trackerId="XX"] {
    Channels:
            Type regionDistance : distanceHome "Distance from Home" [
                regionName="Home",
                regionCenterLocation="YY,XX",
                regionRadius=100,
                accuracyThreshold=0
            ]
            Type regionDistance : distanceHomeClose "Close to Home" [
                regionName="HomeClose",
                regionCenterLocation="YY,XX",
                regionRadius=1000,
                accuracyThreshold=0
            ]

Note the difference in radius.

There are 2 items connected to each channel, e.g. XX_Is_At_Home an XX_Is_Close_To_Home respectively.

When the /enter trigger is received, both XX_Is_At_Home and XX_Is_Close_To_Home are set to true, even though only XX_Is_Close_To_Home should be.

2021-02-23 14:19:30.093 [DEBUG] [nal.provider.AbstractCallbackServlet] - Post message received from OwnTracks tracker: {"_type":"location","acc":15,"alt":118,"batt":83,"conn":"m","lat":YY,"lon":XX,"tid":"XX","tst":1614089969,"vac":1,"vel":0}
2021-02-23 14:19:30.094 [DEBUG] [cker.internal.handler.TrackerHandler] - Update base channels for tracker XX from message: LocationMessage [type=location, trackerId=XX, latitude=YY, longitude=XX, gpsAccuracy=15, batteryLevel=83, timestampMillis=1614089969]
2021-02-23 14:19:30.095 [DEBUG] [cker.internal.handler.TrackerHandler] - Updating distance channels tracker XX
2021-02-23 14:19:30.095 [DEBUG] [cker.internal.handler.TrackerHandler] - Location accuracy threshold check is disabled.
2021-02-23 14:19:30.095 [DEBUG] [cker.internal.handler.TrackerHandler] - Location accuracy threshold check is disabled.
2021-02-23 14:19:30.096 [DEBUG] [cker.internal.handler.TrackerHandler] - Location accuracy threshold check is disabled.
2021-02-23 14:19:30.101 [DEBUG] [cker.internal.handler.TrackerHandler] - Location accuracy threshold check is disabled.
2021-02-23 14:19:30.101 [DEBUG] [cker.internal.handler.TrackerHandler] - Location accuracy threshold check is disabled.
2021-02-23 14:19:30.103 [DEBUG] [ofile.GPSTrackerTriggerSwitchProfile] - Transition trigger HomeClose/enter handled for region HomeClose by profile: ON
2021-02-23 14:19:30.104 [DEBUG] [ofile.GPSTrackerTriggerSwitchProfile] - Transition trigger HomeClose/enter handled for region Home by profile: ON
2021-02-23 14:19:30.108 [DEBUG] [cker.internal.handler.TrackerHandler] - Location accuracy threshold check is disabled.
2021-02-23 14:19:30.111 [DEBUG] [cker.internal.handler.TrackerHandler] - Location accuracy threshold check is disabled.

Note that HomeClose/enter triggers both regions to be switched on:

2021-02-23 14:19:30.103 [DEBUG] [ofile.GPSTrackerTriggerSwitchProfile] - Transition trigger HomeClose/enter handled for region HomeClose by profile: ON
2021-02-23 14:19:30.104 [DEBUG] [ofile.GPSTrackerTriggerSwitchProfile] - Transition trigger HomeClose/enter handled for region Home by profile: ON

I have tracked this down to

The regionNames are matched by the start of the string, not identical strings.

IMO calling this a bug is incorrect as the startsWidth is there for a reason and could be useful(?), but I think this could be made clear in the documentation. It's been a head scatcher for me recently :)

Of course, the solution is to make the region names unique.

Happy to submit a PR if you agree.

@lsiepel
Copy link
Contributor

lsiepel commented Nov 25, 2024

According to the documentation the payload has a "{region}/{event}" format. The quoted code uses a startsWith and endsWith determination. I think it is better to split by the / as that makes it possible to do a full match to the regionname

@lsiepel lsiepel added bug An unexpected problem or unintended behavior of an add-on and removed documentation labels Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants