mjcumming / HomieV3

Homie V3 Implementation in Python
MIT License
5 stars 7 forks source link

Multiple devices to share the same mqtt connection. #4

Closed yozik04 closed 5 years ago

yozik04 commented 5 years ago

Maybe it will be good to make mqtt related stuff static or move it to a separate class?

mjcumming commented 5 years ago

Would the idea be to allow different mqtt clients to be used with device_base? Might allow easy adoption of the library to an ESP...

yozik04 commented 5 years ago

My use case is different. I have a bluetooth temperature sensors across the house. I have a script that listens bluetooth traffic and publishes all sensor data to MQTT via homie. If I have 10 temperature sensors it will make 10 connections to MQTT.

mjcumming commented 5 years ago

The idea behind the Homie concept is that each device should have its own connection so the MQTT LWT message gets sent.

Have a look at the stress test example. My MQTT server is a Raspberry Zero and it handled 500 connections without problem.

yozik04 commented 5 years ago

It was just an idea for improvement =)

mjcumming commented 5 years ago

Understand - but it deviates from protocol. See the discussion here https://github.com/homieiot/convention/issues/158

mjcumming commented 5 years ago

Version 0.3.0 allows using a single MQTT client.


MQTT_SETTINGS = {
    'MQTT_BROKER' : None,
    'MQTT_PORT' : 1883,
    'MQTT_USERNAME' : None,
    'MQTT_PASSWORD' : None,
    'MQTT_KEEPALIVE' : 60,
    'MQTT_CLIENT_ID' : None,
    'MQTT_SHARE_CLIENT' : True,
}
yozik04 commented 5 years ago

Yeey!