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 Gateway for Server #364

Merged
merged 4 commits into from
Jun 13, 2023
Merged

MQTT Gateway for Server #364

merged 4 commits into from
Jun 13, 2023

Conversation

mschlenstedt
Copy link
Contributor

Hey,

I really love the idea to include MQTT into the server. I created a seperate gateway script which passes status of devices from the Server to a MQTT Broker and subscribes to a "set" topic and passes the payload back to the set API call of the Server.

The script polls the status of all known devices (in seperate threads, 20 at the same time currently) every x seconds. Polling is not the best solution here of course, I would really love to have a persist socket to each device and get status changes immediately. But I think this needs a complete rewrite of the server. So maybe polling is "better than nothing" here.

Code needs definetly some clean up and documentation is still missing.

@mschlenstedt
Copy link
Contributor Author

MQTT topic structure:

image

@uzlonewolf
Copy link
Collaborator

So, I'm currently in the middle of a server rewrite that does all this and more. It currently makes persistent connections to all devices and does this with a single thread via non-blocking sockets, supports HTTP, WebSockets, plain TCP, and all of the above wrapped in SSL/TLS. It also has hooks for native MQTT but I have not yet had a chance to hook them up yet https://github.com/uzlonewolf/tinytuya/blob/socket-server/multiserver/multiserver.py#L963 . I'm currently out of town and have not had much time to work on it, but should be able to get back to it next week.

@mschlenstedt
Copy link
Contributor Author

Fully agree - best option is to have persist socket connections. Maybe it's a good idea to include the mqtt_gateway into the existing server until your new rewrite is ready for production. If you leave the MQTT structure the same, users can easily upgrade.

@jasonacox jasonacox merged commit db521e7 into jasonacox:master Jun 13, 2023
@jasonacox
Copy link
Owner

Thanks @mschlenstedt ! I agee, this is a good incremental feature for our current server.

I know @uzlonewolf 's multiserver is going to be amazing! Safe travel, LW!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants