mirror of
https://github.com/ferdzo/iotDashboard.git
synced 2026-04-05 17:16:26 +00:00
Functioning mqtt ingestion and db write, formating changes, device manager initiated
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user