Skip to content

Are there any examples of people using Tinytuya for a full-fledged smart home GUI? #546

Closed Answered by RYoder97
RYoder97 asked this question in Q&A
Discussion options

You must be logged in to vote

OK. After doing some research, I found that for loops are faster than infinite while loops in Python.

So I updated the device status thread like so:

def getDeviceStatuses():
    global devices
    global statuses
    
    x = 0
    for device in devices:
        statuses[x] = {"id":device.id, "status":device.status()}
        x += 1
    
    getDeviceStatuses()

And instead of creating a tmp list and populating it at the end of the loop, we update the global statuses during each iteration, using x as an index to tell us which device we are updating. Meanwhile, the websocket continues to constantly push updates to the client side, but now instead of waiting for a while loop to populate a ne…

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
1 reply
@RYoder97
Comment options

Comment options

You must be logged in to vote
9 replies
@uzlonewolf
Comment options

@jasonacox
Comment options

@jasonacox
Comment options

@uzlonewolf
Comment options

@jasonacox
Comment options

Answer selected by RYoder97
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants