Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(2191): Migrate from ezsp to ember driver for Z2M #2196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading