Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): fix HA and availability feature enabled #2343

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading