mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-16 18:39:09 -07:00
Allow string values for permit_join call. https://github.com/Koenkk/zigbee2mqtt/issues/5644
This commit is contained in:
parent
8026dde26a
commit
19c54040bc
@ -185,6 +185,10 @@ class Bridge extends Extension {
|
|||||||
value = message;
|
value = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
value = value.toLowerCase() === 'true';
|
||||||
|
}
|
||||||
|
|
||||||
await this.zigbee.permitJoin(value, resolvedEntity, time);
|
await this.zigbee.permitJoin(value, resolvedEntity, time);
|
||||||
const response = {value};
|
const response = {value};
|
||||||
if (resolvedEntity) response.device = message.device;
|
if (resolvedEntity) response.device = message.device;
|
||||||
|
@ -219,6 +219,18 @@ describe('Bridge', () => {
|
|||||||
{retain: false, qos: 0}, expect.any(Function)
|
{retain: false, qos: 0}, expect.any(Function)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
zigbeeHerdsman.permitJoin.mockClear();
|
||||||
|
MQTT.publish.mockClear();
|
||||||
|
MQTT.events.message('zigbee2mqtt/bridge/request/permit_join', stringify({"value": "False"}));
|
||||||
|
await flushPromises();
|
||||||
|
expect(zigbeeHerdsman.permitJoin).toHaveBeenCalledTimes(1);
|
||||||
|
expect(zigbeeHerdsman.permitJoin).toHaveBeenCalledWith(false, undefined, undefined);
|
||||||
|
expect(MQTT.publish).toHaveBeenCalledWith(
|
||||||
|
'zigbee2mqtt/bridge/response/permit_join',
|
||||||
|
stringify({"data":{"value":false},"status":"ok"}),
|
||||||
|
{retain: false, qos: 0}, expect.any(Function)
|
||||||
|
);
|
||||||
|
|
||||||
// Invalid payload
|
// Invalid payload
|
||||||
zigbeeHerdsman.permitJoin.mockClear();
|
zigbeeHerdsman.permitJoin.mockClear();
|
||||||
MQTT.publish.mockClear();
|
MQTT.publish.mockClear();
|
||||||
|
Loading…
Reference in New Issue
Block a user