Packaging tools for own use
Project description
hwhpykit
Main function
- Connection
- mqtt
Connection
Mqtt
from hwhpykit import MQTTAsyncClient, mqtt_subscribe
import asyncio
# Config MQTT Client
client = MQTTAsyncClient(broker="broker.hivemq.com", port=1883, client_id="my_client")
client.start()
@mqtt_subscribe("topic/test1")
async def handle_message_1(message: str):
print(f"Received message from topic 1: {message}")
@mqtt_subscribe("topic/test2")
async def handle_message_2(message: str):
print(f"Received message from topic 2: {message}")
async def send_messages():
while True:
await asyncio.sleep(2)
client.publish("topic/test1", "Hello from topic 1!")
client.publish("topic/test2", "Hello from topic 2!")
async def main():
await asyncio.gather(
send_messages(),
asyncio.sleep(3600)
)
if __name__ == '__main__':
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hwhpykit-1.1.8.tar.gz
(3.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hwhpykit-1.1.8.tar.gz.
File metadata
- Download URL: hwhpykit-1.1.8.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b756a35831d68212d06399101ce848864d0de6fc6be6fb6ea48315247714f6a
|
|
| MD5 |
1d93109a427ae1c0a323a41b54d2c11b
|
|
| BLAKE2b-256 |
2b47321f996a09360a473fb989a8ea6e97e76b5cfbc2175fd6b873a42f8a65f9
|
File details
Details for the file hwhpykit-1.1.8-py3-none-any.whl.
File metadata
- Download URL: hwhpykit-1.1.8-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb13256f42840b923c69cc1bdcc5cb07cd7d2f4eeed4ba11dca6b882b35cf90a
|
|
| MD5 |
3f3b88a24af9ab2ab75a109d8049d99f
|
|
| BLAKE2b-256 |
55872b6a3da800c00283ced1a5d627debf3b4614e35247f442f51b09d3b25af6
|