lifx-emulator 2.3.1__py3-none-any.whl → 3.0.1__py3-none-any.whl
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.
- lifx_emulator-3.0.1.dist-info/METADATA +102 -0
- lifx_emulator-3.0.1.dist-info/RECORD +18 -0
- lifx_emulator-3.0.1.dist-info/entry_points.txt +2 -0
- lifx_emulator_app/__init__.py +10 -0
- {lifx_emulator → lifx_emulator_app}/__main__.py +13 -5
- {lifx_emulator → lifx_emulator_app}/api/__init__.py +1 -1
- {lifx_emulator → lifx_emulator_app}/api/app.py +3 -3
- {lifx_emulator → lifx_emulator_app}/api/mappers/__init__.py +1 -1
- {lifx_emulator → lifx_emulator_app}/api/mappers/device_mapper.py +1 -1
- {lifx_emulator → lifx_emulator_app}/api/models.py +1 -2
- lifx_emulator_app/api/routers/__init__.py +11 -0
- {lifx_emulator → lifx_emulator_app}/api/routers/devices.py +2 -2
- {lifx_emulator → lifx_emulator_app}/api/routers/monitoring.py +1 -1
- {lifx_emulator → lifx_emulator_app}/api/routers/scenarios.py +1 -1
- lifx_emulator_app/api/services/__init__.py +8 -0
- {lifx_emulator → lifx_emulator_app}/api/services/device_service.py +3 -2
- lifx_emulator/__init__.py +0 -31
- lifx_emulator/api/routers/__init__.py +0 -11
- lifx_emulator/api/services/__init__.py +0 -8
- lifx_emulator/constants.py +0 -33
- lifx_emulator/devices/__init__.py +0 -37
- lifx_emulator/devices/device.py +0 -339
- lifx_emulator/devices/manager.py +0 -256
- lifx_emulator/devices/observers.py +0 -139
- lifx_emulator/devices/persistence.py +0 -308
- lifx_emulator/devices/state_restorer.py +0 -259
- lifx_emulator/devices/state_serializer.py +0 -157
- lifx_emulator/devices/states.py +0 -377
- lifx_emulator/factories/__init__.py +0 -37
- lifx_emulator/factories/builder.py +0 -373
- lifx_emulator/factories/default_config.py +0 -158
- lifx_emulator/factories/factory.py +0 -221
- lifx_emulator/factories/firmware_config.py +0 -77
- lifx_emulator/factories/serial_generator.py +0 -82
- lifx_emulator/handlers/__init__.py +0 -39
- lifx_emulator/handlers/base.py +0 -49
- lifx_emulator/handlers/device_handlers.py +0 -322
- lifx_emulator/handlers/light_handlers.py +0 -503
- lifx_emulator/handlers/multizone_handlers.py +0 -249
- lifx_emulator/handlers/registry.py +0 -110
- lifx_emulator/handlers/tile_handlers.py +0 -488
- lifx_emulator/products/__init__.py +0 -28
- lifx_emulator/products/generator.py +0 -1037
- lifx_emulator/products/registry.py +0 -1496
- lifx_emulator/products/specs.py +0 -284
- lifx_emulator/products/specs.yml +0 -352
- lifx_emulator/protocol/__init__.py +0 -1
- lifx_emulator/protocol/base.py +0 -446
- lifx_emulator/protocol/const.py +0 -8
- lifx_emulator/protocol/generator.py +0 -1384
- lifx_emulator/protocol/header.py +0 -159
- lifx_emulator/protocol/packets.py +0 -1351
- lifx_emulator/protocol/protocol_types.py +0 -817
- lifx_emulator/protocol/serializer.py +0 -379
- lifx_emulator/repositories/__init__.py +0 -22
- lifx_emulator/repositories/device_repository.py +0 -155
- lifx_emulator/repositories/storage_backend.py +0 -107
- lifx_emulator/scenarios/__init__.py +0 -22
- lifx_emulator/scenarios/manager.py +0 -322
- lifx_emulator/scenarios/models.py +0 -112
- lifx_emulator/scenarios/persistence.py +0 -241
- lifx_emulator/server.py +0 -464
- lifx_emulator-2.3.1.dist-info/METADATA +0 -107
- lifx_emulator-2.3.1.dist-info/RECORD +0 -62
- lifx_emulator-2.3.1.dist-info/entry_points.txt +0 -2
- lifx_emulator-2.3.1.dist-info/licenses/LICENSE +0 -35
- {lifx_emulator-2.3.1.dist-info → lifx_emulator-3.0.1.dist-info}/WHEEL +0 -0
- {lifx_emulator → lifx_emulator_app}/api/templates/dashboard.html +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lifx-emulator
|
|
3
|
+
Version: 3.0.1
|
|
4
|
+
Summary: Standalone LIFX Emulator with CLI and HTTP management API
|
|
5
|
+
Author-email: Avi Miller <me@dje.li>
|
|
6
|
+
Maintainer-email: Avi Miller <me@dje.li>
|
|
7
|
+
License-Expression: UPL-1.0
|
|
8
|
+
Classifier: Environment :: Console
|
|
9
|
+
Classifier: Framework :: AsyncIO
|
|
10
|
+
Classifier: Framework :: FastAPI
|
|
11
|
+
Classifier: Framework :: Pytest
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Software Development :: Testing
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: cyclopts>=4.2.0
|
|
23
|
+
Requires-Dist: fastapi>=0.115.0
|
|
24
|
+
Requires-Dist: lifx-emulator-core>=2.4.0
|
|
25
|
+
Requires-Dist: rich>=14.2.0
|
|
26
|
+
Requires-Dist: uvicorn>=0.34.0
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# lifx-emulator
|
|
30
|
+
|
|
31
|
+
Standalone LIFX device emulator with CLI and HTTP management API.
|
|
32
|
+
|
|
33
|
+
This package provides a ready-to-run emulator for testing LIFX LAN protocol libraries. It includes a command-line interface and an optional HTTP API for runtime device management.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install lifx-emulator
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Start with default configuration (1 color light)
|
|
45
|
+
lifx-emulator
|
|
46
|
+
|
|
47
|
+
# Create multiple device types
|
|
48
|
+
lifx-emulator --color 2 --multizone 1 --tile 1
|
|
49
|
+
|
|
50
|
+
# Enable HTTP management API
|
|
51
|
+
lifx-emulator --api
|
|
52
|
+
|
|
53
|
+
# List available LIFX products
|
|
54
|
+
lifx-emulator list-products
|
|
55
|
+
|
|
56
|
+
# Create devices by product ID
|
|
57
|
+
lifx-emulator --product 27 --product 38 --product 55
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Features
|
|
61
|
+
|
|
62
|
+
- Command-line interface for quick emulator setup
|
|
63
|
+
- HTTP management API with web dashboard
|
|
64
|
+
- Real-time device monitoring and management
|
|
65
|
+
- Support for all LIFX device types (color, multizone, tile, infrared, HEV, switch)
|
|
66
|
+
- Persistent device state across restarts
|
|
67
|
+
- Testing scenarios for protocol edge cases
|
|
68
|
+
|
|
69
|
+
## HTTP Management API
|
|
70
|
+
|
|
71
|
+
Enable with `--api` to get:
|
|
72
|
+
|
|
73
|
+
- **Web Dashboard**: `http://localhost:8080` - Real-time monitoring UI
|
|
74
|
+
- **REST API**: Device management, statistics, and scenario control
|
|
75
|
+
- **OpenAPI Docs**: `http://localhost:8080/docs` - Interactive API documentation
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Start with API server
|
|
79
|
+
lifx-emulator --color 2 --api --api-port 9090
|
|
80
|
+
|
|
81
|
+
# Add a device via API
|
|
82
|
+
curl -X POST http://localhost:9090/api/devices \
|
|
83
|
+
-H "Content-Type: application/json" \
|
|
84
|
+
-d '{"product_id": 27}'
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Documentation
|
|
88
|
+
|
|
89
|
+
Full documentation is available at: **https://djelibeybi.github.io/lifx-emulator**
|
|
90
|
+
|
|
91
|
+
- [Installation Guide](https://djelibeybi.github.io/lifx-emulator/getting-started/installation/)
|
|
92
|
+
- [CLI Reference](https://djelibeybi.github.io/lifx-emulator/cli/cli-reference/)
|
|
93
|
+
- [Web Interface](https://djelibeybi.github.io/lifx-emulator/cli/web-interface/)
|
|
94
|
+
- [REST API](https://djelibeybi.github.io/lifx-emulator/cli/device-management-api/)
|
|
95
|
+
|
|
96
|
+
## Related Packages
|
|
97
|
+
|
|
98
|
+
- **[lifx-emulator-core](https://pypi.org/project/lifx-emulator-core/)**: Core library for embedding the emulator in your own projects
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
[UPL-1.0](https://opensource.org/licenses/UPL)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
lifx_emulator_app/__init__.py,sha256=AJahGiWKb8U8yLQbJX21takbf-SoxDxMOGxjJeM7M5c,222
|
|
2
|
+
lifx_emulator_app/__main__.py,sha256=f_VwgZfwOdp3zQshv8JQqBX7gocE9ATZbZ3wQndlBvo,22060
|
|
3
|
+
lifx_emulator_app/api/__init__.py,sha256=bpdhugx7PAop5IQhkKnWE-a1hfI9gJoJiNRG2CCWe5A,651
|
|
4
|
+
lifx_emulator_app/api/app.py,sha256=_bltPTPyw9mmPVAPHm9sJytzsovq5bgE8-CDRulnWYQ,4892
|
|
5
|
+
lifx_emulator_app/api/models.py,sha256=fiX9hDmR1C12tzet-kGPmbaG_qiZfiprgy-uxwIcEsE,3970
|
|
6
|
+
lifx_emulator_app/api/mappers/__init__.py,sha256=-lGAg-s16eTMl2_D-3bPu-EMqD2kaPzXHqSrKCnmW2w,156
|
|
7
|
+
lifx_emulator_app/api/mappers/device_mapper.py,sha256=WAo-_PJ2kX3J4GUW_Sjoype1d_uaIh-PtXPfMUAujUY,4155
|
|
8
|
+
lifx_emulator_app/api/routers/__init__.py,sha256=TKPypociZ_uo2YCyW5zIeUfalUh_PkzCVt31MHg9ZPc,381
|
|
9
|
+
lifx_emulator_app/api/routers/devices.py,sha256=5_0Id09Z6yOB3s-uAEAU4oNribV49IitC0-_Bmx3bCk,4218
|
|
10
|
+
lifx_emulator_app/api/routers/monitoring.py,sha256=i82_s61caYd9UvMb4MqWPLP7LuFh5KN8Qkw4_dZr3O0,1460
|
|
11
|
+
lifx_emulator_app/api/routers/scenarios.py,sha256=pWXTliY9MIk-DCxDOZ1cjeAFgHn79ExvY-6lj-yHPWk,9747
|
|
12
|
+
lifx_emulator_app/api/services/__init__.py,sha256=cdKZItYE-KkMX44V9xJW_PHHnJoAw5I7Uw1a1YKHgMI,285
|
|
13
|
+
lifx_emulator_app/api/services/device_service.py,sha256=A2rCuZ1aAJ1tThKM6BYorKAjlaDgDaFCT5C9KUHfAvc,6303
|
|
14
|
+
lifx_emulator_app/api/templates/dashboard.html,sha256=h-PeOH_La5bVOUBcXmTY2leRlMdL8D8yJ-NCx3S16-A,33792
|
|
15
|
+
lifx_emulator-3.0.1.dist-info/METADATA,sha256=SHfU2nVUc6ihUB8AYOjmMUG0YhVmJkzZILVKFeDMED8,3174
|
|
16
|
+
lifx_emulator-3.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
17
|
+
lifx_emulator-3.0.1.dist-info/entry_points.txt,sha256=tNZHeJTPUXNxu_nuk99ArXLKgwYLhIVVxN7YiaiXBOA,66
|
|
18
|
+
lifx_emulator-3.0.1.dist-info/RECORD,,
|
|
@@ -6,8 +6,6 @@ import signal
|
|
|
6
6
|
from typing import Annotated
|
|
7
7
|
|
|
8
8
|
import cyclopts
|
|
9
|
-
from rich.logging import RichHandler
|
|
10
|
-
|
|
11
9
|
from lifx_emulator.constants import LIFX_UDP_PORT
|
|
12
10
|
from lifx_emulator.devices import (
|
|
13
11
|
DEFAULT_STORAGE_DIR,
|
|
@@ -21,12 +19,14 @@ from lifx_emulator.factories import (
|
|
|
21
19
|
create_hev_light,
|
|
22
20
|
create_infrared_light,
|
|
23
21
|
create_multizone_light,
|
|
22
|
+
create_switch,
|
|
24
23
|
create_tile_device,
|
|
25
24
|
)
|
|
26
25
|
from lifx_emulator.products.registry import get_registry
|
|
27
26
|
from lifx_emulator.repositories import DeviceRepository
|
|
28
27
|
from lifx_emulator.scenarios import ScenarioPersistenceAsyncFile
|
|
29
28
|
from lifx_emulator.server import EmulatedLifxServer
|
|
29
|
+
from rich.logging import RichHandler
|
|
30
30
|
|
|
31
31
|
app = cyclopts.App(
|
|
32
32
|
name="lifx-emulator",
|
|
@@ -239,6 +239,7 @@ async def run(
|
|
|
239
239
|
hev: Annotated[int, cyclopts.Parameter(group=device_group)] = 0,
|
|
240
240
|
multizone: Annotated[int, cyclopts.Parameter(group=device_group)] = 0,
|
|
241
241
|
tile: Annotated[int, cyclopts.Parameter(group=device_group)] = 0,
|
|
242
|
+
switch: Annotated[int, cyclopts.Parameter(group=device_group)] = 0,
|
|
242
243
|
# Multizone Options
|
|
243
244
|
multizone_zones: Annotated[
|
|
244
245
|
int | None, cyclopts.Parameter(group=multizone_group)
|
|
@@ -284,6 +285,7 @@ async def run(
|
|
|
284
285
|
multizone_extended: Enable extended multizone support (Beam).
|
|
285
286
|
Set --no-multizone-extended for basic multizone (Z) devices.
|
|
286
287
|
tile: Number of tile/matrix chain devices.
|
|
288
|
+
switch: Number of LIFX Switch devices (relays, no lighting).
|
|
287
289
|
tile_count: Number of tiles per device. Uses product defaults if not
|
|
288
290
|
specified (5 for Tile, 1 for Candle/Ceiling).
|
|
289
291
|
tile_width: Width of each tile in zones. Uses product defaults if not
|
|
@@ -310,7 +312,7 @@ async def run(
|
|
|
310
312
|
lifx-emulator --color 2 --multizone 1 --tile 1 --api --verbose
|
|
311
313
|
|
|
312
314
|
Create only specific device types:
|
|
313
|
-
lifx-emulator --color 0 --infrared 3 --hev 2
|
|
315
|
+
lifx-emulator --color 0 --infrared 3 --hev 2 --switch 2
|
|
314
316
|
|
|
315
317
|
Custom serial prefix:
|
|
316
318
|
lifx-emulator --serial-prefix cafe00 --color 5
|
|
@@ -410,6 +412,7 @@ async def run(
|
|
|
410
412
|
and infrared == 0
|
|
411
413
|
and hev == 0
|
|
412
414
|
and multizone == 0
|
|
415
|
+
and switch == 0
|
|
413
416
|
):
|
|
414
417
|
color = 0
|
|
415
418
|
|
|
@@ -423,6 +426,7 @@ async def run(
|
|
|
423
426
|
and hev == 0
|
|
424
427
|
and multizone == 0
|
|
425
428
|
and tile == 0
|
|
429
|
+
and switch == 0
|
|
426
430
|
):
|
|
427
431
|
color = 0
|
|
428
432
|
|
|
@@ -467,13 +471,17 @@ async def run(
|
|
|
467
471
|
)
|
|
468
472
|
)
|
|
469
473
|
|
|
474
|
+
# Create switch devices
|
|
475
|
+
for _ in range(switch):
|
|
476
|
+
devices.append(create_switch(get_serial(), storage=storage))
|
|
477
|
+
|
|
470
478
|
if not devices:
|
|
471
479
|
if persistent:
|
|
472
480
|
logger.warning("No devices configured. Server will run with no devices.")
|
|
473
481
|
logger.info("Use API (--api) or restart with device flags to add devices.")
|
|
474
482
|
else:
|
|
475
483
|
logger.error(
|
|
476
|
-
"No devices configured. Use --color, --multizone, --tile, "
|
|
484
|
+
"No devices configured. Use --color, --multizone, --tile, --switch, "
|
|
477
485
|
"etc. to add devices."
|
|
478
486
|
)
|
|
479
487
|
return
|
|
@@ -520,7 +528,7 @@ async def run(
|
|
|
520
528
|
# Start API server if enabled
|
|
521
529
|
api_task = None
|
|
522
530
|
if api:
|
|
523
|
-
from
|
|
531
|
+
from lifx_emulator_app.api import run_api_server
|
|
524
532
|
|
|
525
533
|
logger.info("Starting HTTP API server on http://%s:%s", api_host, api_port)
|
|
526
534
|
api_task = asyncio.create_task(run_api_server(server, api_host, api_port))
|
|
@@ -10,7 +10,7 @@ of concerns.
|
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
# Import from new refactored structure
|
|
13
|
-
from
|
|
13
|
+
from lifx_emulator_app.api.app import create_api_app, run_api_server
|
|
14
14
|
|
|
15
15
|
# Note: HTML_UI remains in the old lifx_emulator/api.py file temporarily
|
|
16
16
|
# TODO: Phase 1.1d - extract HTML template to separate file
|
|
@@ -19,9 +19,9 @@ from fastapi.templating import Jinja2Templates
|
|
|
19
19
|
if TYPE_CHECKING:
|
|
20
20
|
from lifx_emulator.server import EmulatedLifxServer
|
|
21
21
|
|
|
22
|
-
from
|
|
23
|
-
from
|
|
24
|
-
from
|
|
22
|
+
from lifx_emulator_app.api.routers.devices import create_devices_router
|
|
23
|
+
from lifx_emulator_app.api.routers.monitoring import create_monitoring_router
|
|
24
|
+
from lifx_emulator_app.api.routers.scenarios import create_scenarios_router
|
|
25
25
|
|
|
26
26
|
logger = logging.getLogger(__name__)
|
|
27
27
|
|
|
@@ -7,7 +7,7 @@ from typing import TYPE_CHECKING
|
|
|
7
7
|
if TYPE_CHECKING:
|
|
8
8
|
from lifx_emulator.devices import EmulatedLifxDevice
|
|
9
9
|
|
|
10
|
-
from
|
|
10
|
+
from lifx_emulator_app.api.models import ColorHsbk, DeviceInfo
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class DeviceMapper:
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"""Pydantic models for API requests and responses."""
|
|
2
2
|
|
|
3
|
-
from pydantic import BaseModel, Field, field_validator
|
|
4
|
-
|
|
5
3
|
# Import shared domain models
|
|
6
4
|
from lifx_emulator.scenarios import ScenarioConfig
|
|
5
|
+
from pydantic import BaseModel, Field, field_validator
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
class DeviceCreateRequest(BaseModel):
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""API routers for LIFX emulator endpoints."""
|
|
2
|
+
|
|
3
|
+
from lifx_emulator_app.api.routers.devices import create_devices_router
|
|
4
|
+
from lifx_emulator_app.api.routers.monitoring import create_monitoring_router
|
|
5
|
+
from lifx_emulator_app.api.routers.scenarios import create_scenarios_router
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"create_monitoring_router",
|
|
9
|
+
"create_devices_router",
|
|
10
|
+
"create_scenarios_router",
|
|
11
|
+
]
|
|
@@ -9,8 +9,8 @@ from fastapi import APIRouter, HTTPException
|
|
|
9
9
|
if TYPE_CHECKING:
|
|
10
10
|
from lifx_emulator.server import EmulatedLifxServer
|
|
11
11
|
|
|
12
|
-
from
|
|
13
|
-
from
|
|
12
|
+
from lifx_emulator_app.api.models import DeviceCreateRequest, DeviceInfo
|
|
13
|
+
from lifx_emulator_app.api.services.device_service import (
|
|
14
14
|
DeviceAlreadyExistsError,
|
|
15
15
|
DeviceCreationError,
|
|
16
16
|
DeviceNotFoundError,
|
|
@@ -9,7 +9,7 @@ from fastapi import APIRouter
|
|
|
9
9
|
if TYPE_CHECKING:
|
|
10
10
|
from lifx_emulator.server import EmulatedLifxServer
|
|
11
11
|
|
|
12
|
-
from
|
|
12
|
+
from lifx_emulator_app.api.models import ActivityEvent, ServerStats
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
def create_monitoring_router(server: EmulatedLifxServer) -> APIRouter:
|
|
@@ -9,7 +9,7 @@ from fastapi import APIRouter, HTTPException
|
|
|
9
9
|
if TYPE_CHECKING:
|
|
10
10
|
from lifx_emulator.server import EmulatedLifxServer
|
|
11
11
|
|
|
12
|
-
from
|
|
12
|
+
from lifx_emulator_app.api.models import ScenarioConfig, ScenarioResponse
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
def _validate_device_serial(serial: str) -> bool:
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""Business logic services for API endpoints."""
|
|
2
|
+
|
|
3
|
+
from lifx_emulator_app.api.services.device_service import DeviceService
|
|
4
|
+
|
|
5
|
+
# TODO: Create ScenarioService (Phase 1.1b completion)
|
|
6
|
+
# from lifx_emulator_app.api.services.scenario_service import ScenarioService
|
|
7
|
+
|
|
8
|
+
__all__ = ["DeviceService"]
|
|
@@ -13,10 +13,11 @@ from typing import TYPE_CHECKING
|
|
|
13
13
|
if TYPE_CHECKING:
|
|
14
14
|
from lifx_emulator.server import EmulatedLifxServer
|
|
15
15
|
|
|
16
|
-
from lifx_emulator.api.mappers import DeviceMapper
|
|
17
|
-
from lifx_emulator.api.models import DeviceCreateRequest, DeviceInfo
|
|
18
16
|
from lifx_emulator.factories import create_device
|
|
19
17
|
|
|
18
|
+
from lifx_emulator_app.api.mappers import DeviceMapper
|
|
19
|
+
from lifx_emulator_app.api.models import DeviceCreateRequest, DeviceInfo
|
|
20
|
+
|
|
20
21
|
logger = logging.getLogger(__name__)
|
|
21
22
|
|
|
22
23
|
|
lifx_emulator/__init__.py
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"""LIFX Emulator
|
|
2
|
-
|
|
3
|
-
A comprehensive LIFX emulator for testing LIFX LAN protocol libraries.
|
|
4
|
-
Implements the binary UDP protocol documented at https://lan.developer.lifx.com
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from importlib.metadata import version as get_version
|
|
8
|
-
|
|
9
|
-
from lifx_emulator.devices import EmulatedLifxDevice
|
|
10
|
-
from lifx_emulator.factories import (
|
|
11
|
-
create_color_light,
|
|
12
|
-
create_color_temperature_light,
|
|
13
|
-
create_hev_light,
|
|
14
|
-
create_infrared_light,
|
|
15
|
-
create_multizone_light,
|
|
16
|
-
create_tile_device,
|
|
17
|
-
)
|
|
18
|
-
from lifx_emulator.server import EmulatedLifxServer
|
|
19
|
-
|
|
20
|
-
__version__ = get_version("lifx_emulator")
|
|
21
|
-
|
|
22
|
-
__all__ = [
|
|
23
|
-
"EmulatedLifxServer",
|
|
24
|
-
"EmulatedLifxDevice",
|
|
25
|
-
"create_color_light",
|
|
26
|
-
"create_color_temperature_light",
|
|
27
|
-
"create_hev_light",
|
|
28
|
-
"create_infrared_light",
|
|
29
|
-
"create_multizone_light",
|
|
30
|
-
"create_tile_device",
|
|
31
|
-
]
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"""API routers for LIFX emulator endpoints."""
|
|
2
|
-
|
|
3
|
-
from lifx_emulator.api.routers.devices import create_devices_router
|
|
4
|
-
from lifx_emulator.api.routers.monitoring import create_monitoring_router
|
|
5
|
-
from lifx_emulator.api.routers.scenarios import create_scenarios_router
|
|
6
|
-
|
|
7
|
-
__all__ = [
|
|
8
|
-
"create_monitoring_router",
|
|
9
|
-
"create_devices_router",
|
|
10
|
-
"create_scenarios_router",
|
|
11
|
-
]
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"""Business logic services for API endpoints."""
|
|
2
|
-
|
|
3
|
-
from lifx_emulator.api.services.device_service import DeviceService
|
|
4
|
-
|
|
5
|
-
# TODO: Create ScenarioService (Phase 1.1b completion)
|
|
6
|
-
# from lifx_emulator.api.services.scenario_service import ScenarioService
|
|
7
|
-
|
|
8
|
-
__all__ = ["DeviceService"]
|
lifx_emulator/constants.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"""Protocol constants for LIFX LAN Protocol"""
|
|
2
|
-
|
|
3
|
-
from typing import Final
|
|
4
|
-
|
|
5
|
-
# ============================================================================
|
|
6
|
-
# Network Constants
|
|
7
|
-
# ============================================================================
|
|
8
|
-
|
|
9
|
-
# LIFX UDP port for device communication
|
|
10
|
-
LIFX_UDP_PORT: Final[int] = 56700
|
|
11
|
-
|
|
12
|
-
# LIFX Protocol version
|
|
13
|
-
LIFX_PROTOCOL_VERSION: Final[int] = 1024
|
|
14
|
-
|
|
15
|
-
# Header size in bytes
|
|
16
|
-
LIFX_HEADER_SIZE: Final[int] = 36
|
|
17
|
-
|
|
18
|
-
# Backward compatibility alias
|
|
19
|
-
HEADER_SIZE = LIFX_HEADER_SIZE
|
|
20
|
-
|
|
21
|
-
# ============================================================================
|
|
22
|
-
# Official LIFX Repository URLs
|
|
23
|
-
# ============================================================================
|
|
24
|
-
|
|
25
|
-
# Official LIFX protocol specification URL
|
|
26
|
-
PROTOCOL_URL: Final[str] = (
|
|
27
|
-
"https://raw.githubusercontent.com/LIFX/public-protocol/refs/heads/main/protocol.yml"
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
# Official LIFX products specification URL
|
|
31
|
-
PRODUCTS_URL: Final[str] = (
|
|
32
|
-
"https://raw.githubusercontent.com/LIFX/products/refs/heads/master/products.json"
|
|
33
|
-
)
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"""Device management module for LIFX emulator.
|
|
2
|
-
|
|
3
|
-
This module contains all device-related functionality including:
|
|
4
|
-
- Device core (EmulatedLifxDevice)
|
|
5
|
-
- Device manager (DeviceManager, IDeviceManager)
|
|
6
|
-
- Device states (DeviceState and related dataclasses)
|
|
7
|
-
- Device persistence (async file storage)
|
|
8
|
-
- State restoration and serialization
|
|
9
|
-
- Device state observers (ActivityObserver, ActivityLogger, PacketEvent, NullObserver)
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
from lifx_emulator.devices.device import EmulatedLifxDevice
|
|
13
|
-
from lifx_emulator.devices.manager import DeviceManager, IDeviceManager
|
|
14
|
-
from lifx_emulator.devices.observers import (
|
|
15
|
-
ActivityLogger,
|
|
16
|
-
ActivityObserver,
|
|
17
|
-
NullObserver,
|
|
18
|
-
PacketEvent,
|
|
19
|
-
)
|
|
20
|
-
from lifx_emulator.devices.persistence import (
|
|
21
|
-
DEFAULT_STORAGE_DIR,
|
|
22
|
-
DevicePersistenceAsyncFile,
|
|
23
|
-
)
|
|
24
|
-
from lifx_emulator.devices.states import DeviceState
|
|
25
|
-
|
|
26
|
-
__all__ = [
|
|
27
|
-
"EmulatedLifxDevice",
|
|
28
|
-
"DeviceManager",
|
|
29
|
-
"IDeviceManager",
|
|
30
|
-
"DeviceState",
|
|
31
|
-
"DevicePersistenceAsyncFile",
|
|
32
|
-
"DEFAULT_STORAGE_DIR",
|
|
33
|
-
"ActivityObserver",
|
|
34
|
-
"ActivityLogger",
|
|
35
|
-
"PacketEvent",
|
|
36
|
-
"NullObserver",
|
|
37
|
-
]
|