Skip to content

Commit

Permalink
Support more features for Xiaomi WS-USC03 (#5770)
Browse files Browse the repository at this point in the history
* update Xiaomi (Aqara) WS-USC03 to expose power, energy, device temperature, power outage memory, operation mode, flip indicator light, etc.

* fix lint errors for devices/xiaomi.js

* Update xiaomi.js

* Update xiaomi.js

---------

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
  • Loading branch information
tmkhoa and Koenkk authored May 21, 2023
1 parent 83aa82b commit 70f7c2d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/converters/toZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -2280,8 +2280,8 @@ const converters = {
convertSet: async (entity, key, value, meta) => {
if (['SP-EUC01', 'ZNCZ04LM', 'ZNCZ12LM', 'ZNCZ15LM', 'QBCZ14LM', 'QBCZ15LM', 'SSM-U01', 'SSM-U02', 'DLKZMK11LM', 'DLKZMK12LM',
'WS-EUK01', 'WS-EUK02', 'WS-EUK03', 'WS-EUK04', 'QBKG19LM', 'QBKG20LM', 'QBKG25LM', 'QBKG26LM', 'QBKG28LM', 'QBKG29LM',
'QBKG31LM', 'QBKG34LM', 'QBKG38LM', 'QBKG39LM', 'QBKG40LM', 'QBKG41LM', 'ZNDDMK11LM', 'ZNLDP13LM',
'WS-USC02', 'WS-USC04', 'ZNQBKG31LM',
'QBKG31LM', 'QBKG34LM', 'QBKG38LM', 'QBKG39LM', 'QBKG40LM', 'QBKG41LM', 'ZNDDMK11LM', 'ZNLDP13LM', 'ZNQBKG31LM',
'WS-USC02', 'WS-USC03', 'WS-USC04',
].includes(meta.mapped.model)) {
await entity.write('aqaraOpple', {0x0201: {value: value ? 1 : 0, type: 0x10}}, manufacturerOptions.xiaomi);
} else if (['ZNCZ02LM', 'QBCZ11LM', 'LLKZMK11LM'].includes(meta.mapped.model)) {
Expand All @@ -2305,8 +2305,8 @@ const converters = {
convertGet: async (entity, key, meta) => {
if (['SP-EUC01', 'ZNCZ04LM', 'ZNCZ12LM', 'ZNCZ15LM', 'QBCZ14LM', 'QBCZ15LM', 'SSM-U01', 'SSM-U02', 'DLKZMK11LM', 'DLKZMK12LM',
'WS-EUK01', 'WS-EUK02', 'WS-EUK03', 'WS-EUK04', 'QBKG19LM', 'QBKG20LM', 'QBKG25LM', 'QBKG26LM', 'QBKG28LM', 'QBKG29LM',
'QBKG31LM', 'QBKG34LM', 'QBKG38LM', 'QBKG39LM', 'QBKG40LM', 'QBKG41LM', 'ZNDDMK11LM', 'ZNLDP13LM',
'WS-USC02', 'WS-USC04', 'ZNQBKG31LM',
'QBKG31LM', 'QBKG34LM', 'QBKG38LM', 'QBKG39LM', 'QBKG40LM', 'QBKG41LM', 'ZNDDMK11LM', 'ZNLDP13LM', 'ZNQBKG31LM',
'WS-USC02', 'WS-USC03', 'WS-USC04',
].includes(meta.mapped.model)) {
await entity.read('aqaraOpple', [0x0201]);
} else if (['ZNCZ02LM', 'QBCZ11LM', 'ZNCZ11LM'].includes(meta.mapped.model)) {
Expand Down
16 changes: 12 additions & 4 deletions src/devices/xiaomi.js
Original file line number Diff line number Diff line change
Expand Up @@ -1026,11 +1026,19 @@ module.exports = [
model: 'WS-USC03',
vendor: 'Xiaomi',
description: 'Aqara smart wall switch (neutral, single rocker)',
extend: extend.switch(),
fromZigbee: [fz.on_off, fz.xiaomi_power, fz.aqara_opple],
toZigbee: [tz.on_off, tz.xiaomi_power, tz.xiaomi_switch_operation_mode_opple, tz.xiaomi_switch_power_outage_memory,
tz.xiaomi_flip_indicator_light],
exposes: [e.switch(), e.action(['single', 'double']), e.flip_indicator_light(), e.power_outage_count(),
e.device_temperature().withAccess(ea.STATE),
e.power().withAccess(ea.STATE_GET), e.energy(), e.voltage(), e.power_outage_memory(),
exposes.enum('operation_mode', ea.ALL, ['control_relay', 'decoupled'])
.withDescription('Decoupled mode')],
onEvent: preventReset,
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff']);
await reporting.onOff(endpoint);
const endpoint1 = device.getEndpoint(1);
// set "event" mode
await endpoint1.write('aqaraOpple', {'mode': 1}, {manufacturerCode: 0x115f, disableResponse: true});
},
ota: ota.zigbeeOTA,
},
Expand Down

0 comments on commit 70f7c2d

Please sign in to comment.