Skip to content

Commit

Permalink
Make ssl module optional
Browse files Browse the repository at this point in the history
  • Loading branch information
devbis committed May 3, 2023
1 parent a8d4d0d commit a6482ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lumimqtt/lumimqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from dataclasses import dataclass
from datetime import datetime

import ssl
import aio_mqtt

from .__version__ import version
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a6482ba

Please sign in to comment.