Skip to content

Commit

Permalink
fix(ignore): fix dd1e0db
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Dec 4, 2023
1 parent dd1e0db commit 04d8522
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 33 deletions.
4 changes: 2 additions & 2 deletions lib/extension/homeassistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ export default class HomeAssistant extends Extension {
}

if (hasColorTemp) {
const colorTemps = exposes.map((expose) => expose.features
.filter(isNumericExposeFeature).find((e) => e.name === 'color_temp'));
const colorTemps = exposes.map((expose) => expose.features.find((e) => e.name === 'color_temp'))
.filter((e) => e).filter(isNumericExposeFeature);
const max = Math.min(...colorTemps.map((e) => e.value_max));
const min = Math.max(...colorTemps.map((e) => e.value_min));
discoveryEntry.discovery_payload.max_mireds = max;
Expand Down
2 changes: 1 addition & 1 deletion lib/extension/otaUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class OTAUpdate extends Extension {
logger.debug(`Device '${data.device.name}' requested OTA`);

const automaticOTACheckDisabled = settings.get().ota.disable_automatic_update_check;
let supportsOTA = data.device.definition.hasOwnProperty('ota');
let supportsOTA = !!data.device.definition.ota;
if (supportsOTA && !automaticOTACheckDisabled) {
// When a device does a next image request, it will usually do it a few times after each other
// with only 10 - 60 seconds inbetween. It doesn't make sense to check for a new update
Expand Down
12 changes: 0 additions & 12 deletions scripts/generateNewSupportedDevices.js

This file was deleted.

26 changes: 13 additions & 13 deletions test/externalConverters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const flushPromises = require('./lib/flushPromises');
const path = require('path');
const fs = require('fs');

zigbeeHerdsmanConverters.addDeviceDefinition = jest.fn();
zigbeeHerdsmanConverters.addDefinition = jest.fn();

const mocksClear = [zigbeeHerdsmanConverters.addDeviceDefinition, zigbeeHerdsman.permitJoin,
const mocksClear = [zigbeeHerdsmanConverters.addDefinition, zigbeeHerdsman.permitJoin,
mockExit, MQTT.end, zigbeeHerdsman.stop, logger.debug,
MQTT.publish, MQTT.connect, zigbeeHerdsman.devices.bulb_color.removeFromNetwork,
zigbeeHerdsman.devices.bulb.removeFromNetwork, logger.error,
Expand Down Expand Up @@ -67,15 +67,15 @@ describe('Loads external converters', () => {
it('Does not load external converters', async () => {
settings.set(['external_converters'], []);
await resetExtension();
expect(zigbeeHerdsmanConverters.addDeviceDefinition).toHaveBeenCalledTimes(0);
expect(zigbeeHerdsmanConverters.addDefinition).toHaveBeenCalledTimes(0);
});

it('Loads external converters', async () => {
fs.copyFileSync(path.join(__dirname, 'assets', 'mock-external-converter.js'), path.join(data.mockDir, 'mock-external-converter.js'));
settings.set(['external_converters'], ['mock-external-converter.js']);
await resetExtension();
expect(zigbeeHerdsmanConverters.addDeviceDefinition).toHaveBeenCalledTimes(1);
expect(zigbeeHerdsmanConverters.addDeviceDefinition).toHaveBeenCalledWith({
expect(zigbeeHerdsmanConverters.addDefinition).toHaveBeenCalledTimes(1);
expect(zigbeeHerdsmanConverters.addDefinition).toHaveBeenCalledWith({
mock: true,
zigbeeModel: ['external_converter_device'],
vendor: 'external',
Expand All @@ -91,8 +91,8 @@ describe('Loads external converters', () => {
fs.copyFileSync(path.join(__dirname, 'assets', 'mock-external-converter-multiple.js'), path.join(data.mockDir, 'mock-external-converter-multiple.js'));
settings.set(['external_converters'], ['mock-external-converter-multiple.js']);
await resetExtension();
expect(zigbeeHerdsmanConverters.addDeviceDefinition).toHaveBeenCalledTimes(2);
expect(zigbeeHerdsmanConverters.addDeviceDefinition).toHaveBeenNthCalledWith(1, {
expect(zigbeeHerdsmanConverters.addDefinition).toHaveBeenCalledTimes(2);
expect(zigbeeHerdsmanConverters.addDefinition).toHaveBeenNthCalledWith(1, {
mock: 1,
model: 'external_converters_device_1',
zigbeeModel: ['external_converter_device_1'],
Expand All @@ -102,7 +102,7 @@ describe('Loads external converters', () => {
toZigbee: [],
exposes: []
});
expect(zigbeeHerdsmanConverters.addDeviceDefinition).toHaveBeenNthCalledWith(2, {
expect(zigbeeHerdsmanConverters.addDefinition).toHaveBeenNthCalledWith(2, {
mock: 2,
model: 'external_converters_device_2',
zigbeeModel: ['external_converter_device_2'],
Expand All @@ -117,20 +117,20 @@ describe('Loads external converters', () => {
it('Loads external converters from package', async () => {
settings.set(['external_converters'], ['mock-external-converter-module']);
await resetExtension();
expect(zigbeeHerdsmanConverters.addDeviceDefinition).toHaveBeenCalledTimes(1);
expect(zigbeeHerdsmanConverters.addDeviceDefinition).toHaveBeenCalledWith({
expect(zigbeeHerdsmanConverters.addDefinition).toHaveBeenCalledTimes(1);
expect(zigbeeHerdsmanConverters.addDefinition).toHaveBeenCalledWith({
mock: true
});
});

it('Loads multiple external converters from package', async () => {
settings.set(['external_converters'], ['mock-multiple-external-converter-module']);
await resetExtension();
expect(zigbeeHerdsmanConverters.addDeviceDefinition).toHaveBeenCalledTimes(2);
expect(zigbeeHerdsmanConverters.addDeviceDefinition).toHaveBeenNthCalledWith(1, {
expect(zigbeeHerdsmanConverters.addDefinition).toHaveBeenCalledTimes(2);
expect(zigbeeHerdsmanConverters.addDefinition).toHaveBeenNthCalledWith(1, {
mock: 1
});
expect(zigbeeHerdsmanConverters.addDeviceDefinition).toHaveBeenNthCalledWith(2, {
expect(zigbeeHerdsmanConverters.addDefinition).toHaveBeenNthCalledWith(2, {
mock: 2
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Groups', () => {
settings.reRead();
MQTT.publish.mockClear();
zigbeeHerdsman.groups.gledopto_group.command.mockClear();
zigbeeHerdsmanConverters.toZigbeeConverters.__clearStore__();
zigbeeHerdsmanConverters.toZigbee.__clearStore__();
controller.state.state = {};
})

Expand Down
2 changes: 1 addition & 1 deletion test/homeassistant.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('HomeAssistant extension', () => {

it('Should not have duplicate type/object_ids in a mapping', () => {
const duplicated = [];
require('zigbee-herdsman-converters').devices.forEach((d) => {
require('zigbee-herdsman-converters').definitions.forEach((d) => {
const exposes = typeof d.exposes == 'function' ? d.exposes() : d.exposes;
const device = {definition: d, isDevice: () => true, options: {}, exposes: () => exposes, zh: {endpoints: []}};
const configs = extension.getConfigs(device);
Expand Down
2 changes: 1 addition & 1 deletion test/onEvent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ describe('On event', () => {
await zigbeeHerdsman.events.deviceAnnounce({device});
await flushPromises();
expect(zigbeeHerdsmanConverters.onEvent).toHaveBeenCalledTimes(1);
expect(zigbeeHerdsmanConverters.onEvent).toHaveBeenCalledWith('deviceAnnounce', {device}, device, settings.getDevice(device.ieeeAddr), {});
expect(zigbeeHerdsmanConverters.onEvent).toHaveBeenCalledWith('deviceAnnounce', {device}, device);
});
});
4 changes: 2 additions & 2 deletions test/publish.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Publish', () => {
g.command.mockClear();
});

zigbeeHerdsmanConverters.toZigbeeConverters.__clearStore__();
zigbeeHerdsmanConverters.toZigbee.__clearStore__();
});

afterAll(async () => {
Expand Down Expand Up @@ -1343,7 +1343,7 @@ describe('Publish', () => {
await MQTT.events.message('zigbee2mqtt/bulb_color/set', stringify({state: 'ON', brightness: 20, transition: 0.0}));
await flushPromises();

zigbeeHerdsmanConverters.toZigbeeConverters.__clearStore__();
zigbeeHerdsmanConverters.toZigbee.__clearStore__();

await MQTT.events.message('zigbee2mqtt/bulb_color/set', stringify({"state": "ON", "transition": 1.0}));
await flushPromises();
Expand Down

0 comments on commit 04d8522

Please sign in to comment.