diff --git a/.env b/.env deleted file mode 100644 index 9bb55d5..0000000 --- a/.env +++ /dev/null @@ -1,6 +0,0 @@ -BROKER = "" -PORT = 1883 -SUB_TOPIC = "" -PUB_TOPIC = "" -USERNAME = "" -PASSWORD = "" \ No newline at end of file diff --git a/mqtt.py b/mqtt.py index 71b1327..99a8de5 100644 --- a/mqtt.py +++ b/mqtt.py @@ -9,7 +9,7 @@ from lib.shared import run_bulb_action, convert_to_bulb_format load_dotenv() broker = os.getenv("BROKER") -port = os.getenv("PORT") +port = int(os.getenv("PORT")) topic = os.getenv("SUB_TOPIC") # generate client ID with pub prefix randomly client_id = f"python-mqtt-{random.randint(0, 100)}" @@ -32,7 +32,7 @@ def connect_mqtt() -> mqtt_client: def publish(client): - result = client.publish(os.getenv('PUB_TOPIC'), "ON") + result = client.publish(os.getenv("PUB_TOPIC"), "ON") status = result[0] if status == 0: print(f"Send `ON` to topic `{topic}`")