mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-02-14 00:17:05 +01:00
Add ability to set mqtt qos in config (#16435)
This commit is contained in:
parent
81bd956ae8
commit
bc96db8612
@ -46,6 +46,11 @@ mqtt:
|
||||
tls_insecure: false
|
||||
# Optional: interval in seconds for publishing stats (default: shown below)
|
||||
stats_interval: 60
|
||||
# Optional: QoS level for subscriptions and publishing (default: shown below)
|
||||
# 0 = at most once
|
||||
# 1 = at least once
|
||||
# 2 = exactly once
|
||||
qos: 0
|
||||
|
||||
# Optional: Detectors configuration. Defaults to a single CPU detector
|
||||
detectors:
|
||||
|
@ -31,7 +31,10 @@ class MqttClient(Communicator): # type: ignore[misc]
|
||||
return
|
||||
|
||||
self.client.publish(
|
||||
f"{self.mqtt_config.topic_prefix}/{topic}", payload, retain=retain
|
||||
f"{self.mqtt_config.topic_prefix}/{topic}",
|
||||
payload,
|
||||
qos=self.config.mqtt.qos,
|
||||
retain=retain,
|
||||
)
|
||||
|
||||
def stop(self) -> None:
|
||||
@ -151,7 +154,7 @@ class MqttClient(Communicator): # type: ignore[misc]
|
||||
|
||||
self.connected = True
|
||||
logger.debug("MQTT connected")
|
||||
client.subscribe(f"{self.mqtt_config.topic_prefix}/#")
|
||||
client.subscribe(f"{self.mqtt_config.topic_prefix}/#", qos=self.config.mqtt.qos)
|
||||
self._set_initial_topics()
|
||||
|
||||
def _on_disconnect(
|
||||
|
@ -30,6 +30,7 @@ class MqttConfig(FrigateBaseModel):
|
||||
)
|
||||
tls_client_key: Optional[str] = Field(default=None, title="MQTT TLS Client Key")
|
||||
tls_insecure: Optional[bool] = Field(default=None, title="MQTT TLS Insecure")
|
||||
qos: Optional[int] = Field(default=0, title="MQTT QoS")
|
||||
|
||||
@model_validator(mode="after")
|
||||
def user_requires_pass(self, info: ValidationInfo) -> Self:
|
||||
|
Loading…
Reference in New Issue
Block a user