remove my changes
This commit is contained in:
parent
c9b3acca63
commit
4f1e2a528c
6
.env
6
.env
@ -1,6 +0,0 @@
|
||||
BROKER = ""
|
||||
PORT = 1883
|
||||
SUB_TOPIC = ""
|
||||
PUB_TOPIC = ""
|
||||
USERNAME = ""
|
||||
PASSWORD = ""
|
4
mqtt.py
4
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}`")
|
||||
|
Loading…
x
Reference in New Issue
Block a user