Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT configuration is now in a dict for easier management #1609

Merged
merged 3 commits into from
Mar 1, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/develop' into patch-5
  • Loading branch information
andreasbrett committed Feb 27, 2022
commit eacb80c8e14ec5e122c0ba702ee45a44567561a6
Original file line number Diff line number Diff line change
Expand Up @@ -93,29 +93,6 @@ def watchForNewCard():
processGet("all")


def watchForNewCard():
i = inotify.adapters.Inotify()
i.add_watch(path + "/../settings/Latest_RFID")

# wait for inotify events
for event in i.event_gen(yield_nones=False):
if event is not None:
# fetch event attributes
(e_header, e_type_names, e_path, e_filename) = event

# file was closed and written => a new card was swiped
if "IN_CLOSE_WRITE" in e_type_names:
# fetch card ID
cardid = readfile(path + "/../settings/Latest_RFID")

# publish event "card_swiped"
client.publish(config.get("mqttBaseTopic") + "/event/card_swiped", payload=cardid)
print(" --> Publishing event card_swiped = " + cardid)

# process all attributes
processGet("all")


def on_connect(client, userdata, flags, rc):
if rc == 0:
print("Connection established.")
Expand Down Expand Up @@ -465,6 +442,11 @@ def fetchData():
tWatchForNewCard.setDaemon(True)
tWatchForNewCard.start()

# register thread for watchForNewCard
tWatchForNewCard = Thread(target=watchForNewCard)
tWatchForNewCard.setDaemon(True)
tWatchForNewCard.start()

# start endless loop
client.loop_start()
while True:
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.