-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomekit-data.js
More file actions
151 lines (146 loc) · 8.05 KB
/
homekit-data.js
File metadata and controls
151 lines (146 loc) · 8.05 KB
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
const homeKitData = {
"Service": {
"0000003E-0000-1000-8000-0026BB765291": "Accessory Information",
"0000008D-0000-1000-8000-0026BB765291": "Air Quality Sensor",
"00000096-0000-1000-8000-0026BB765291": "Battery Service",
"00000062-0000-1000-8000-0026BB765291": "Bridging State",
"00000097-0000-1000-8000-0026BB765291": "Carbon Dioxide Sensor",
"0000007F-0000-1000-8000-0026BB765291": "Carbon Monoxide Sensor",
"00000080-0000-1000-8000-0026BB765291": "Contact Sensor",
"00000081-0000-1000-8000-0026BB765291": "Door",
"00000040-0000-1000-8000-0026BB765291": "Fan",
"00000041-0000-1000-8000-0026BB765291": "Garage Door Opener",
"00000082-0000-1000-8000-0026BB765291": "Humidity Sensor",
"00000083-0000-1000-8000-0026BB765291": "Leak Sensor",
"00000084-0000-1000-8000-0026BB765291": "Light Sensor",
"00000043-0000-1000-8000-0026BB765291": "Lightbulb",
"00000044-0000-1000-8000-0026BB765291": "Lock Management",
"00000045-0000-1000-8000-0026BB765291": "Lock Mechanism",
"00000085-0000-1000-8000-0026BB765291": "Motion Sensor",
"00000086-0000-1000-8000-0026BB765291": "Occupancy Sensor",
"00000047-0000-1000-8000-0026BB765291": "Outlet",
"0000007E-0000-1000-8000-0026BB765291": "Security System",
"00000087-0000-1000-8000-0026BB765291": "Smoke Sensor",
"00000088-0000-1000-8000-0026BB765291": "Stateful Programmable Switch",
"00000089-0000-1000-8000-0026BB765291": "Stateless Programmable Switch",
"00000049-0000-1000-8000-0026BB765291": "Switch",
"0000008A-0000-1000-8000-0026BB765291": "Temperature Sensor",
"0000004A-0000-1000-8000-0026BB765291": "Thermostat",
"0000008B-0000-1000-8000-0026BB765291": "Window",
"0000008C-0000-1000-8000-0026BB765291": "Window Covering"
},
"Characteristic": {
"00000001-0000-1000-8000-0026BB765291": "Administrator Only Access",
"00000064-0000-1000-8000-0026BB765291": "Air Particulate Density",
"00000065-0000-1000-8000-0026BB765291": "Air Particulate Size",
"00000095-0000-1000-8000-0026BB765291": "Air Quality",
"00000005-0000-1000-8000-0026BB765291": "Audio Feedback",
"00000068-0000-1000-8000-0026BB765291": "Battery Level",
"00000008-0000-1000-8000-0026BB765291": "Brightness",
"00000092-0000-1000-8000-0026BB765291": "Carbon Dioxide Detected",
"00000093-0000-1000-8000-0026BB765291": "Carbon Dioxide Level",
"00000094-0000-1000-8000-0026BB765291": "Carbon Dioxide Peak Level",
"00000069-0000-1000-8000-0026BB765291": "Carbon Monoxide Detected",
"00000090-0000-1000-8000-0026BB765291": "Carbon Monoxide Level",
"00000091-0000-1000-8000-0026BB765291": "Carbon Monoxide Peak Level",
"0000008F-0000-1000-8000-0026BB765291": "Charging State",
"0000006A-0000-1000-8000-0026BB765291": "Contact Sensor State",
"0000000D-0000-1000-8000-0026BB765291": "Cooling Threshold Temperature",
"0000006B-0000-1000-8000-0026BB765291": "Current Ambient Light Level",
"0000000E-0000-1000-8000-0026BB765291": "Current Door State",
"0000000F-0000-1000-8000-0026BB765291": "Current Heating Cooling State",
"0000006C-0000-1000-8000-0026BB765291": "Current Horizontal Tilt Angle",
"0000006D-0000-1000-8000-0026BB765291": "Current Position",
"00000010-0000-1000-8000-0026BB765291": "Current Relative Humidity",
"00000011-0000-1000-8000-0026BB765291": "Current Temperature",
"0000006E-0000-1000-8000-0026BB765291": "Current Vertical Tilt Angle",
"00000052-0000-1000-8000-0026BB765291": "Firmware Revision",
"00000053-0000-1000-8000-0026BB765291": "Hardware Revision",
"00000012-0000-1000-8000-0026BB765291": "Heating Threshold Temperature",
"0000006F-0000-1000-8000-0026BB765291": "Hold Position",
"00000013-0000-1000-8000-0026BB765291": "Hue",
"00000014-0000-1000-8000-0026BB765291": "Identify",
"00000070-0000-1000-8000-0026BB765291": "Leak Detected",
"00000019-0000-1000-8000-0026BB765291": "Lock Control Point",
"0000001D-0000-1000-8000-0026BB765291": "Lock Current State",
"0000001C-0000-1000-8000-0026BB765291": "Lock Last Known Action",
"0000001A-0000-1000-8000-0026BB765291": "Lock Management Auto Security Timeout",
"0000001E-0000-1000-8000-0026BB765291": "Lock Target State",
"0000001F-0000-1000-8000-0026BB765291": "Logs",
"00000020-0000-1000-8000-0026BB765291": "Manufacturer",
"00000021-0000-1000-8000-0026BB765291": "Model",
"00000022-0000-1000-8000-0026BB765291": "Motion Detected",
"00000023-0000-1000-8000-0026BB765291": "Name",
"00000024-0000-1000-8000-0026BB765291": "Obstruction Detected",
"00000071-0000-1000-8000-0026BB765291": "Occupancy Detected",
"00000025-0000-1000-8000-0026BB765291": "On",
"00000026-0000-1000-8000-0026BB765291": "Outlet In Use",
"00000072-0000-1000-8000-0026BB765291": "Position State",
"00000073-0000-1000-8000-0026BB765291": "Programmable Switch Event",
"00000074-0000-1000-8000-0026BB765291": "Programmable Switch Output State",
"00000063-0000-1000-8000-0026BB765291": "Reachable",
"00000028-0000-1000-8000-0026BB765291": "Rotation Direction",
"00000029-0000-1000-8000-0026BB765291": "Rotation Speed",
"0000002F-0000-1000-8000-0026BB765291": "Saturation",
"0000008E-0000-1000-8000-0026BB765291": "Security System Alarm Type",
"00000066-0000-1000-8000-0026BB765291": "Security System Current State",
"00000067-0000-1000-8000-0026BB765291": "Security System Target State",
"00000030-0000-1000-8000-0026BB765291": "Serial Number",
"00000076-0000-1000-8000-0026BB765291": "Smoke Detected",
"00000054-0000-1000-8000-0026BB765291": "Software Revision",
"00000075-0000-1000-8000-0026BB765291": "Status Active",
"00000077-0000-1000-8000-0026BB765291": "Status Fault",
"00000078-0000-1000-8000-0026BB765291": "Status Jammed",
"00000079-0000-1000-8000-0026BB765291": "Status Low Battery",
"0000007A-0000-1000-8000-0026BB765291": "Status Tampered",
"00000032-0000-1000-8000-0026BB765291": "Target Door State",
"00000033-0000-1000-8000-0026BB765291": "Target Heating Cooling State",
"0000007B-0000-1000-8000-0026BB765291": "Target Horizontal Tilt Angle",
"0000007C-0000-1000-8000-0026BB765291": "Target Position",
"00000034-0000-1000-8000-0026BB765291": "Target Relative Humidity",
"00000035-0000-1000-8000-0026BB765291": "Target Temperature",
"0000007D-0000-1000-8000-0026BB765291": "Target Vertical Tilt Angle",
"00000036-0000-1000-8000-0026BB765291": "Temperature Display Units",
"00000037-0000-1000-8000-0026BB765291": "Version"
}
};
const uuidToName = {};
const nameToUUID = {};
// Build the mappings
Object.entries(homeKitData.Service).forEach(([uuid, name]) => {
uuidToName[uuid] = name;
nameToUUID[name] = uuid;
});
Object.entries(homeKitData.Characteristic).forEach(([uuid, name]) => {
uuidToName[uuid] = name;
nameToUUID[name] = uuid;
});
function getNameByUUID(uuid) {
if (homeKitData.Service.hasOwnProperty(uuid)) {
return homeKitData.Service[uuid];
} else if (homeKitData.Characteristic.hasOwnProperty(uuid)) {
return homeKitData.Characteristic[uuid];
} else {
return false;
}
}
function subsituteData(data) {
// console.log(JSON.stringify(data, null, 2))
data.accessories.forEach(accessories => {
accessories.services.forEach(service => {
if (getNameByUUID(service.type)) {
service.type = getNameByUUID(service.type)
}
service.characteristics.forEach(characteristic => {
if (getNameByUUID(characteristic.type)) {
characteristic.type = getNameByUUID(characteristic.type)
}
});
});
});
return data;
}
module.exports = {
getNameByUUID,
subsituteData
}