Skip to content

Commit

Permalink
fix!: Remove permit_join_timeout (Koenkk#25082)
Browse files Browse the repository at this point in the history
Co-authored-by: Nerivec <[email protected]>
Co-authored-by: IIIEII <[email protected]>
Co-authored-by: Artem Draft <[email protected]>
  • Loading branch information
4 people authored Dec 8, 2024
1 parent f44ea32 commit 7d63a87
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 48 deletions.
3 changes: 2 additions & 1 deletion lib/extension/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,8 @@ export default class Bridge extends Extension {
channel: networkParams.channel,
},
log_level: logger.getLevel(),
permit_join_timeout: this.zigbee.getPermitJoinTimeout(),
permit_join: this.zigbee.getPermitJoin(),
permit_join_end: this.zigbee.getPermitJoinEnd(),
restart_required: this.restartRequired,
config,
config_schema: settings.schemaJson,
Expand Down
14 changes: 0 additions & 14 deletions lib/extension/homeassistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2014,20 +2014,6 @@ export default class HomeAssistant extends Extension {
json_attributes_template: '{{ value_json.data.value | tojson }}',
},
},
{
type: 'sensor',
object_id: 'permit_join_timeout',
mockProperties: [],
discovery_payload: {
name: 'Permit join timeout',
device_class: 'duration',
unit_of_measurement: 's',
entity_category: 'diagnostic',
state_topic: true,
state_topic_postfix: 'info',
value_template: '{{ iif(value_json.permit_join_timeout is defined, value_json.permit_join_timeout, None) }}',
},
},

// Switches.
{
Expand Down
3 changes: 2 additions & 1 deletion lib/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ export interface Zigbee2MQTTAPI {
channel: number;
};
log_level: 'debug' | 'info' | 'warning' | 'error';
permit_join_timeout: number;
permit_join: boolean;
permit_join_end: number | undefined;
restart_required: boolean;
config: Settings;
config_schema: typeof schemaJson;
Expand Down
8 changes: 6 additions & 2 deletions lib/zigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,12 @@ export default class Zigbee {
logger.info('Stopped zigbee-herdsman');
}

getPermitJoinTimeout(): number {
return this.herdsman.getPermitJoinTimeout();
getPermitJoin(): boolean {
return this.herdsman.getPermitJoin();
}

getPermitJoinEnd(): number | undefined {
return this.herdsman.getPermitJoinEnd();
}

async permitJoin(time: number, device?: Device): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"winston-syslog": "^2.7.1",
"winston-transport": "^4.9.0",
"ws": "^8.18.0",
"zigbee-herdsman": "3.0.1",
"zigbee-herdsman": "3.0.2",
"zigbee-herdsman-converters": "21.2.1",
"zigbee2mqtt-frontend": "0.9.0"
},
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test/extensions/bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ describe('Extension: Bridge', () => {
coordinator: {ieee_address: '0x00124b00120144ae', meta: {revision: 20190425, version: 1}, type: 'z-Stack'},
log_level: 'info',
network: {channel: 15, extended_pan_id: 0x001122, pan_id: 5674},
permit_join_timeout: 0,
permit_join: false,
permit_join_end: undefined,
restart_required: false,
version: version.version,
zigbee_herdsman: zhVersion,
Expand Down
20 changes: 0 additions & 20 deletions test/extensions/homeassistant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2389,26 +2389,6 @@ describe('Extension: HomeAssistant', () => {
{retain: true, qos: 1},
);

payload = {
name: 'Permit join timeout',
object_id: 'zigbee2mqtt_bridge_permit_join_timeout',
entity_category: 'diagnostic',
device_class: 'duration',
unit_of_measurement: 's',
unique_id: 'bridge_0x00124b00120144ae_permit_join_timeout_zigbee2mqtt',
state_topic: 'zigbee2mqtt/bridge/info',
value_template: '{{ iif(value_json.permit_join_timeout is defined, value_json.permit_join_timeout, None) }}',
origin: origin,
device: devicePayload,
availability: [{topic: 'zigbee2mqtt/bridge/state', value_template: '{{ value_json.state }}'}],
availability_mode: 'all',
};
expect(mockMQTT.publishAsync).toHaveBeenCalledWith(
'homeassistant/sensor/1221051039810110150109113116116_0x00124b00120144ae/permit_join_timeout/config',
stringify(payload),
{retain: true, qos: 1},
);

// Switches.
payload = {
name: 'Permit join',
Expand Down
3 changes: 2 additions & 1 deletion test/mocks/zigbeeHerdsman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,8 @@ export const mockController = {
touchlinkFactoryResetFirst: jest.fn(),
addInstallCode: jest.fn(),
permitJoin: jest.fn(),
getPermitJoinTimeout: jest.fn((): number => 0),
getPermitJoin: jest.fn((): boolean => false),
getPermitJoinEnd: jest.fn((): number | undefined => undefined),
isStopping: jest.fn((): boolean => false),
backup: jest.fn(),
coordinatorCheck: jest.fn(),
Expand Down

0 comments on commit 7d63a87

Please sign in to comment.