Skip to content

Commit

Permalink
fix: runtime data types - relate_detector
Browse files Browse the repository at this point in the history
  • Loading branch information
petrleocompel committed May 12, 2023
1 parent 25c69d9 commit c4a6ce1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions custom_components/hikvision_axpro/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,12 +612,12 @@ class ZoneConfig:
chime_warning_type: ChimeWarningType
timeout_type: TimeoutType
timeout: int
relate_detector: bool
related_chan_list: List[RelatedChanList]
double_knock_enabled: bool
double_knock_time: int
new_key_zone_trigger_type_cfg: NewKeyZoneTriggerTypeCFG
zone_status_cfg: ZoneStatusCFG
relate_detector: Optional[bool] = None
sub_system_no: Optional[int] = None
linkage_sub_system: Optional[List[int]] = None
support_linkage_sub_system_list: Optional[List[int]] = None
Expand Down Expand Up @@ -662,7 +662,7 @@ def from_dict(obj: Any) -> 'ZoneConfig':
chime_warning_type = ChimeWarningType(obj.get("chimeWarningType"))
timeout_type = TimeoutType(obj.get("timeoutType"))
timeout = from_int(obj.get("timeout"))
relate_detector = from_bool(obj.get("relateDetector"))
relate_detector = from_union([from_bool, from_none], obj.get("relateDetector"))
related_chan_list = from_list(RelatedChanList.from_dict, obj.get("RelatedChanList"))
double_knock_enabled = from_bool(obj.get("doubleKnockEnabled"))
double_knock_time = from_int(obj.get("doubleKnockTime"))
Expand Down Expand Up @@ -700,8 +700,8 @@ def from_dict(obj: Any) -> 'ZoneConfig':
timeout_limit = from_union([from_bool, from_none], obj.get("timeoutLimit"))
check_time = from_union([from_int, from_none], obj.get("checkTime"))
return ZoneConfig(id, zone_name, detector_type, zone_type, stay_away_enabled, chime_enabled, silent_enabled,
chime_warning_type, timeout_type, timeout, relate_detector, related_chan_list, double_knock_enabled,
double_knock_time, new_key_zone_trigger_type_cfg, zone_status_cfg, sub_system_no,
chime_warning_type, timeout_type, timeout, related_chan_list, double_knock_enabled,
double_knock_time, new_key_zone_trigger_type_cfg, zone_status_cfg, relate_detector, sub_system_no,
linkage_sub_system, support_linkage_sub_system_list, enter_delay, exit_delay, stay_arm_delay_time,
siren_delay_time, detector_seq, cross_zone_cfg, arm_no_bypass_enabled, related_pircam, arm_mode,
zone_attrib, final_door_exit_enabled, time_restart_enabled, swinger_limit_activation,
Expand All @@ -721,7 +721,8 @@ def to_dict(self) -> dict:
result["chimeWarningType"] = to_enum(ChimeWarningType, self.chime_warning_type)
result["timeoutType"] = to_enum(TimeoutType, self.timeout_type)
result["timeout"] = from_int(self.timeout)
result["relateDetector"] = from_bool(self.relate_detector)
if self.relate_detector is not None:
result["relateDetector"] = from_bool(self.relate_detector)
result["RelatedChanList"] = from_list(lambda x: to_class(RelatedChanList, x), self.related_chan_list)
result["doubleKnockEnabled"] = from_bool(self.double_knock_enabled)
result["doubleKnockTime"] = from_int(self.double_knock_time)
Expand Down

0 comments on commit c4a6ce1

Please sign in to comment.