Skip to content

Commit 121f835

Browse files
committed
fix(config): remove deprecated bridge/config
1 parent ab18490 commit 121f835

File tree

4 files changed

+56
-76
lines changed

4 files changed

+56
-76
lines changed

src/initialState.json

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"networkGraphIsLoading": false,
1313
"groups": [],
1414
"bridgeState": "online",
15-
"bridgeConfig": {},
1615
"bridgeDefinitions": {},
1716
"bridgeInfo": {
1817
"configSchema": {

src/store.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import createStore from 'unistore';
22
import {
3-
BridgeConfig,
43
BridgeInfo,
54
BridgeState,
65
BridgeDefinitions,
@@ -65,7 +64,6 @@ export interface GlobalState extends WithDevices, WithDeviceStates, WithGroups,
6564
touchlinkResetInProgress: boolean;
6665
networkGraph: GraphI;
6766
networkGraphIsLoading: boolean;
68-
bridgeConfig: BridgeConfig;
6967
bridgeState: BridgeState;
7068
bridgeDefinitions: BridgeDefinitions;
7169
logs: LogMessage[];

src/types.ts

+55-66
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import { JSONSchema7 } from 'json-schema';
2-
import {CustomClusters} from './zcl/definition/tstype'
2+
import { CustomClusters } from './zcl/definition/tstype';
33

4-
export type DeviceType = "EndDevice" | "Router" | "Coordinator";
4+
export type DeviceType = 'EndDevice' | 'Router' | 'Coordinator';
55
export type FriendlyName = string;
66
export type IEEEEAddress = string;
77

88
export type OTAState = {
9-
state: "available" | "updating";
9+
state: 'available' | 'updating';
1010
progress: number;
1111
remaining: number;
12-
}
12+
};
1313
export type RGBColor = {
1414
r: number;
1515
g: number;
1616
b: number;
17-
}
17+
};
1818
export type HueSaturationColor = {
1919
hue: number;
2020
saturation: number;
21-
}
21+
};
2222

2323
export type XYColor = {
2424
x: number;
2525
y: number;
26-
}
26+
};
2727
export type AnyColor = RGBColor | XYColor | HueSaturationColor;
2828
export type DeviceState = Record<string, unknown>;
2929
export type Cluster = string | number;
@@ -56,8 +56,8 @@ export interface ClusterDefinition {
5656
}
5757

5858
export interface BridgeDefinitions {
59-
clusters: Readonly<Record<Cluster, Readonly<ClusterDefinition>>>,
60-
custom_clusters: Readonly<Record<IEEEEAddress, Readonly<CustomClusters>>>,
59+
clusters: Readonly<Record<Cluster, Readonly<ClusterDefinition>>>;
60+
custom_clusters: Readonly<Record<IEEEEAddress, Readonly<CustomClusters>>>;
6161
}
6262

