mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-16 02:18:31 -07:00
Implement new api healthcheck. #3281
This commit is contained in:
parent
2e0b23f97c
commit
db748a1333
@ -24,6 +24,7 @@ class Bridge extends Extension {
|
||||
'config/elapsed': this.configElapsed.bind(this),
|
||||
'config/log_level': this.configLogLevel.bind(this),
|
||||
'touchlink/factory_reset': this.touchlinkFactoryReset.bind(this),
|
||||
'health_check': this.healthCheck.bind(this),
|
||||
};
|
||||
}
|
||||
|
||||
@ -111,6 +112,10 @@ class Bridge extends Extension {
|
||||
return this.removeEntity('group', message);
|
||||
}
|
||||
|
||||
async healthCheck(message) {
|
||||
return utils.getResponse(message, {healthy: true}, null);
|
||||
}
|
||||
|
||||
async groupAdd(message) {
|
||||
if (typeof message === 'object' && !message.hasOwnProperty('friendly_name')) {
|
||||
throw new Error(`Invalid payload`);
|
||||
|
@ -220,6 +220,17 @@ describe('Bridge', () => {
|
||||
await flushPromises();
|
||||
});
|
||||
|
||||
it('Should allow a healthcheck', async () => {
|
||||
MQTT.publish.mockClear();
|
||||
MQTT.events.message('zigbee2mqtt/bridge/request/health_check', '');
|
||||
await flushPromises();
|
||||
expect(MQTT.publish).toHaveBeenCalledWith(
|
||||
'zigbee2mqtt/bridge/response/health_check',
|
||||
JSON.stringify({"data":{"healthy": true},"status":"ok"}),
|
||||
{retain: false, qos: 0}, expect.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it('Should allow to remove device by string', async () => {
|
||||
const device = zigbeeHerdsman.devices.bulb;
|
||||
controller.state.state = {'0x000b57fffec6a5b3': {brightness: 100}};
|
||||
|
Loading…
Reference in New Issue
Block a user