michaelarnauts / cec-mqtt-bridge

A HDMI-CEC to MQTT bridge for connecting HDMI-CEC-devices to your Home Automation system.
145 stars 48 forks source link

MQTT client id #19

Closed glassbase closed 5 years ago

glassbase commented 5 years ago

There should be a config option or append a random # on end of MQTT client ID for those of us that want to run this on multiple devices and push to same MQTT server.

As noted here

Each client must have a unique client id, the broker will kick off the oldest client when a new one connects with the same client id. Other than that you can run as many clients as you want connecting from anywhere that can reach the broker

MQTT logs:

1547942724: New client connected from 10.0.0.216 as cec-ir-mqtt (c1, k60).
1547942725: New connection from 10.0.0.128 on port 1883.
1547942725: Client cec-ir-mqtt already connected, closing old connection.
1547942725: Socket error on client cec-ir-mqtt, disconnecting.
1547942725: New client connected from 10.0.0.128 as cec-ir-mqtt (c1, k60).
1547942726: New connection from 10.0.0.216 on port 1883.
1547942726: Client cec-ir-mqtt already connected, closing old connection.
1547942726: Socket error on client cec-ir-mqtt, disconnecting.
1547942726: New client connected from 10.0.0.216 as cec-ir-mqtt (c1, k60).
1547942727: New connection from 10.0.0.128 on port 1883.
1547942727: Client cec-ir-mqtt already connected, closing old connection.
1547942727: Socket error on client cec-ir-mqtt, disconnecting.
1547942727: New client connected from 10.0.0.128 as cec-ir-mqtt (c1, k60).

(repeating)

michaelarnauts commented 5 years ago

Good point. I'm currently hardcoding the name as cec-ir-mqtt here: https://github.com/michaelarnauts/cec-mqtt-bridge/blob/master/bridge.py#L350

You would need to add it to the config definition and provide a default here: https://github.com/michaelarnauts/cec-mqtt-bridge/blob/master/bridge.py#L14

I don't have a lot of free time atm, so feel free to make a merge request for that.