mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-02-18 00:16:41 +01:00
More bug fixes (#14593)
* Adjust mqtt logging behavior * Set disconnect * Only consider intel gpu stats error if None is returned
This commit is contained in:
parent
4c75440af4
commit
eca504cb07
@ -18,7 +18,6 @@ class MqttClient(Communicator): # type: ignore[misc]
|
|||||||
self.config = config
|
self.config = config
|
||||||
self.mqtt_config = config.mqtt
|
self.mqtt_config = config.mqtt
|
||||||
self.connected = False
|
self.connected = False
|
||||||
self.started = False
|
|
||||||
|
|
||||||
def subscribe(self, receiver: Callable) -> None:
|
def subscribe(self, receiver: Callable) -> None:
|
||||||
"""Wrapper for allowing dispatcher to subscribe."""
|
"""Wrapper for allowing dispatcher to subscribe."""
|
||||||
@ -28,8 +27,7 @@ class MqttClient(Communicator): # type: ignore[misc]
|
|||||||
def publish(self, topic: str, payload: Any, retain: bool = False) -> None:
|
def publish(self, topic: str, payload: Any, retain: bool = False) -> None:
|
||||||
"""Wrapper for publishing when client is in valid state."""
|
"""Wrapper for publishing when client is in valid state."""
|
||||||
if not self.connected:
|
if not self.connected:
|
||||||
if self.started:
|
logger.debug(f"Unable to publish to {topic}: client is not connected")
|
||||||
logger.error(f"Unable to publish to {topic}: client is not connected")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
self.client.publish(
|
self.client.publish(
|
||||||
@ -175,6 +173,7 @@ class MqttClient(Communicator): # type: ignore[misc]
|
|||||||
client_id=self.mqtt_config.client_id,
|
client_id=self.mqtt_config.client_id,
|
||||||
)
|
)
|
||||||
self.client.on_connect = self._on_connect
|
self.client.on_connect = self._on_connect
|
||||||
|
self.client.on_disconnect = self._on_disconnect
|
||||||
self.client.will_set(
|
self.client.will_set(
|
||||||
self.mqtt_config.topic_prefix + "/available",
|
self.mqtt_config.topic_prefix + "/available",
|
||||||
payload="offline",
|
payload="offline",
|
||||||
@ -247,7 +246,6 @@ class MqttClient(Communicator): # type: ignore[misc]
|
|||||||
# with connect_async, retries are handled automatically
|
# with connect_async, retries are handled automatically
|
||||||
self.client.connect_async(self.mqtt_config.host, self.mqtt_config.port, 60)
|
self.client.connect_async(self.mqtt_config.host, self.mqtt_config.port, 60)
|
||||||
self.client.loop_start()
|
self.client.loop_start()
|
||||||
self.started = True
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Unable to connect to MQTT server: {e}")
|
logger.error(f"Unable to connect to MQTT server: {e}")
|
||||||
return
|
return
|
||||||
|
@ -197,8 +197,8 @@ async def set_gpu_stats(
|
|||||||
# intel QSV GPU
|
# intel QSV GPU
|
||||||
intel_usage = get_intel_gpu_stats()
|
intel_usage = get_intel_gpu_stats()
|
||||||
|
|
||||||
if intel_usage:
|
if intel_usage is not None:
|
||||||
stats["intel-qsv"] = intel_usage
|
stats["intel-qsv"] = intel_usage or {"gpu": "", "mem": ""}
|
||||||
else:
|
else:
|
||||||
stats["intel-qsv"] = {"gpu": "", "mem": ""}
|
stats["intel-qsv"] = {"gpu": "", "mem": ""}
|
||||||
hwaccel_errors.append(args)
|
hwaccel_errors.append(args)
|
||||||
@ -222,8 +222,8 @@ async def set_gpu_stats(
|
|||||||
# intel VAAPI GPU
|
# intel VAAPI GPU
|
||||||
intel_usage = get_intel_gpu_stats()
|
intel_usage = get_intel_gpu_stats()
|
||||||
|
|
||||||
if intel_usage:
|
if intel_usage is not None:
|
||||||
stats["intel-vaapi"] = intel_usage
|
stats["intel-vaapi"] = intel_usage or {"gpu": "", "mem": ""}
|
||||||
else:
|
else:
|
||||||
stats["intel-vaapi"] = {"gpu": "", "mem": ""}
|
stats["intel-vaapi"] = {"gpu": "", "mem": ""}
|
||||||
hwaccel_errors.append(args)
|
hwaccel_errors.append(args)
|
||||||
|
Loading…
Reference in New Issue
Block a user