Skip to content

Commit

Permalink
fix(config): fix HA and availability feature enabled (#2343)
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk authored Dec 28, 2024
1 parent 63b33e8 commit a20222f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/device-page/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class DeviceInfo extends Component<
render(): JSX.Element {
const { device, deviceStates, bridgeInfo, availability, t } = this.props;
const { configureDevice, renameDevice, removeDevice, setDeviceDescription, interviewDevice } = this.props;
const homeassistantEnabled = !!bridgeInfo.config?.homeassistant;
const homeassistantEnabled = !!bridgeInfo.config?.homeassistant?.enabled;
const deviceState: DeviceState = deviceStates[device.friendly_name] ?? ({} as DeviceState);

const displayProps = [
Expand Down Expand Up @@ -87,7 +87,7 @@ export class DeviceInfo extends Component<
availability: AvailabilityState,
) => {
const { config } = bridgeInfo;
const availabilityFeatureEnabled = !!config.availability;
const availabilityFeatureEnabled = !!config.availability?.enabled;
const availabilityEnabledForDevice = config.devices[device.ieee_address]?.availability !== false;

return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/zigbee/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ function DevicesPage(props: DevicesPageProps): JSX.Element {
availability,
} = props;
const { renameDevice, removeDevice, configureDevice, setDeviceDescription, interviewDevice } = props;
const availabilityFeatureEnabled = !!config.availability;
const homeassistantEnabled = !!config?.homeassistant;
const availabilityFeatureEnabled = !!config.availability?.enabled;
const homeassistantEnabled = !!config?.homeassistant?.enabled;
const getDevicesToRender = (): DevicesPageData[] => {
return Object.values<Device>(devices)
.filter((device) => device.type !== 'Coordinator')
Expand Down
7 changes: 6 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ export interface AdvancedConfig {
legacy_api: boolean;
}
export interface Z2MConfig {
homeassistant: boolean;
homeassistant?: {
enabled: boolean;
};
availability?: {
enabled: boolean;
};
advanced: AdvancedConfig;
devices: Record<string, DeviceConfig>;
device_options: DeviceConfig;
Expand Down

0 comments on commit a20222f

Please sign in to comment.