Skip to content

Commit

Permalink
Use preset for power_outage_count
Browse files Browse the repository at this point in the history
  • Loading branch information
McGiverGim committed Mar 12, 2022
1 parent badc8e4 commit 7f7999c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
20 changes: 8 additions & 12 deletions devices/xiaomi.js
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ module.exports = [
fromZigbee: [fz.aqara_opple],
toZigbee: [tz.RTCZCGQ11LM_presence, tz.RTCZCGQ11LM_monitoring_mode, tz.RTCZCGQ11LM_approach_distance,
tz.aqara_motion_sensitivity, tz.RTCZCGQ11LM_reset_nopresence_status],
exposes: [e.presence().withAccess(ea.STATE_GET),
exposes: [e.presence().withAccess(ea.STATE_GET), e.power_outage_count(), e.temperature(),
exposes.enum('presence_event', ea.STATE, ['enter', 'leave', 'left_enter', 'right_leave', 'right_enter', 'left_leave',
'approach', 'away']).withDescription('Presence events: "enter", "leave", "left_enter", "right_leave", ' +
'"right_enter", "left_leave", "approach", "away"'),
Expand All @@ -925,8 +925,7 @@ module.exports = [
exposes.enum('motion_sensitivity', ea.ALL, ['low', 'medium', 'high']).withDescription('Different sensitivities ' +
'means different static human body recognition rate and response speed of occupied'),
exposes.enum('reset_nopresence_status', ea.SET, ['Reset']).withDescription('Reset the status of no presence'),
exposes.numeric('power_outage_count', ea.STATE).withDescription('Number of power outages (since last pairing)'),
e.temperature()],
],
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
await endpoint.read('aqaraOpple', [0x010c], {manufacturerCode: 0x115f});
Expand Down Expand Up @@ -1173,7 +1172,7 @@ module.exports = [
fromZigbee: [fz.aqara_opple],
toZigbee: [tz.JTBZ01AQA_gas, tz.JTBZ01AQA_gas_density, tz.JTBZ01AQA_gas_sensitivity, tz.JTBZ01AQA_selftest,
tz.JTBZ01AQA_mute_buzzer, tz.JTBZ01AQA_mute, tz.JTBZ01AQA_linkage_alarm, tz.JTBZ01AQA_state, tz.aqara_power_outage_count],
exposes: [e.gas().withAccess(ea.STATE_GET),
exposes: [e.gas().withAccess(ea.STATE_GET), e.power_outage_count().withAccess(ea.STATE_GET),
exposes.numeric('gas_density', ea.STATE_GET).withUnit('%LEL').withDescription('Value of gas concentration'),
exposes.enum('gas_sensitivity', ea.ALL, ['10%LEL', '15%LEL']).withDescription('Gas concentration value at which ' +
'an alarm is triggered ("10%LEL" is more sensitive than "15%LEL")'),
Expand All @@ -1186,8 +1185,8 @@ module.exports = [
exposes.binary('linkage_alarm', ea.ALL, true, false).withDescription('When this option is enabled and a gas leak ' +
'is detected, other detectors with this option enabled will also sound the alarm buzzer'),
exposes.binary('state', ea.STATE_GET, 'preparation', 'work').withDescription('"Preparation" or "work" ' +
'(measurement of the gas concentration value and triggering of an alarm are only performed in the "work" state)'),
exposes.numeric('power_outage_count', ea.STATE_GET).withDescription('Number of power outages (since last pairing)')],
'(measurement of the gas concentration value and triggering of an alarm are only performed in the "work" state)'),
],
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
await endpoint.read('aqaraOpple', [0x013a], {manufacturerCode: 0x115f});
Expand Down Expand Up @@ -1304,12 +1303,10 @@ module.exports = [
endpoint: (device) => {
return {'l1': 1, 'l2': 2};
},
exposes: [e.power().withAccess(ea.STATE_GET), e.energy(), e.temperature(), e.voltage().withAccess(ea.STATE), e.current(),
e.switch().withEndpoint('l1'), e.switch().withEndpoint('l2'),
exposes: [e.power().withAccess(ea.STATE_GET), e.energy(), e.temperature(), e.voltage(), e.current(),
e.switch().withEndpoint('l1'), e.switch().withEndpoint('l2'), e.power_outage_count(false),
exposes.binary('interlock', ea.STATE_SET, true, false)
.withDescription('Enabling prevents both relais being on at the same time'),
exposes.numeric('power_outage_count', ea.STATE)
.withDescription('Number of power outages'),
],
ota: ota.zigbeeOTA,
},
Expand Down Expand Up @@ -1484,9 +1481,8 @@ module.exports = [
// Ignore energy metering reports, rely on aqara_opple: https://github.com/Koenkk/zigbee2mqtt/issues/10709
fromZigbee: [fz.on_off, fz.device_temperature, fz.aqara_opple, fz.ignore_metering, fz.ignore_electrical_measurement,
fz.xiaomi_power],
exposes: [e.switch(), e.energy(), e.power(), e.device_temperature(), e.power_outage_memory(), e.switch_type(),
exposes: [e.switch(), e.energy(), e.power(), e.device_temperature(), e.power_outage_memory(), e.power_outage_count(), e.switch_type(),
e.voltage(), e.temperature(), e.current(),
exposes.numeric('power_outage_count', ea.STATE).withDescription('Number of power outages (since last pairing)'),
],
toZigbee: [tz.xiaomi_switch_type, tz.on_off, tz.xiaomi_switch_power_outage_memory, tz.xiaomi_led_disabled_night],
configure: async (device, coordinatorEndpoint, logger) => {
Expand Down
1 change: 1 addition & 0 deletions lib/exposes.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ module.exports = {
position: () => new Numeric('position', access.STATE).withUnit('%').withDescription('Position'),
power: () => new Numeric('power', access.STATE).withUnit('W').withDescription('Instantaneous measured power'),
power_on_behavior: () => new Enum('power_on_behavior', access.ALL, ['off', 'previous', 'on']).withDescription('Controls the behavior when the device is powered on'),
power_outage_count: (resetsWhenPairing = true) => new Numeric('power_outage_count', access.STATE).withDescription('Number of power outages' + (resetsWhenPairing ? ' (since last pairing)' : '')),
power_outage_memory: () => new Binary('power_outage_memory', access.ALL, true, false).withDescription('Enable/disable the power outage memory, this recovers the on/off mode after power failure'),
presence: () => new Binary('presence', access.STATE, true, false).withDescription('Indicates whether the device detected presence'),
pressure: () => new Numeric('pressure', access.STATE).withUnit('hPa').withDescription('The measured atmospheric pressure'),
Expand Down

0 comments on commit 7f7999c

Please sign in to comment.