Skip to content

Commit

Permalink
feat: update data models to allow None for optional fields
Browse files Browse the repository at this point in the history
  • Loading branch information
RaHehl committed Jan 23, 2025
1 parent f4b7830 commit 943c78d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/uiprotect/data/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ class CameraChannel(ProtectBaseObject):
height: int
fps: int
bitrate: int
min_bitrate: int # read only
max_bitrate: int # read only
min_bitrate: int | None = None # read only
max_bitrate: int | None = None # read only
min_client_adaptive_bit_rate: int | None = None # read only
min_motion_adaptive_bit_rate: int | None = None # read only
fps_values: list[int] # read only
Expand Down Expand Up @@ -543,7 +543,7 @@ def unifi_dict(
class TalkbackSettings(ProtectBaseObject):
type_fmt: AudioCodecs
type_in: str
bind_addr: IPv4Address
bind_addr: IPv4Address | None = None
bind_port: int
filter_addr: str | None = None # can be used to restrict sender address
filter_port: int | None = None # can be used to restrict sender port
Expand Down Expand Up @@ -945,7 +945,7 @@ class Camera(ProtectMotionDeviceModel):
feature_flags: CameraFeatureFlags
lcd_message: LCDMessage | None = None
lenses: list[CameraLenses]
platform: str
platform: str | None = None
has_speaker: bool
has_wifi: bool
audio_bitrate: int
Expand Down
2 changes: 2 additions & 0 deletions src/uiprotect/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ def convert_unifi_data(value: Any, field: FieldInfo) -> Any:
# 00000000-0000-00 0- 000-000000000000
if type_ is UUID and value == _BAD_UUID:
return _EMPTY_UUID
if (type_ is IPv4Address) and value == '':
return None
return type_(value)
if _is_enum_type(type_):
if _is_from_string_enum(type_):
Expand Down

0 comments on commit 943c78d

Please sign in to comment.