lint fixes

This commit is contained in:
Blake Blackshear 2022-04-16 08:42:44 -05:00
parent 0044f73d7a
commit ec91466fe4
6 changed files with 33 additions and 20 deletions

View File

@ -93,8 +93,8 @@ class FrigateApp:
"i", self.config.cameras[camera_name].detect.enabled "i", self.config.cameras[camera_name].detect.enabled
), ),
"improve_contrast_enabled": mp.Value( "improve_contrast_enabled": mp.Value(
"i", self.config.cameras[camera_name].motion.improve_contrast "i", self.config.cameras[camera_name].motion.improve_contrast
), ),
"detection_fps": mp.Value("d", 0.0), "detection_fps": mp.Value("d", 0.0),
"detection_frame": mp.Value("d", 0.0), "detection_frame": mp.Value("d", 0.0),
"read_start": mp.Value("d", 0.0), "read_start": mp.Value("d", 0.0),

View File

@ -43,9 +43,11 @@ class DetectorConfig(FrigateBaseModel):
device: str = Field(default="usb", title="Device Type") device: str = Field(default="usb", title="Device Type")
num_threads: int = Field(default=3, title="Number of detection threads") num_threads: int = Field(default=3, title="Number of detection threads")
class UIConfig(FrigateBaseModel): class UIConfig(FrigateBaseModel):
use_experimental: bool = Field(default=False, title="Experimental UI") use_experimental: bool = Field(default=False, title="Experimental UI")
class MqttConfig(FrigateBaseModel): class MqttConfig(FrigateBaseModel):
host: str = Field(title="MQTT Host") host: str = Field(title="MQTT Host")
port: int = Field(default=1883, title="MQTT Port") port: int = Field(default=1883, title="MQTT Port")
@ -516,7 +518,9 @@ class CameraLiveConfig(FrigateBaseModel):
class CameraUiConfig(FrigateBaseModel): class CameraUiConfig(FrigateBaseModel):
order: int = Field(default=0, title="Order of camera in UI.") order: int = Field(default=0, title="Order of camera in UI.")
dashboard: bool = Field(default=True, title="Show this camera in Frigate dashboard UI.") dashboard: bool = Field(
default=True, title="Show this camera in Frigate dashboard UI."
)
class CameraConfig(FrigateBaseModel): class CameraConfig(FrigateBaseModel):

View File

@ -14,22 +14,22 @@ from frigate.models import Event
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def should_insert_db(prev_event, current_event): def should_insert_db(prev_event, current_event):
"""If current event has new clip or snapshot.""" """If current event has new clip or snapshot."""
return ( return (not prev_event["has_clip"] and not prev_event["has_snapshot"]) and (
(not prev_event["has_clip"] and not prev_event["has_snapshot"]) current_event["has_clip"] or current_event["has_snapshot"]
and (current_event["has_clip"] or current_event["has_snapshot"])
) )
def should_update_db(prev_event, current_event): def should_update_db(prev_event, current_event):
"""If current_event has updated fields and (clip or snapshot).""" """If current_event has updated fields and (clip or snapshot)."""
return ( return (current_event["has_clip"] or current_event["has_snapshot"]) and (
(current_event["has_clip"] or current_event["has_snapshot"]) prev_event["top_score"] != current_event["top_score"]
and (prev_event["top_score"] != current_event["top_score"] or prev_event["entered_zones"] != current_event["entered_zones"]
or prev_event["entered_zones"] != current_event["entered_zones"] or prev_event["thumbnail"] != current_event["thumbnail"]
or prev_event["thumbnail"] != current_event["thumbnail"] or prev_event["has_clip"] != current_event["has_clip"]
or prev_event["has_clip"] != current_event["has_clip"] or prev_event["has_snapshot"] != current_event["has_snapshot"]
or prev_event["has_snapshot"] != current_event["has_snapshot"])
) )

View File

@ -111,7 +111,7 @@ def create_mqtt_client(config: FrigateConfig, camera_metrics):
logger.warning(f"Received unsupported value at {message.topic}: {payload}") logger.warning(f"Received unsupported value at {message.topic}: {payload}")
state_topic = f"{message.topic[:-4]}/state" state_topic = f"{message.topic[:-4]}/state"
client.publish(state_topic, payload, retain=True) client.publish(state_topic, payload, retain=True)
def on_restart_command(client, userdata, message): def on_restart_command(client, userdata, message):
restart_frigate() restart_frigate()
@ -120,9 +120,13 @@ def create_mqtt_client(config: FrigateConfig, camera_metrics):
threading.current_thread().name = "mqtt" threading.current_thread().name = "mqtt"
if rc != 0: if rc != 0:
if rc == 3: if rc == 3:
logger.error("Unable to connect to MQTT server: MQTT Server unavailable") logger.error(
"Unable to connect to MQTT server: MQTT Server unavailable"
)
elif rc == 4: elif rc == 4:
logger.error("Unable to connect to MQTT server: MQTT Bad username or password") logger.error(
"Unable to connect to MQTT server: MQTT Bad username or password"
)
elif rc == 5: elif rc == 5:
logger.error("Unable to connect to MQTT server: MQTT Not authorized") logger.error("Unable to connect to MQTT server: MQTT Not authorized")
else: else:
@ -153,7 +157,8 @@ def create_mqtt_client(config: FrigateConfig, camera_metrics):
f"{mqtt_config.topic_prefix}/{name}/detect/set", on_detect_command f"{mqtt_config.topic_prefix}/{name}/detect/set", on_detect_command
) )
client.message_callback_add( client.message_callback_add(
f"{mqtt_config.topic_prefix}/{name}/improve_contrast/set", on_improve_contrast_command f"{mqtt_config.topic_prefix}/{name}/improve_contrast/set",
on_improve_contrast_command,
) )
client.message_callback_add( client.message_callback_add(
@ -204,7 +209,7 @@ def create_mqtt_client(config: FrigateConfig, camera_metrics):
f"{mqtt_config.topic_prefix}/{name}/improve_contrast/state", f"{mqtt_config.topic_prefix}/{name}/improve_contrast/state",
"ON" if config.cameras[name].motion.improve_contrast else "OFF", "ON" if config.cameras[name].motion.improve_contrast else "OFF",
retain=True, retain=True,
) )
return client return client

View File

@ -15,7 +15,9 @@ logger = logging.getLogger(__name__)
def get_latest_version() -> str: def get_latest_version() -> str:
request = requests.get('https://api.github.com/repos/blakeblackshear/frigate/releases/latest') request = requests.get(
"https://api.github.com/repos/blakeblackshear/frigate/releases/latest"
)
response = request.json() response = request.json()
if request.ok and response: if request.ok and response:

View File

@ -368,7 +368,9 @@ def track_camera(
objects_to_track = config.objects.track objects_to_track = config.objects.track
object_filters = config.objects.filters object_filters = config.objects.filters
motion_detector = MotionDetector(frame_shape, config.motion, improve_contrast_enabled) motion_detector = MotionDetector(
frame_shape, config.motion, improve_contrast_enabled
)
object_detector = RemoteObjectDetector( object_detector = RemoteObjectDetector(
name, labelmap, detection_queue, result_connection, model_shape name, labelmap, detection_queue, result_connection, model_shape
) )