summaryrefslogtreecommitdiff
path: root/src/home/mqtt/mqtt.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/home/mqtt/mqtt.py')
-rw-r--r--src/home/mqtt/mqtt.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/home/mqtt/mqtt.py b/src/home/mqtt/mqtt.py
index fad5d26..ba32889 100644
--- a/src/home/mqtt/mqtt.py
+++ b/src/home/mqtt/mqtt.py
@@ -5,6 +5,7 @@ import logging
from ..config import config
from ._payload import *
+from typing import Optional
def username_and_password() -> Tuple[str, str]:
@@ -13,11 +14,13 @@ def username_and_password() -> Tuple[str, str]:
return username, password
-class MqttBase:
+class Mqtt:
_connected: bool
- def __init__(self, clean_session=True):
- self._client = mqtt.Client(client_id=config['mqtt']['client_id'],
+ def __init__(self,
+ clean_session=True,
+ client_id: Optional[str] = None):
+ self._client = mqtt.Client(client_id=config['mqtt']['client_id'] if not client_id else client_id,
protocol=mqtt.MQTTv311,
clean_session=clean_session)
self._client.on_connect = self.on_connect
@@ -81,14 +84,3 @@ class MqttBase:
def on_publish(self, client: mqtt.Client, userdata, mid):
self._logger.debug(f'publish done, mid={mid}')
-
-
-class MqttEspDevice:
- id: str
- secret: Optional[str]
-
- def __init__(self,
- node_id: str,
- secret: Optional[str] = None):
- self.id = node_id
- self.secret = secret