forked from echauvet/freebox_home
-
Notifications
You must be signed in to change notification settings - Fork 0
/
const.py
182 lines (158 loc) · 5.03 KB
/
const.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
"""Freebox component constants."""
from __future__ import annotations
import socket
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntityDescription,
)
from homeassistant.components.cover import CoverDeviceClass, CoverEntityDescription
from homeassistant.components.camera import CameraEntityDescription
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.const import DATA_RATE_KILOBYTES_PER_SECOND, PERCENTAGE, Platform
from homeassistant.helpers.entity import EntityCategory
DOMAIN = "freebox_home"
SERVICE_REBOOT = "reboot"
APP_DESC = {
"app_id": "hass",
"app_name": "Home Assistant",
"app_version": "0.109",
"device_name": socket.gethostname(),
}
API_VERSION = "v6"
PLATFORMS = [
Platform.DEVICE_TRACKER,
Platform.SENSOR,
Platform.BUTTON,
Platform.BINARY_SENSOR,
Platform.SWITCH,
Platform.COVER,
Platform.CAMERA,
]
DEFAULT_DEVICE_NAME = "Unknown device"
# to store the cookie
STORAGE_KEY = DOMAIN
STORAGE_VERSION = 1
# Sensors
CONNECTION_SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="rate_down",
name="Freebox download speed",
native_unit_of_measurement=DATA_RATE_KILOBYTES_PER_SECOND,
icon="mdi:download-network",
),
SensorEntityDescription(
key="rate_up",
name="Freebox upload speed",
native_unit_of_measurement=DATA_RATE_KILOBYTES_PER_SECOND,
icon="mdi:upload-network",
),
)
CONNECTION_SENSORS_KEYS: list[str] = [desc.key for desc in CONNECTION_SENSORS]
CALL_SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="missed",
name="Freebox missed calls",
icon="mdi:phone-missed",
),
)
DISK_PARTITION_SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="partition_free_space",
name="Free space",
native_unit_of_measurement=PERCENTAGE,
icon="mdi:harddisk",
),
)
HOME_NODE_BATTERY_SENSOR: SensorEntityDescription = SensorEntityDescription(
key="battery",
name="Battery",
entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.BATTERY,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=PERCENTAGE,
)
HOME_NODE_REMOTE_BUTTON_SENSOR: SensorEntityDescription = SensorEntityDescription(
key="pushed",
name="Last action",
)
HOME_NODES_SENSORS: dict[str, SensorEntityDescription] = {
"battery": HOME_NODE_BATTERY_SENSOR,
"pushed": HOME_NODE_REMOTE_BUTTON_SENSOR,
}
# Binary Sensors
HOME_NODE_COVER_BINARY_SENSOR: BinarySensorEntityDescription = (
BinarySensorEntityDescription(
key="cover",
name="Cover",
entity_category=EntityCategory.DIAGNOSTIC,
device_class=BinarySensorDeviceClass.OPENING,
)
)
HOME_NODE_MOTION_BINARY_SENSOR: BinarySensorEntityDescription = (
BinarySensorEntityDescription(
key="motion",
name="Motion",
device_class=BinarySensorDeviceClass.MOTION,
)
)
HOME_NODE_OPENING_BINARY_SENSOR: BinarySensorEntityDescription = (
BinarySensorEntityDescription(
key="opening",
name="Status",
device_class=BinarySensorDeviceClass.OPENING,
)
)
HOME_NODES_BINARY_SENSORS: dict[str, BinarySensorEntityDescription] = {
"cover": HOME_NODE_COVER_BINARY_SENSOR,
"opening": HOME_NODE_OPENING_BINARY_SENSOR,
"motion": HOME_NODE_MOTION_BINARY_SENSOR,
}
# Cover
HOME_NODE_SHUTTER_COVER: CoverEntityDescription = CoverEntityDescription(
key="shutter",
name="Shutter",
device_class=CoverDeviceClass.SHUTTER,
)
# Basic Cover
HOME_NODE_BASIC_SHUTTER_COVER: CoverEntityDescription = CoverEntityDescription(
key="basic_shutter", name="basic_shutter", device_class=CoverDeviceClass.SHUTTER
)
HOME_NODES_COVERS: dict[str, CoverEntityDescription] = {
"shutter": HOME_NODE_SHUTTER_COVER,
"basic_shutter": HOME_NODE_BASIC_SHUTTER_COVER,
}
# Camera
HOME_NODE_CAMERA: CameraEntityDescription = CameraEntityDescription(
key="camera", name="camera"
)
# Alarm
HOME_NODES_ALARM_REMOTE_KEY: list[str] = [
"Alarm 1 ON",
"Alarm OFF",
"Alarm 2 ON",
"Not used",
]
# Icons
DEVICE_ICONS = {
"freebox_delta": "mdi:television-guide",
"freebox_hd": "mdi:television-guide",
"freebox_mini": "mdi:television-guide",
"freebox_player": "mdi:television-guide",
"ip_camera": "mdi:cctv",
"ip_phone": "mdi:phone-voip",
"laptop": "mdi:laptop",
"multimedia_device": "mdi:play-network",
"nas": "mdi:nas",
"networking_device": "mdi:network",
"printer": "mdi:printer",
"router": "mdi:router-wireless",
"smartphone": "mdi:cellphone",
"tablet": "mdi:tablet",
"television": "mdi:television",
"vg_console": "mdi:gamepad-variant",
"workstation": "mdi:desktop-tower-monitor",
}