添加regionName, typeName
This commit is contained in:
@ -12,7 +12,7 @@ async def read_event():
|
||||
# 读取配置文件
|
||||
home_dir = Path.home()
|
||||
with open(
|
||||
home_dir / ".config" / "hik-push" / "config.yaml", "r", encoding="utf-8"
|
||||
home_dir / ".config" / "hik-push" / "config.yaml", "r", encoding="utf-8"
|
||||
) as f:
|
||||
config = yaml.safe_load(f)
|
||||
if "user_ids" not in config:
|
||||
@ -63,6 +63,12 @@ async def read_event():
|
||||
src_index = event_detail["srcIndex"]
|
||||
device_name = device_map.get(src_index, "未知设备")
|
||||
event_detail["deviceName"] = device_name
|
||||
# 添加regionName和typeName
|
||||
event_detail["typeName"] = event_type_str
|
||||
if "srcName" in event_detail:
|
||||
event_detail["regionName"] = event_detail["srcName"]
|
||||
else:
|
||||
event_detail["regionName"] = device_name
|
||||
# 根据设备名称获取 user_ids
|
||||
user_ids = []
|
||||
# 高级
|
||||
@ -91,7 +97,7 @@ async def read_event():
|
||||
event_detail["data"].pop(detection_field_name)
|
||||
)
|
||||
if isinstance(
|
||||
event_detail["data"]["_detectionResult"], list
|
||||
event_detail["data"]["_detectionResult"], list
|
||||
) and len(event_detail["data"]["_detectionResult"]):
|
||||
event_detail["data"]["_detectionResult"] = (
|
||||
event_detail["data"]["_detectionResult"][0]
|
||||
@ -115,9 +121,16 @@ async def read_event():
|
||||
logging.info(event_type)
|
||||
event_type_str = event_map.get(event_type, "未知事件类型")
|
||||
event["eventType"] = event_type_str
|
||||
|
||||
# 添加设备名称
|
||||
src_index = event["srcIndex"]
|
||||
device_name = device_map.get(src_index, "未知设备")
|
||||
# 添加regionName和typeName
|
||||
event["typeName"] = event_type_str
|
||||
if "srcName" in event:
|
||||
event["regionName"] = event["srcName"]
|
||||
else:
|
||||
event["regionName"] = device_name
|
||||
# 默认事件等级为2
|
||||
if "eventLvl" not in event:
|
||||
event["eventLvl"] = 2
|
||||
@ -147,7 +160,7 @@ async def read_event():
|
||||
detection_field_name
|
||||
)
|
||||
if isinstance(
|
||||
event["data"]["_detectionResult"], list
|
||||
event["data"]["_detectionResult"], list
|
||||
) and len(event["data"]["_detectionResult"]):
|
||||
event["data"]["_detectionResult"] = event["data"][
|
||||
"_detectionResult"
|
||||
|
Reference in New Issue
Block a user