aiobirdnetgo 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hamish West
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,167 @@
1
+ Metadata-Version: 2.4
2
+ Name: aiobirdnetgo
3
+ Version: 0.1.0
4
+ Summary: Asynchronous Python client for the BirdNET-Go REST and SSE API
5
+ Author-email: Hamish West <hamish@hamishwest.xyz>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/tphakala/birdnet-go
8
+ Project-URL: Repository, https://github.com/tphakala/aiobirdnetgo
9
+ Project-URL: Bug Tracker, https://github.com/tphakala/aiobirdnetgo/issues
10
+ Keywords: birdnet,birdnet-go,homeassistant,audio,ai,birds
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Framework :: AsyncIO
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Home Automation
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.11
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: aiohttp>=3.9.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
30
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
31
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
32
+ Requires-Dist: mypy>=1.9.0; extra == "dev"
33
+ Requires-Dist: ruff>=0.3.0; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ # aiobirdnetgo
37
+
38
+ [![PyPI version](https://img.shields.io/pypi/v/aiobirdnetgo.svg)](https://pypi.org/project/aiobirdnetgo/)
39
+ [![Python versions](https://img.shields.io/pypi/pyversions/aiobirdnetgo.svg)](https://pypi.org/project/aiobirdnetgo/)
40
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
41
+
42
+ Asynchronous Python client library for the [BirdNET-Go](https://github.com/tphakala/birdnet-go) REST API and real-time Server-Sent Events (SSE) streaming.
43
+
44
+ Designed primarily for integration with **Home Assistant Core** and other Python asyncio applications.
45
+
46
+ ---
47
+
48
+ ## Features
49
+
50
+ - ⚡ **Asynchronous:** Built entirely on top of `aiohttp` and `asyncio`.
51
+ - 🔍 **Type-Safe:** Frozen dataclasses with full typing support (`py.typed`).
52
+ - 🐦 **Real-Time Detection Streaming:** Built-in SSE listener with automatic reconnection and heartbeat handling.
53
+ - 📊 **Dashboard KPIs & Analytics:** Fetch daily species summaries, lifetime statistics, and detection streaks.
54
+ - 🎙️ **Multi-Source Audio:** Discovers and maps audio devices and RTSP stream sources.
55
+ - 🎛️ **Engine Control:** Restart analysis engine or reload classifier models remotely.
56
+
57
+ ---
58
+
59
+ ## Installation
60
+
61
+ ```bash
62
+ pip install aiobirdnetgo
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Quickstart
68
+
69
+ ### Basic API Usage & KPIs
70
+
71
+ ```python
72
+ import asyncio
73
+ from aiobirdnetgo import BirdNetGoClient
74
+
75
+
76
+ async def main():
77
+ async with BirdNetGoClient(host="192.168.1.50", port=8080) as client:
78
+ # Check connectivity
79
+ if await client.ping():
80
+ print("Connected to BirdNET-Go!")
81
+
82
+ # Get system health
83
+ health = await client.get_health()
84
+ print(f"Version: {health.version}, Status: {health.status}")
85
+
86
+ # Get dashboard headline KPIs
87
+ kpis = await client.get_kpis()
88
+ print(f"Today's detections: {kpis.today_detections}")
89
+ print(f"Lifetime species count: {kpis.lifetime_species}")
90
+ print(f"Current streak: {kpis.detection_streak.days} days")
91
+
92
+
93
+ if __name__ == "__main__":
94
+ asyncio.run(main())
95
+ ```
96
+
97
+ ---
98
+
99
+ ### Real-Time Detection Streaming (SSE)
100
+
101
+ ```python
102
+ import asyncio
103
+ from aiobirdnetgo import BirdNetGoClient
104
+
105
+
106
+ async def main():
107
+ async with BirdNetGoClient(host="192.168.1.50", port=8080) as client:
108
+ print("Listening for live bird detections...")
109
+
110
+ stream = client.stream_detections()
111
+ async for detection in stream:
112
+ print(f"🐦 Detected: {detection.common_name} ({detection.scientific_name})")
113
+ print(f" Confidence: {detection.confidence * 100:.1f}%")
114
+ print(f" Source: {detection.source_name or detection.source_id}")
115
+ if detection.bird_image:
116
+ print(f" Photo: {client.get_species_image_url(detection.scientific_name)}")
117
+
118
+
119
+ if __name__ == "__main__":
120
+ asyncio.run(main())
121
+ ```
122
+
123
+ ---
124
+
125
+ ### Managing Audio Sources & Recent Detections
126
+
127
+ ```python
128
+ import asyncio
129
+ from aiobirdnetgo import BirdNetGoClient
130
+
131
+
132
+ async def main():
133
+ async with BirdNetGoClient(host="192.168.1.50", port=8080) as client:
134
+ # List audio sources (sound cards & RTSP streams)
135
+ sources = await client.get_audio_sources()
136
+ for source in sources:
137
+ print(f"Source: {source.name} (ID: {source.id}, State: {source.state})")
138
+
139
+ # Fetch recent detections
140
+ detections = await client.get_recent_detections(limit=10)
141
+ for det in detections:
142
+ print(f"{det.time} - {det.common_name} ({det.confidence * 100:.0f}%)")
143
+
144
+
145
+ if __name__ == "__main__":
146
+ asyncio.run(main())
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Development & Testing
152
+
153
+ ```bash
154
+ # Clone the repository
155
+ git clone https://github.com/tphakala/aiobirdnetgo.git
156
+ cd aiobirdnetgo
157
+
158
+ # Install dependencies and dev tools
159
+ pip install -e ".[dev]"
160
+
161
+ # Run linter and type checker
162
+ ruff check .
163
+ mypy src tests
164
+
165
+ # Run unit tests with coverage
166
+ pytest
167
+ ```
@@ -0,0 +1,132 @@
1
+ # aiobirdnetgo
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/aiobirdnetgo.svg)](https://pypi.org/project/aiobirdnetgo/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/aiobirdnetgo.svg)](https://pypi.org/project/aiobirdnetgo/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ Asynchronous Python client library for the [BirdNET-Go](https://github.com/tphakala/birdnet-go) REST API and real-time Server-Sent Events (SSE) streaming.
8
+
9
+ Designed primarily for integration with **Home Assistant Core** and other Python asyncio applications.
10
+
11
+ ---
12
+
13
+ ## Features
14
+
15
+ - ⚡ **Asynchronous:** Built entirely on top of `aiohttp` and `asyncio`.
16
+ - 🔍 **Type-Safe:** Frozen dataclasses with full typing support (`py.typed`).
17
+ - 🐦 **Real-Time Detection Streaming:** Built-in SSE listener with automatic reconnection and heartbeat handling.
18
+ - 📊 **Dashboard KPIs & Analytics:** Fetch daily species summaries, lifetime statistics, and detection streaks.
19
+ - 🎙️ **Multi-Source Audio:** Discovers and maps audio devices and RTSP stream sources.
20
+ - 🎛️ **Engine Control:** Restart analysis engine or reload classifier models remotely.
21
+
22
+ ---
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install aiobirdnetgo
28
+ ```
29
+
30
+ ---
31
+
32
+ ## Quickstart
33
+
34
+ ### Basic API Usage & KPIs
35
+
36
+ ```python
37
+ import asyncio
38
+ from aiobirdnetgo import BirdNetGoClient
39
+
40
+
41
+ async def main():
42
+ async with BirdNetGoClient(host="192.168.1.50", port=8080) as client:
43
+ # Check connectivity
44
+ if await client.ping():
45
+ print("Connected to BirdNET-Go!")
46
+
47
+ # Get system health
48
+ health = await client.get_health()
49
+ print(f"Version: {health.version}, Status: {health.status}")
50
+
51
+ # Get dashboard headline KPIs
52
+ kpis = await client.get_kpis()
53
+ print(f"Today's detections: {kpis.today_detections}")
54
+ print(f"Lifetime species count: {kpis.lifetime_species}")
55
+ print(f"Current streak: {kpis.detection_streak.days} days")
56
+
57
+
58
+ if __name__ == "__main__":
59
+ asyncio.run(main())
60
+ ```
61
+
62
+ ---
63
+
64
+ ### Real-Time Detection Streaming (SSE)
65
+
66
+ ```python
67
+ import asyncio
68
+ from aiobirdnetgo import BirdNetGoClient
69
+
70
+
71
+ async def main():
72
+ async with BirdNetGoClient(host="192.168.1.50", port=8080) as client:
73
+ print("Listening for live bird detections...")
74
+
75
+ stream = client.stream_detections()
76
+ async for detection in stream:
77
+ print(f"🐦 Detected: {detection.common_name} ({detection.scientific_name})")
78
+ print(f" Confidence: {detection.confidence * 100:.1f}%")
79
+ print(f" Source: {detection.source_name or detection.source_id}")
80
+ if detection.bird_image:
81
+ print(f" Photo: {client.get_species_image_url(detection.scientific_name)}")
82
+
83
+
84
+ if __name__ == "__main__":
85
+ asyncio.run(main())
86
+ ```
87
+
88
+ ---
89
+
90
+ ### Managing Audio Sources & Recent Detections
91
+
92
+ ```python
93
+ import asyncio
94
+ from aiobirdnetgo import BirdNetGoClient
95
+
96
+
97
+ async def main():
98
+ async with BirdNetGoClient(host="192.168.1.50", port=8080) as client:
99
+ # List audio sources (sound cards & RTSP streams)
100
+ sources = await client.get_audio_sources()
101
+ for source in sources:
102
+ print(f"Source: {source.name} (ID: {source.id}, State: {source.state})")
103
+
104
+ # Fetch recent detections
105
+ detections = await client.get_recent_detections(limit=10)
106
+ for det in detections:
107
+ print(f"{det.time} - {det.common_name} ({det.confidence * 100:.0f}%)")
108
+
109
+
110
+ if __name__ == "__main__":
111
+ asyncio.run(main())
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Development & Testing
117
+
118
+ ```bash
119
+ # Clone the repository
120
+ git clone https://github.com/tphakala/aiobirdnetgo.git
121
+ cd aiobirdnetgo
122
+
123
+ # Install dependencies and dev tools
124
+ pip install -e ".[dev]"
125
+
126
+ # Run linter and type checker
127
+ ruff check .
128
+ mypy src tests
129
+
130
+ # Run unit tests with coverage
131
+ pytest
132
+ ```
@@ -0,0 +1,97 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "aiobirdnetgo"
7
+ version = "0.1.0"
8
+ description = "Asynchronous Python client for the BirdNET-Go REST and SSE API"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.11"
12
+ authors = [
13
+ { name = "Hamish West", email = "hamish@hamishwest.xyz" },
14
+ ]
15
+ keywords = ["birdnet", "birdnet-go", "homeassistant", "audio", "ai", "birds"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Framework :: AsyncIO",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Operating System :: OS Independent",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: 3.14",
27
+ "Topic :: Home Automation",
28
+ "Topic :: Software Development :: Libraries :: Python Modules",
29
+ "Typing :: Typed",
30
+ ]
31
+ dependencies = [
32
+ "aiohttp>=3.9.0",
33
+ ]
34
+
35
+ [project.optional-dependencies]
36
+ dev = [
37
+ "pytest>=8.0.0",
38
+ "pytest-asyncio>=0.23.0",
39
+ "pytest-cov>=4.1.0",
40
+ "mypy>=1.9.0",
41
+ "ruff>=0.3.0",
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/tphakala/birdnet-go"
46
+ Repository = "https://github.com/tphakala/aiobirdnetgo"
47
+ "Bug Tracker" = "https://github.com/tphakala/aiobirdnetgo/issues"
48
+
49
+ [tool.setuptools.packages.find]
50
+ where = ["src"]
51
+
52
+ [tool.setuptools.package-data]
53
+ aiobirdnetgo = ["py.typed"]
54
+
55
+ [tool.pytest.ini_options]
56
+ pythonpath = ["src"]
57
+ asyncio_mode = "auto"
58
+ testpaths = ["tests"]
59
+ addopts = "--cov=aiobirdnetgo --cov-report=term-missing"
60
+
61
+ [tool.mypy]
62
+ python_version = "3.11"
63
+ strict = true
64
+ warn_return_any = true
65
+ warn_unused_configs = true
66
+ disallow_untyped_defs = true
67
+ disallow_incomplete_defs = true
68
+ check_untyped_defs = true
69
+ disallow_untyped_decorators = true
70
+ no_implicit_optional = true
71
+ warn_redundant_casts = true
72
+ warn_unused_ignores = true
73
+ warn_no_return = true
74
+ warn_unreachable = true
75
+
76
+ [tool.ruff]
77
+ line-length = 100
78
+ target-version = "py311"
79
+
80
+ [tool.ruff.lint]
81
+ select = [
82
+ "E", # pycodestyle errors
83
+ "W", # pycodestyle warnings
84
+ "F", # pyflakes
85
+ "I", # isort
86
+ "UP", # pyupgrade
87
+ "B", # flake8-bugbear
88
+ "C4", # flake8-comprehensions
89
+ "ASYNC", # flake8-async
90
+ "T20", # flake8-print
91
+ "SIM", # flake8-simplify
92
+ "RUF", # ruff-specific rules
93
+ ]
94
+ ignore = []
95
+
96
+ [tool.ruff.lint.isort]
97
+ known-first-party = ["aiobirdnetgo"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,83 @@
1
+ """Asynchronous Python client for BirdNET-Go."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .client import BirdNetGoClient
6
+ from .const import (
7
+ DEFAULT_PORT,
8
+ DEFAULT_RECONNECT_INTERVAL,
9
+ DEFAULT_SSE_TIMEOUT,
10
+ DEFAULT_TIMEOUT,
11
+ MAX_RECONNECT_INTERVAL,
12
+ SSE_EVENT_AUDIO_LEVEL,
13
+ SSE_EVENT_CONNECTED,
14
+ SSE_EVENT_DETECTION,
15
+ SSE_EVENT_HEARTBEAT,
16
+ SSE_EVENT_PENDING,
17
+ )
18
+ from .exceptions import (
19
+ BirdNetGoAuthenticationError,
20
+ BirdNetGoConnectionError,
21
+ BirdNetGoError,
22
+ BirdNetGoNotFoundError,
23
+ BirdNetGoResponseError,
24
+ BirdNetGoTimeoutError,
25
+ )
26
+ from .models import (
27
+ AudioLevelEvent,
28
+ AudioLevelItem,
29
+ AudioSource,
30
+ BestDayInfo,
31
+ BirdImageInfo,
32
+ DashboardKPIs,
33
+ DatabaseHealth,
34
+ Detection,
35
+ HealthResponse,
36
+ PingResponse,
37
+ SpeciesDailySummary,
38
+ SpeciesSummary,
39
+ StreakInfo,
40
+ SystemInfo,
41
+ WeatherInfo,
42
+ )
43
+ from .stream import AudioLevelStream, DetectionStream, SSEMessage
44
+
45
+ __version__ = "0.1.0"
46
+
47
+ __all__ = [
48
+ "DEFAULT_PORT",
49
+ "DEFAULT_RECONNECT_INTERVAL",
50
+ "DEFAULT_SSE_TIMEOUT",
51
+ "DEFAULT_TIMEOUT",
52
+ "MAX_RECONNECT_INTERVAL",
53
+ "SSE_EVENT_AUDIO_LEVEL",
54
+ "SSE_EVENT_CONNECTED",
55
+ "SSE_EVENT_DETECTION",
56
+ "SSE_EVENT_HEARTBEAT",
57
+ "SSE_EVENT_PENDING",
58
+ "AudioLevelEvent",
59
+ "AudioLevelItem",
60
+ "AudioLevelStream",
61
+ "AudioSource",
62
+ "BestDayInfo",
63
+ "BirdImageInfo",
64
+ "BirdNetGoAuthenticationError",
65
+ "BirdNetGoClient",
66
+ "BirdNetGoConnectionError",
67
+ "BirdNetGoError",
68
+ "BirdNetGoNotFoundError",
69
+ "BirdNetGoResponseError",
70
+ "BirdNetGoTimeoutError",
71
+ "DashboardKPIs",
72
+ "DatabaseHealth",
73
+ "Detection",
74
+ "DetectionStream",
75
+ "HealthResponse",
76
+ "PingResponse",
77
+ "SSEMessage",
78
+ "SpeciesDailySummary",
79
+ "SpeciesSummary",
80
+ "StreakInfo",
81
+ "SystemInfo",
82
+ "WeatherInfo",
83
+ ]