Arksine / moonraker

Web API Server for Klipper
https://moonraker.readthedocs.io
GNU General Public License v3.0
1.08k stars 414 forks source link

Allow setting MQTT ClientId in moonraker.conf #883

Open antlu65 opened 4 months ago

antlu65 commented 4 months ago

Is your feature request related to a problem? Please describe

Moonraker instance connects to MQTT broker using empty ClientId. There does not appear to be any option to set the ClientId in Moonraker configuration. MQTT broker is responsible for assigning clientId to Moonraker MQTT client.

Describe the solution you'd like

A configuration option 'clientid' under the [mqtt] section in moonraker.conf. The Moonraker instance will connect to MQTT broker using specified clientId. If not specified, default value may be specified 'instance name' under the same section. If instance name not specified, default clientId may be device host name.

Describe alternatives you've considered

No response

Additional information

No response

antlu65 commented 4 months ago

I have zero experience working in Python, but I imagine it would look something like this:

(mqtt.py) class MQTTClient(APITransport): def init(self, config: ConfigHelper) -> None: ... self.client_id = config.get('client_id', socket.gethostname()) (validation checks here) ...