Skip to content

Commit ba50b47

Browse files
committed
MQTT loop Bug fix
1 parent f4bc335 commit ba50b47

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

FunHouse_Motion_Outlet/code.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
OUTLET_STATE_TOPIC = "funhouse/outlet/state"
1313
OUTLET_COMMAND_TOPIC = "funhouse/outlet/set"
1414
MOTION_TIMEOUT = 300 # Timeout in seconds
15+
USE_MQTT = True
1516

1617
try:
1718
from secrets import secrets
@@ -32,7 +33,7 @@ def set_outlet_state(value):
3233
publish_outlet_state()
3334

3435
def publish_outlet_state():
35-
if OUTLET_STATE_TOPIC and OUTLET_COMMAND_TOPIC:
36+
if USE_MQTT:
3637
funhouse.peripherals.led = True
3738
output = "on" if outlet.value else "off"
3839
# Publish the Dotstar State
@@ -88,7 +89,7 @@ def timeleft():
8889
funhouse.splash.append(status)
8990

9091
# Initialize a new MQTT Client object
91-
if OUTLET_STATE_TOPIC and OUTLET_COMMAND_TOPIC:
92+
if USE_MQTT:
9293
funhouse.network.init_mqtt(
9394
secrets["mqtt_broker"],
9495
secrets["mqtt_port"],
@@ -112,4 +113,5 @@ def timeleft():
112113
set_outlet_state(False)
113114
funhouse.set_text(timeleft(), countdown_label)
114115
# Check any topics we are subscribed to
115-
funhouse.network.mqtt_loop(0.5)
116+
if USE_MQTT:
117+
funhouse.network.mqtt_loop(0.5)

0 commit comments

Comments
 (0)