Functioning mqtt ingestion and db write, formating changes, device manager initiated

This commit is contained in:
Andrej Mickov
2025-10-30 00:32:25 +01:00
parent 0b96c72f45
commit 12d3720421
45 changed files with 2168 additions and 820 deletions

View File

@@ -5,6 +5,7 @@ from typing import Optional
dotenv.load_dotenv()
@dataclass
class RedisConfig:
host: str
@@ -12,6 +13,7 @@ class RedisConfig:
db: int = 0
password: Optional[str] = None
@dataclass
class MQTTConfig:
broker: str
@@ -21,6 +23,7 @@ class MQTTConfig:
topic_pattern: str = "devices/#"
keepalive: int = 60
@dataclass
class Payload:
device_id: str
@@ -32,18 +35,19 @@ class Payload:
class Config:
def __init__(self):
self.redis = RedisConfig(
host=os.getenv('REDIS_HOST', 'localhost'),
port=int(os.getenv('REDIS_PORT', 6379)),
db=int(os.getenv('REDIS_DB', 0)),
password=os.getenv('REDIS_PASSWORD', None)
host=os.getenv("REDIS_HOST", "localhost"),
port=int(os.getenv("REDIS_PORT", 6379)),
db=int(os.getenv("REDIS_DB", 0)),
password=os.getenv("REDIS_PASSWORD", None),
)
self.mqtt = MQTTConfig(
broker=os.getenv('MQTT_BROKER', 'localhost'),
port=int(os.getenv('MQTT_PORT', 1883)),
username=os.getenv('MQTT_USERNAME', None),
password=os.getenv('MQTT_PASSWORD', None),
topic_pattern=os.getenv('MQTT_TOPIC_PATTERN', 'devices/#'),
keepalive=int(os.getenv('MQTT_KEEPALIVE', 60))
broker=os.getenv("MQTT_BROKER", "localhost"),
port=int(os.getenv("MQTT_PORT", 1883)),
username=os.getenv("MQTT_USERNAME", None),
password=os.getenv("MQTT_PASSWORD", None),
topic_pattern=os.getenv("MQTT_TOPIC_PATTERN", "devices/#"),
keepalive=int(os.getenv("MQTT_KEEPALIVE", 60)),
)
config = Config()
config = Config()