diff --git a/README.md b/README.md index 6106c09..cddccea 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,13 @@ changes `light_transition_period` value in seconds to set default transition for light switching or light change. Use `0` to remove the transition. + +### SSL connection + +To use SSL connection, you need to set `mqtt_cert` and `mqtt_key`, and optional `mqtt_ca` with corresponding paths to files. + +### Custom sensors + You can also use GPIO(s) as binary sensor(s). Add this to configuration: ```json diff --git a/lumimqtt/lumimqtt.py b/lumimqtt/lumimqtt.py index b42f485..d7ce81b 100644 --- a/lumimqtt/lumimqtt.py +++ b/lumimqtt/lumimqtt.py @@ -9,7 +9,6 @@ from dataclasses import dataclass from datetime import datetime -import ssl import aio_mqtt from .__version__ import version @@ -474,6 +473,8 @@ async def _connect_forever(self) -> None: client_id = f'lumimqtt_{self.dev_id}' context = None if self._mqtt_cert is not None and self._mqtt_key is not None: + import ssl + context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) if self._mqtt_ca is not None: context.load_verify_locations(self._mqtt_ca)