Home Assistant Unofficial Reference 2024.12.1
models.py
Go to the documentation of this file.
1 """ONVIF models."""
2 
3 from __future__ import annotations
4 
5 from dataclasses import dataclass
6 from enum import Enum
7 from typing import Any
8 
9 from homeassistant.const import EntityCategory
10 
11 
12 @dataclass
13 class DeviceInfo:
14  """Represent device information."""
15 
16  manufacturer: str | None = None
17  model: str | None = None
18  fw_version: str | None = None
19  serial_number: str | None = None
20  mac: str | None = None
21 
22 
23 @dataclass
24 class Resolution:
25  """Represent video resolution."""
26 
27  width: int
28  height: int
29 
30 
31 @dataclass
32 class Video:
33  """Represent video encoding settings."""
34 
35  encoding: str
36  resolution: Resolution
37 
38 
39 @dataclass
40 class PTZ:
41  """Represents PTZ configuration on a profile."""
42 
43  continuous: bool
44  relative: bool
45  absolute: bool
46  presets: list[str] | None = None
47 
48 
49 @dataclass
50 class Profile:
51  """Represent a ONVIF Profile."""
52 
53  index: int
54  token: str
55  name: str
56  video: Video
57  ptz: PTZ | None = None
58  video_source_token: str | None = None
59 
60 
61 @dataclass
63  """Represents Service capabilities."""
64 
65  snapshot: bool = False
66  events: bool = False
67  ptz: bool = False
68  imaging: bool = False
69 
70 
71 @dataclass
72 class Event:
73  """Represents a ONVIF event."""
74 
75  uid: str
76  name: str
77  platform: str
78  device_class: str | None = None
79  unit_of_measurement: str | None = None
80  value: Any = None
81  entity_category: EntityCategory | None = None
82  entity_enabled: bool = True
83 
84 
86  """States for the pullpoint manager."""
87 
88  STOPPED = 0 # Not running or not supported
89  STARTED = 1 # Running and renewing
90  PAUSED = 2 # Switched to webhook, but can resume
91  FAILED = 3 # Failed to do initial subscription
92 
93 
94 class WebHookManagerState(Enum):
95  """States for the webhook manager."""
96 
97  STOPPED = 0
98  STARTED = 1
99  FAILED = 2 # Failed to do initial subscription