Skip to content

Commit 5878e48

Browse files
authored
Merge pull request #302 from tim-hellhake/extend-switch-support
Extend switch support
2 parents 2c0563f + 0ee5fac commit 5878e48

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/zigbee2mqtt/zigbee2mqtt-device.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -274,19 +274,19 @@ export class Zigbee2MqttDevice extends Device {
274274

275275
const additionalProperties: Record<string, unknown> = {};
276276

277-
switch (value) {
278-
case 'single':
279-
additionalProperties['@type'] = 'PressedEvent';
280-
isPushbutton = true;
281-
break;
282-
case 'double':
283-
additionalProperties['@type'] = 'DoublePressedEvent';
284-
isPushbutton = true;
285-
break;
286-
case 'release':
287-
additionalProperties['@type'] = 'LongPressedEvent';
288-
isPushbutton = true;
289-
break;
277+
if (value.indexOf('single') > -1 || value === 'on' || value === 'toggle') {
278+
additionalProperties['@type'] = 'PressedEvent';
279+
isPushbutton = true;
280+
}
281+
282+
if (value.indexOf('double') > -1) {
283+
additionalProperties['@type'] = 'DoublePressedEvent';
284+
isPushbutton = true;
285+
}
286+
287+
if (value.indexOf('release') > -1) {
288+
additionalProperties['@type'] = 'LongPressedEvent';
289+
isPushbutton = true;
290290
}
291291

292292
this.addEvent(value, {

0 commit comments

Comments
 (0)