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

feat: make source_type configurable #49

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ For info on how these params appear in HA see [below](#home-assistant-configurat
* away: Custom location name to be sent when a device is no longer connected. Default: "not_home"
* fallback_sync_interval: Interval in seconds to perform a full sync of online/offline devices to HA. Enable this as a fallback option if you have issues with devices not being detected as 'offline' when they go out of WiFi range.
**NOTE**: this will perform a 'ubus get clients' call every X seconds, which could increase load on the router. Default 0 (disabled)
* source_type: This is the type of device that gets sent to HA to represent the tracking device. It defaults to 'router', but can also be set to 'gps' to allow for different zones/locations to work.
* debug: Enable or disable debugging (prints state information on stdout when enabled). Default: false

## (Optional) Home Assistant Configuration
Expand Down
3 changes: 2 additions & 1 deletion presence-detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(self, config_file: str) -> None:
"location": "home",
"away": "not_home",
"fallback_sync_interval": 0,
"source_type": "router",
"debug": False,
}
with open(config_file, "r", encoding="utf-8") as settings:
Expand Down Expand Up @@ -112,7 +113,7 @@ def _ha_seen(self, device: str, seen: bool = True) -> bool:
else:
location = self._settings.away

body = {"mac": device, "location_name": location, "source_type": "router"}
body = {"mac": device, "location_name": location, "source_type": self._settings.source_type}
if device in self._settings.params:
body.update(self._settings.params[device])
if self._settings.ap_name:
Expand Down
1 change: 1 addition & 0 deletions presence-detector.settings.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"location": "home",
"away": "not_home",
"fallback_sync_interval": 0,
"source_type": "router",
"debug": false
}
Loading