Skip to content

Commit

Permalink
Add: Tracker history position (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
FukjemiCZ authored Jan 13, 2024
1 parent c9e2882 commit 0cf1fe2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ await tracker.hw_info() # Includes battery level, firmware version, model and so
await tracker.pos_report() # Includes coordinates, latitude, speed and so on
# Retrieve hardware info

# Retrive history positions
```python
now = datetime.timestamp(datetime.now())
time_from = now - 3600 * LAST_HOURS
time_to = now
format = json_segments
await tracker.positions(time_from, time_to, format):
```

# Control the buzzer
await set_buzzer_active(True) # or False

Expand Down
9 changes: 9 additions & 0 deletions aiotractive/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ async def pos_report(self):
f"device_pos_report/{self._id}",
)

async def positions(self, time_from, time_to, format):
url = f"tracker/{self._id}/positions"
params = {
"time_from": time_from,
"time_to": time_to,
"format": format,
}
return await self._api.request(url, params=params)

async def set_buzzer_active(self, active):
action = self.ACTIONS[active]

Expand Down

0 comments on commit 0cf1fe2

Please sign in to comment.