MQTT loop Bug fix
This commit is contained in:
parent
f4bc335cb6
commit
ba50b47611
1 changed files with 5 additions and 3 deletions
|
|
@ -12,6 +12,7 @@ from adafruit_funhouse import FunHouse
|
|||
OUTLET_STATE_TOPIC = "funhouse/outlet/state"
|
||||
OUTLET_COMMAND_TOPIC = "funhouse/outlet/set"
|
||||
MOTION_TIMEOUT = 300 # Timeout in seconds
|
||||
USE_MQTT = True
|
||||
|
||||
try:
|
||||
from secrets import secrets
|
||||
|
|
@ -32,7 +33,7 @@ def set_outlet_state(value):
|
|||
publish_outlet_state()
|
||||
|
||||
def publish_outlet_state():
|
||||
if OUTLET_STATE_TOPIC and OUTLET_COMMAND_TOPIC:
|
||||
if USE_MQTT:
|
||||
funhouse.peripherals.led = True
|
||||
output = "on" if outlet.value else "off"
|
||||
# Publish the Dotstar State
|
||||
|
|
@ -88,7 +89,7 @@ status = Circle(229, 10, 10, fill=0xFF0000, outline=0x880000)
|
|||
funhouse.splash.append(status)
|
||||
|
||||
# Initialize a new MQTT Client object
|
||||
if OUTLET_STATE_TOPIC and OUTLET_COMMAND_TOPIC:
|
||||
if USE_MQTT:
|
||||
funhouse.network.init_mqtt(
|
||||
secrets["mqtt_broker"],
|
||||
secrets["mqtt_port"],
|
||||
|
|
@ -112,4 +113,5 @@ while True:
|
|||
set_outlet_state(False)
|
||||
funhouse.set_text(timeleft(), countdown_label)
|
||||
# Check any topics we are subscribed to
|
||||
funhouse.network.mqtt_loop(0.5)
|
||||
if USE_MQTT:
|
||||
funhouse.network.mqtt_loop(0.5)
|
||||
|
|
|
|||
Loading…
Reference in a new issue