itsTako_alerts_library
refer to Melius I+D
Speed alert driver notifications
Driver lookup and Telegram delivery are opt-in. Pass driver_notification_config
to SpeedAlerts to enable them; omit it to retain the existing synchronous
WhatsApp flow.
SpeedAlerts(
redis_client=redis_client,
whatsapp_config=whatsapp_config,
time_window=60,
alert_threshold=2,
driver_notification_config={
"api_key": os.getenv("TAKO_API_KEY"),
"telegram_bot_token": os.getenv("TELEGRAM_TOKEN_EMASIVO"),
"max_workers": 2,
"request_timeout": 5,
},
)
The trips API URL defaults to the Emasivo external trips endpoint and can be
overridden with trips_api_url. The API key is sent as x-api-key. Bus IDs
matching ZXX2222 are normalized to ZXX-2222 for lookup only. Background
workers perform driver lookup, WhatsApp/Telegram delivery, reverse geocoding,
and alert persistence without blocking the queue consumer.
Telegram messages include the alert bus and local time. When valid coordinates are available, they also include a Ver ubicación button that opens the alert location in Google Maps.
Behavior alert code 4 (distracted driving) is disabled. Codes 1, 2, and
3 remain enabled.
Speed alerts inside KML zones
Create a SpeedZoneLookup with a KML file or folder and a dictionary that maps
each KML placemark name to its speed limit in km/h. Pass the lookup to
SpeedAlerts. Samples outside all configured zones are ignored. Samples inside
a zone use that zone's speed limit.
from its_system_alerts.system.alerts.speed_alerts import SpeedAlerts
from its_system_alerts.system.alerts.speed_zones import SpeedZoneLookup
zones = SpeedZoneLookup(
kml_path="app/speed_zones",
speed_limits={"Polígono1": 30, "Polígono2": 40},
)
speed_alerts = SpeedAlerts(
redis_client=redis_client,
whatsapp_config=whatsapp_config,
time_window=60,
alert_threshold=2,
speed_zones=zones,
alert_source="speed_zone",
)
Each consumer can create its own lookup from its KML files and speed dictionary.
Set a different alert_source for each stream when each stream needs separate
Redis counters and cooldowns. The database alert type remains the standard
speed alert type.
Metadata
Release files for tako-alerts-system 0.2.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tako_alerts_system-0.2.13.tar.gz | 16.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tako_alerts_system-0.2.13-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.9 kB
Release files / tako_alerts_system-0.2.13.tar.gz
| Download URL | tako_alerts_system-0.2.13.tar.gz |
|---|---|
| Size | 16.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ccdd0df492556b3302564634f1c668805f8dd0e358bd5e709ebdd1e2bff16cc
|
|
BLAKE2b-256 checksum How to use checksums |
7454d1b6290388282393fa036a3c36a530e1c5807b27b99bfb93fe2b8f027130
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / tako_alerts_system-0.2.13-py3-none-any.whl
| Download URL | tako_alerts_system-0.2.13-py3-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac581457110c0c227f28257283630d11cec271bdf421c152f148540836681aaf
|
|
BLAKE2b-256 checksum How to use checksums |
12a14e6968aeb35299857712d4c2742b4a8acb27aec4aba56cef84604b2feb78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|