6363
export interface Meta {
@@ -85,7 +85,6 @@ export interface AdvancedConfig {
8585
elapsed: boolean;
8686
last_seen: 'disable' | 'ISO_8601' | 'ISO_8601_local' | 'epoch';
8787
legacy_api: boolean;
88-
8988
}
9089
export interface Z2MConfig {
9190
homeassistant: boolean;
@@ -94,25 +93,16 @@ export interface Z2MConfig {
9493
device_options: DeviceConfig;
9594
[k: string]: unknown;
9695
}
97-
export interface BridgeConfig {
98-
version: string;
99-
commit: string;
100-
coordinator: Coordinator;
101-
network: Network;
102-
log_level: string;
103-
permit_join: boolean;
104-
105-
}
106-
export type BridgeState = "online" | "offline";
96+
export type BridgeState = 'online' | 'offline';
10797
export interface BridgeInfo {
10898
config: Z2MConfig;
10999
config_schema: JSONSchema7;
110100
permit_join: boolean;
111101
permit_join_timeout: number;
112102
commit?: string;
113103
version?: string;
114-
zigbee_herdsman_converters: {version: string},
115-
zigbee_herdsman: {version: string},
104+
zigbee_herdsman_converters: { version: string };
105+
zigbee_herdsman: { version: string };
116106
coordinator?: {
117107
meta?: {
118108
revision?: string;
@@ -124,11 +114,10 @@ export interface BridgeInfo {
124114
restart_required: boolean;
125115
}
126116

127-
export type PowerSource = "Battery" | "Mains (single phase)" | "DC Source";
128-
129-
export type GenericFeatureType = "numeric" | "binary" | "enum" | "text" | "list";
130-
export type CompositeFeatureType = "fan" | "light" | "switch" | "cover" | "lock" | "composite" | "climate";
117+
export type PowerSource = 'Battery' | 'Mains (single phase)' | 'DC Source';
131118

119+
export type GenericFeatureType = 'numeric' | 'binary' | 'enum' | 'text' | 'list';
120+
export type CompositeFeatureType = 'fan' | 'light' | 'switch' | 'cover' | 'lock' | 'composite' | 'climate';
132121

133122
export enum FeatureAccessMode {
134123
NONE,
@@ -140,30 +129,30 @@ export interface GenericExposedFeature {
140129
type: GenericFeatureType;
141130
name: string;
142131
label: string;
143-
unit?: "string";
132+
unit?: 'string';
144133
access: FeatureAccessMode;
145134
endpoint?: Endpoint;
146135
property?: string;
147136
description?: string;
148137
}
149138

150139
export interface BinaryFeature extends GenericExposedFeature {
151-
type: "binary";
140+
type: 'binary';
152141
value_on: unknown;
153142
value_off: unknown;
154143
value_toggle?: unknown;
155144
}
156145

157146
export interface ListFeature extends GenericExposedFeature {
158-
type: "list";
147+
type: 'list';
159148
// bad design decision
160-
item_type: "number" | GenericOrCompositeFeature;
149+
item_type: 'number' | GenericOrCompositeFeature;
161150

162151
length_min?: number;
163152
length_max?: number;
164153
}
165154

166-
export interface CompositeFeature extends Omit<GenericExposedFeature, "type"> {
155+
export interface CompositeFeature extends Omit<GenericExposedFeature, 'type'> {
167156
type: CompositeFeatureType;
168157
features: GenericOrCompositeFeature[];
169158
}
@@ -176,55 +165,55 @@ export interface NumericFeaturePreset {
176165
description?: string;
177166
}
178167
export interface NumericFeature extends GenericExposedFeature {
179-
type: "numeric";
168+
type: 'numeric';
180169
value_min?: number;
181170
value_max?: number;
182171
value_step?: number;
183172
presets?: NumericFeaturePreset[];
184173
}
185174

186175
export interface TextualFeature extends GenericExposedFeature {
187-
type: "text";
176+
type: 'text';
188177
}
189178

190179
export interface EnumFeature extends GenericExposedFeature {
191-
type: "enum";
180+
type: 'enum';
192181
values: unknown[];
193182
}
194183

195184
export interface GradientFeature extends GenericExposedFeature {
196-
type: "text";
197-
name: "gradient";
185+
type: 'text';
186+
name: 'gradient';
198187
length_min: number;
199188
length_max: number;
200189
}
201190

202191
export interface LightFeature extends CompositeFeature {
203-
type: "light";
192+
type: 'light';
204193
}
205194

206195
export interface SwitchFeature extends CompositeFeature {
207-
type: "switch";
196+
type: 'switch';
208197
}
209198

210199
export interface CoverFeature extends CompositeFeature {
211-
type: "cover";
200+
type: 'cover';
212201
}
213202

214203
export interface LockFeature extends CompositeFeature {
215-
type: "lock";
204+
type: 'lock';
216205
}
217206
export interface FanFeature extends CompositeFeature {
218-
type: "fan";
207+
type: 'fan';
219208
}
220209

221210
export interface ClimateFeature extends CompositeFeature {
222-
type: "climate";
211+
type: 'climate';
223212
}
224213

225214
export interface ColorFeature extends CompositeFeature {
226-
type: "composite";
227-
name: "color_xy" | "color_hs";
215+
type: 'composite';
216+
name: 'color_xy' | 'color_hs';
228217
features: NumericFeature[];
229218
}
230219

@@ -272,7 +261,7 @@ export type Scene = {
272261
id: number;
273262
name?: string;
274263
endpoint?: Endpoint;
275-
}
264+
};
276265
export interface Group extends WithFriendlyName, WithDescription, WithScenes {
277266
id: number;
278267
members: GroupAddress[];
@@ -294,42 +283,42 @@ export interface Device extends WithFriendlyName, WithDescription {
294283
endpoints: Record<Endpoint, EndpointDescription>;
295284
}
296285

297-
export type ObjectType = "device" | "group";
286+
export type ObjectType = 'device' | 'group';
298287
export interface BindRule {
299288
cluster: Cluster;
300289
target: {
301290
id?: number;
302291
endpoint?: Endpoint;
303292
ieee_address?: IEEEEAddress;
304-
type: "endpoint" | "group";
293+
type: 'endpoint' | 'group';
305294
};
306-
307295
}
308296

309297
export interface TouchLinkDevice {
310298
ieee_address: IEEEEAddress;
311299
channel: number;
312300
}
313301

314-
export type LastSeenType = "disable" | "ISO_8601" | "ISO_8601_local" | "epoch";
315-
316-
export type KVP = Record<string, unknown>
302+
export type LastSeenType = 'disable' | 'ISO_8601' | 'ISO_8601_local' | 'epoch';
317303

304+
export type KVP = Record<string, unknown>;
318305

319-
export type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
320-
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...0[]]
306+
export type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...0[]];
321307

322-
export type Join<K, P> = K extends string | number ?
323-
P extends string | number ?
324-
`${K}${"" extends P ? "" : "."}${P}`
325-
: never : never;
326-
327-
328-
export type Paths<T, D extends number = 10> = [D] extends [never] ? never : T extends object ?
329-
{ [K in keyof T]-?: K extends string | number ?
330-
`${K}` | Join<K, Paths<T[K], Prev[D]>>
308+
export type Join<K, P> = K extends string | number
309+
? P extends string | number
310+
? `${K}${'' extends P ? '' : '.'}${P}`
331311
: never
332-
}[keyof T] : ""
333-
334-
export type Leaves<T, D extends number = 10> = [D] extends [never] ? never : T extends object ?
335-
{ [K in keyof T]-?: Join<K, Leaves<T[K], Prev[D]>> }[keyof T] : "";
312+
: never;
313+
314+
export type Paths<T, D extends number = 10> = [D] extends [never]
315+
? never
316+
: T extends object
317+
? { [K in keyof T]-?: K extends string | number ? `${K}` | Join<K, Paths<T[K], Prev[D]>> : never }[keyof T]
318+
: '';
319+
320+
export type Leaves<T, D extends number = 10> = [D] extends [never]
321+
? never
322+
: T extends object
323+
? { [K in keyof T]-?: Join<K, Leaves<T[K], Prev[D]>> }[keyof T]
324+
: '';

src/ws-client.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ReconnectingWebSocket from 'reconnecting-websocket';
22
import store, { Base64String, Extension, LogMessage, OnlineOrOffline } from './store';
3-
import { BridgeConfig, BridgeInfo, BridgeState, BridgeDefinitions, Device, DeviceState, Group, TouchLinkDevice } from './types';
3+
import { BridgeInfo, BridgeState, BridgeDefinitions, Device, DeviceState, Group, TouchLinkDevice } from './types';
44
import {
55
debounceArgs,
66
isSecurePage,
@@ -155,12 +155,6 @@ class Api {
155155

156156
private processBridgeMessage = (data: Message): void => {
157157
switch (data.topic) {
158-
case "bridge/config":
159-
store.setState({
160-
bridgeConfig: data.payload as unknown as BridgeConfig
161-
});
162-
break;
163-
164158
case "bridge/info":
165159
store.setState({
166160
bridgeInfo: data.payload as unknown as BridgeInfo

0 commit comments

Comments
 (0)