diff --git a/src/actions/BridgeApi.ts b/src/actions/BridgeApi.ts index 84e342a2c..6bf797ccd 100644 --- a/src/actions/BridgeApi.ts +++ b/src/actions/BridgeApi.ts @@ -3,7 +3,7 @@ import { Device } from '../types'; import store from '../store'; export interface BridgeApi { - setPermitJoin(permit: boolean, device: Device): Promise; + setPermitJoin(time: number, device: Device): Promise; updateBridgeConfig(options: unknown): Promise; restartBridge(): Promise; requestBackup(): Promise; @@ -11,8 +11,8 @@ export interface BridgeApi { } -const setPermitJoin = (_state, permit = true, device?: Device, time = 254): Promise => { - return api.send("bridge/request/permit_join", { value: permit, time, device: device?.friendly_name }); +const setPermitJoin = (_state, time = 254, device?: Device): Promise => { + return api.send("bridge/request/permit_join", { time, device: device?.friendly_name }); } export default { @@ -29,6 +29,6 @@ export default { }, async addInstallCode(_state, installCode: string): Promise { await api.send('bridge/request/install_code/add', { value: installCode }); - return setPermitJoin(_state, true) + return setPermitJoin(_state, 254) } } diff --git a/src/components/navbar/StartStopJoinButton.tsx b/src/components/navbar/StartStopJoinButton.tsx index aa1306e5a..c23951bf3 100644 --- a/src/components/navbar/StartStopJoinButton.tsx +++ b/src/components/navbar/StartStopJoinButton.tsx @@ -14,7 +14,8 @@ export function StartStopJoinButton({ devices, setPermitJoin, bridgeInfo }: Star const { t } = useTranslation(['navbar']); const { ref, isComponentVisible, setIsComponentVisible } = useComponentVisible(false); const [selectedRouter, setSelectedRouter] = useState({} as Device); - const { permit_join: permitJoin, permit_join_timeout: permitJoinTimeout } = bridgeInfo; + const { permit_join_timeout: permitJoinTimeout } = bridgeInfo; + const permitJoin = permitJoinTimeout > 0; const selectAndHide = (device: Device) => { setSelectedRouter(device); @@ -36,7 +37,7 @@ export function StartStopJoinButton({ devices, setPermitJoin, bridgeInfo }: Star )); const onBtnClick = () => { - setPermitJoin(!permitJoin, selectedRouter); + setPermitJoin(permitJoin ? 0 : 254, selectedRouter); }; const permitJoinTimer = ( <> diff --git a/src/types.ts b/src/types.ts index 89dcd73ae..57e7891cd 100644 --- a/src/types.ts +++ b/src/types.ts @@ -97,7 +97,6 @@ export type BridgeState = 'online' | 'offline'; export interface BridgeInfo { config: Z2MConfig; config_schema: JSONSchema7; - permit_join: boolean; permit_join_timeout: number; commit?: string; version?: string;