Skip to content

Commit

Permalink
fix(2191): Migrate from ezsp to ember driver for Z2M
Browse files Browse the repository at this point in the history
  • Loading branch information
cicoub13 committed Jan 9, 2025
1 parent e9b3211 commit 084e89e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions server/services/zigbee2mqtt/adapters/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const CONFIG_KEYS = {
DECONZ: 'deconz',
EZSP: 'ezsp',
EMBER: 'ember',
NONE: 'none',
};

const ADAPTERS_BY_CONFIG_KEY = {
[CONFIG_KEYS.DECONZ]: ['ConBee', 'ConBee II', 'RaspBee', 'RaspBee II'],
[CONFIG_KEYS.EZSP]: [
[CONFIG_KEYS.EMBER]: [
'CoolKit ZB-GW04 USB dongle (a.k.a. easyiot stick)',
'Elelabs ELU013 and Popp ZB-STICK',
'Elelabs Zigbee Raspberry Pi Shield/Popp ZB-Shield',
Expand Down
2 changes: 1 addition & 1 deletion server/services/zigbee2mqtt/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const DEFAULT = {
'zigbee2mqtt/#', // Default zigbee2mqtt topic
],
DOCKER_MQTT_VERSION: '4', // Last version of MQTT docker file
DOCKER_Z2M_VERSION: '4', // Last version of Z2M docker file,
DOCKER_Z2M_VERSION: '5', // Last version of Z2M docker file,
CONFIGURATION_PATH: 'zigbee2mqtt/z2m/configuration.yaml',
CONFIGURATION_CONTENT: {
homeassistant: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mqtt:
server: mqtt://localhost:1884
serial:
port: /dev/ttyACM0
adapter: ezsp
adapter: ember
map_options:
graphviz:
colors:
Expand Down
20 changes: 10 additions & 10 deletions server/test/services/zigbee2mqtt/lib/configureContainer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const defaultConfigFilePath = path.join(configBasePath, 'z2m_default_config.yaml
const mqttConfigFilePath = path.join(configBasePath, 'z2m_mqtt_config.yaml');
const mqttOtherConfigFilePath = path.join(configBasePath, 'z2m_mqtt-other_config.yaml');
const deconzConfigFilePath = path.join(configBasePath, 'z2m_adapter-deconz_config.yaml');
const ezspConfigFilePath = path.join(configBasePath, 'z2m_adapter-ezsp_config.yaml');
const emberznetConfigFilePath = path.join(configBasePath, 'z2m_adapter-emberznet_config.yaml');
const portConfigFilePath = path.join(configBasePath, 'z2m_port_config.yaml');

describe('zigbee2mqtt configureContainer', () => {
Expand Down Expand Up @@ -150,20 +150,20 @@ describe('zigbee2mqtt configureContainer', () => {
it('it should only add serial adapter', async () => {
// PREPARE
const config = {
z2mDongleName: ADAPTERS_BY_CONFIG_KEY[CONFIG_KEYS.EZSP][0],
z2mDongleName: ADAPTERS_BY_CONFIG_KEY[CONFIG_KEYS.EMBER][0],
};
// EXECUTE
const changed = await zigbee2mqttManager.configureContainer(basePathOnContainer, config);
// ASSERT
const resultContent = fs.readFileSync(configFilePath, 'utf8');
const expectedContent = fs.readFileSync(ezspConfigFilePath, 'utf8');
const expectedContent = fs.readFileSync(emberznetConfigFilePath, 'utf8');
expect(resultContent).to.equal(expectedContent);
expect(changed).to.be.eq(true);
});

it('it should remove serial adapter (adapter is not set)', async () => {
// PREPARE
fs.copyFileSync(ezspConfigFilePath, configFilePath);
fs.copyFileSync(emberznetConfigFilePath, configFilePath);
const config = {};
// EXECUTE
const changed = await zigbee2mqttManager.configureContainer(basePathOnContainer, config);
Expand All @@ -176,7 +176,7 @@ describe('zigbee2mqtt configureContainer', () => {

it('it should remove serial adapter (adapter is expliclty none)', async () => {
// PREPARE
fs.copyFileSync(ezspConfigFilePath, configFilePath);
fs.copyFileSync(emberznetConfigFilePath, configFilePath);
const config = {
z2mDongleName: ADAPTERS_BY_CONFIG_KEY[CONFIG_KEYS.NONE][0],
};
Expand All @@ -191,22 +191,22 @@ describe('zigbee2mqtt configureContainer', () => {

it('it should keep serial adapter', async () => {
// PREPARE
fs.copyFileSync(ezspConfigFilePath, configFilePath);
fs.copyFileSync(emberznetConfigFilePath, configFilePath);
const config = {
z2mDongleName: ADAPTERS_BY_CONFIG_KEY[CONFIG_KEYS.EZSP][0],
z2mDongleName: ADAPTERS_BY_CONFIG_KEY[CONFIG_KEYS.EMBER][0],
};
// EXECUTE
const changed = await zigbee2mqttManager.configureContainer(basePathOnContainer, config);
// ASSERT
const resultContent = fs.readFileSync(configFilePath, 'utf8');
const expectedContent = fs.readFileSync(ezspConfigFilePath, 'utf8');
const expectedContent = fs.readFileSync(emberznetConfigFilePath, 'utf8');
expect(resultContent).to.equal(expectedContent);
expect(changed).to.be.eq(false);
});

it('it should override serial adapter', async () => {
// PREPARE
fs.copyFileSync(ezspConfigFilePath, configFilePath);
fs.copyFileSync(emberznetConfigFilePath, configFilePath);
const config = {
z2mDongleName: ADAPTERS_BY_CONFIG_KEY[CONFIG_KEYS.DECONZ][0],
};
Expand All @@ -221,7 +221,7 @@ describe('zigbee2mqtt configureContainer', () => {

it('it should remove serial adapter (unknown adapter)', async () => {
// PREPARE
fs.copyFileSync(ezspConfigFilePath, configFilePath);
fs.copyFileSync(emberznetConfigFilePath, configFilePath);
const config = { z2mDongleName: 'this-is-not-a-real-adapter' };
// EXECUTE
const changed = await zigbee2mqttManager.configureContainer(basePathOnContainer, config);
Expand Down

0 comments on commit 084e89e

Please sign in to comment.