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

Add IKEA Tradfri On/Off E1743 Switch #1848

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion front/src/config/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,12 @@
"3": "Long click press",
"4": "Long click release",
"5": "Hold click",
"6": "Long click"
"6": "Long click",
"7": "On",
"8": "Off",
"9": "Brightness down",
"10": "Brightness up",
"11": "Brightness stop"
}
},
"opening-sensor": {
Expand Down
7 changes: 6 additions & 1 deletion front/src/config/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2148,7 +2148,12 @@
"3": "Pression clic long",
"4": "Relâche clic long",
"5": "Clic maintenu",
"6": "Clic long"
"6": "Clic long",
"7": "On",
"8": "Off",
"9": "Réduire luminosité",
"10": "Augmenter luminosité",
"11": "Stopper luminosité"
}
},
"opening-sensor": {
Expand Down
6 changes: 6 additions & 0 deletions server/services/zigbee2mqtt/exposes/enumType.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ addMapping('action', BUTTON_STATUS.CLICK, 'single');
addMapping('action', BUTTON_STATUS.DOUBLE_CLICK, 'double');
addMapping('action', BUTTON_STATUS.HOLD_CLICK, 'hold');
addMapping('action', BUTTON_STATUS.LONG_CLICK, 'long');
addMapping('action', BUTTON_STATUS.ON, 'on');
addMapping('action', BUTTON_STATUS.OFF, 'off');
addMapping('action', BUTTON_STATUS.BRIGHTNESS_MOVE_DOWN, 'brightness_move_down');
addMapping('action', BUTTON_STATUS.BRIGHTNESS_MOVE_UP, 'brightness_move_up');
addMapping('action', BUTTON_STATUS.BRIGHTNESS_STOP, 'brightness_stop');

addMapping('state', COVER_STATE.OPEN, 'OPEN');
addMapping('state', COVER_STATE.CLOSE, 'CLOSE');
addMapping('state', COVER_STATE.STOP, 'STOP');
Expand Down
132 changes: 131 additions & 1 deletion server/test/services/zigbee2mqtt/utils/convertDevice.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { assert } = require('chai');
const { assert, expect } = require('chai');
const { convertDevice } = require('../../../../services/zigbee2mqtt/utils/convertDevice');

const serviceId = '6a37dd9d-48c7-4d09-a7bb-33f257edb78d';
Expand Down Expand Up @@ -62,4 +62,134 @@ describe('zigbee2mqtt convertDevice', () => {
};
return assert.deepEqual(result, managedGladysDevice);
});
it('should return ikea E1743 device', () => {
const zigbee2mqttDevice = {
friendly_name: '0x5c0272fffxxxxx',
ieee_address: '0x5c0272fffeaxxxxx',
status: 'successful',
supported: true,
definition: {
description: 'TRADFRI ON/OFF switch',
exposes: [
{
access: 1,
description: 'Remaining battery in %',
name: 'battery',
property: 'battery',
type: 'numeric',
unit: '%',
value_max: 100,
value_min: 0,
},
{
access: 1,
description: 'Triggered action (e.g. a button click)',
name: 'action',
property: 'action',
type: 'enum',
values: ['on', 'off', 'brightness_move_down', 'brightness_move_up', 'brightness_stop'],
},
{
access: 1,
description: 'Link quality (signal strength)',
name: 'linkquality',
property: 'linkquality',
type: 'numeric',
unit: 'lqi',
value_max: 255,
value_min: 0,
},
],
model: 'E1743',
options: [
{
access: 2,
description:
'Set to false to disable the legacy integration (highly recommended), will change structure of the published payload (default true).',
name: 'legacy',
property: 'legacy',
type: 'binary',
value_off: false,
value_on: true,
},
{
description:
'Simulate a brightness value. If this device provides a brightness_move_up or brightness_move_down action it is possible to specify the update interval and delta.',
features: [
{
access: 2,
description: 'Delta per interval, 20 by default',
name: 'delta',
property: 'delta',
type: 'numeric',
value_min: 0,
},
{
access: 2,
description: 'Interval duration',
name: 'interval',
property: 'interval',
type: 'numeric',
unit: 'ms',
value_min: 0,
},
],
name: 'simulated_brightness',
property: 'simulated_brightness',
type: 'composite',
},
],
supports_ota: true,
vendor: 'IKEA',
},
};

const result = convertDevice(zigbee2mqttDevice, serviceId);

expect(result).to.deep.equal({
name: '0x5c0272fffxxxxx',
model: 'E1743',
external_id: 'zigbee2mqtt:0x5c0272fffxxxxx',
features: [
{
name: 'Battery',
read_only: true,
has_feedback: false,
min: 0,
max: 100,
category: 'battery',
type: 'integer',
unit: 'percent',
external_id: 'zigbee2mqtt:0x5c0272fffxxxxx:battery:integer:battery',
selector: 'zigbee2mqtt-0x5c0272fffxxxxx-battery-integer-battery',
},
{
name: 'Action',
read_only: true,
has_feedback: false,
min: 0,
max: 5,
category: 'button',
type: 'click',
unit: null,
external_id: 'zigbee2mqtt:0x5c0272fffxxxxx:button:click:action',
selector: 'zigbee2mqtt-0x5c0272fffxxxxx-button-click-action',
},
{
name: 'Linkquality',
read_only: true,
has_feedback: false,
min: 0,
max: 5,
category: 'signal',
type: 'integer',
unit: null,
external_id: 'zigbee2mqtt:0x5c0272fffxxxxx:signal:integer:linkquality',
selector: 'zigbee2mqtt-0x5c0272fffxxxxx-signal-integer-linkquality',
},
],
should_poll: false,
service_id: '6a37dd9d-48c7-4d09-a7bb-33f257edb78d',
});
});
});
5 changes: 5 additions & 0 deletions server/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const BUTTON_STATUS = {
LONG_CLICK_RELEASE: 4,
HOLD_CLICK: 5,
LONG_CLICK: 6,
ON: 7,
OFF: 8,
BRIGHTNESS_MOVE_DOWN: 9,
BRIGHTNESS_MOVE_UP: 10,
BRIGHTNESS_STOP: 11,
};

const COVER_STATE = {
Expand Down