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

Add simple support for iterator-based event subscription #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
12 changes: 11 additions & 1 deletion traeger.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import uuid
import urllib
import json

import queue

CLIENT_ID = "2fuohjtqv1e63dckp5v84rau0j"

Expand Down Expand Up @@ -112,3 +112,13 @@ def get_grill_status(self, timeout = 10):
time.sleep(1)
remaining -= 1
return self.grill_status

def grill_status_subscription(self):
sub_queue = queue.Queue()
def handle_message(client, userdata, message):
sub_queue.put(json.loads(message.payload))
client = self.get_mqtt_client(self.grill_connect, handle_message)
for grill in self.grills:
client.subscribe(("prod/thing/update/{}".format(grill["thingName"]),1))
while True:
yield sub_queue.get()