Skip to content

Commit a20222f

Browse files
authored
fix(config): fix HA and availability feature enabled (#2343)
1 parent 63b33e8 commit a20222f

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/components/device-page/info.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class DeviceInfo extends Component<
3939
render(): JSX.Element {
4040
const { device, deviceStates, bridgeInfo, availability, t } = this.props;
4141
const { configureDevice, renameDevice, removeDevice, setDeviceDescription, interviewDevice } = this.props;
42-
const homeassistantEnabled = !!bridgeInfo.config?.homeassistant;
42+
const homeassistantEnabled = !!bridgeInfo.config?.homeassistant?.enabled;
4343
const deviceState: DeviceState = deviceStates[device.friendly_name] ?? ({} as DeviceState);
4444

4545
const displayProps = [
@@ -87,7 +87,7 @@ export class DeviceInfo extends Component<
8787
availability: AvailabilityState,
8888
) => {
8989
const { config } = bridgeInfo;
90-
const availabilityFeatureEnabled = !!config.availability;
90+
const availabilityFeatureEnabled = !!config.availability?.enabled;
9191
const availabilityEnabledForDevice = config.devices[device.ieee_address]?.availability !== false;
9292

9393
return (

src/components/zigbee/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ function DevicesPage(props: DevicesPageProps): JSX.Element {
3434
availability,
3535
} = props;
3636
const { renameDevice, removeDevice, configureDevice, setDeviceDescription, interviewDevice } = props;
37-
const availabilityFeatureEnabled = !!config.availability;
38-
const homeassistantEnabled = !!config?.homeassistant;
37+
const availabilityFeatureEnabled = !!config.availability?.enabled;
38+
const homeassistantEnabled = !!config?.homeassistant?.enabled;
3939
const getDevicesToRender = (): DevicesPageData[] => {
4040
return Object.values<Device>(devices)
4141
.filter((device) => device.type !== 'Coordinator')

src/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ export interface AdvancedConfig {
8787
legacy_api: boolean;
8888
}
8989
export interface Z2MConfig {
90-
homeassistant: boolean;
90+
homeassistant?: {
91+
enabled: boolean;
92+
};
93+
availability?: {
94+
enabled: boolean;
95+
};
9196
advanced: AdvancedConfig;
9297
devices: Record<string, DeviceConfig>;
9398
device_options: DeviceConfig;

0 commit comments

Comments
 (0)