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
Lumi.plug.mmeu01.part two improvement #1874
Conversation
… functionality of lumi.plug.mmeu01, i.e. ZNCZ04LM: New states: auto_off - auto off state, to swith the plug off in case of low level of consumption; consumer_connected - show the status of connection of the customer to the plug; led_disabled - show the state of the led disable feature; power_outage_memory - show the state of power outage memory feature; New switches: auto_off - auto off feature, to swith the plug off in case of low level of consumption; led_disabled - feature to set led disabled; power_outage_memory - feature to set power outage memory enabled or disabled; Changes to be committed: modified: converters/fromZigbee.js modified: converters/toZigbee.js modified: devices.js modified: lib/exposes.js
Some description of a states tunig Changes to be committed: modified: lib/exposes.js
Hello, |
lib/exposes.js
Outdated
@@ -303,12 +303,14 @@ module.exports = { | |||
presets: { | |||
action: (values) => new Enum('action', access.STATE, values).withDescription('Triggered action (e.g. a button click)'), | |||
aqi: () => new Numeric('aqi', access.STATE).withDescription('Air quality index'), | |||
auto_off: () => new Binary('auto_off', access.STATE, true, false).withDescription('Indicates whether the device has auto off with low consumer load functionality enabled or not'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
access should be access.STATE_SET
here (since you can set it via toZigbee), same goes for power_outage_memory
and led_disabled
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me, if I'm wrong, but I understand this way:
STATE_SET - only for set
STATE_GET - only for get
STATE - for both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I have more strategical question:
Should be such states not binary, but like a switch - literally "on/off' ?
lib/exposes.js
Outdated
@@ -325,6 +327,7 @@ module.exports = { | |||
illuminance: () => new Numeric('illuminance', access.STATE).withDescription('Raw measured illuminance'), | |||
illuminance_lux: () => new Numeric('illuminance_lux', access.STATE).withUnit('lx').withDescription('Measured illuminance in lux'), | |||
keypad_lockout: () => new Lock().withState('keypad_lockout', '1', '0', 'Enables/disables physical input on the device'), | |||
led_disabled: () => new Binary('led_disabled', access.STATE, true, false).withDescription('Indicates whether the device has LED disable at night state or not'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should rename this to led_disabled_night
because led_disabled
makes me think the led is always disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accepted
converters/fromZigbee.js
Outdated
default: | ||
// if (meta.logger) meta.logger.debug(`plug.mmeu01: unknown index $(index) with value ${value}`); | ||
} | ||
if (meta.logger) meta.logger.debug(`plug.mmeu01: recorded index ${index} with value ${value}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should always log here. maybe only in default case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same goes for all logging below e.g. if (meta.logger) meta.logger.debug(
plug.mmeu01: attr. 513 (pwr_out_mem) has value ${msg.data['513']});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
converters/fromZigbee.js
Outdated
} | ||
if (msg.data.hasOwnProperty('523')) { | ||
// 0x020B | ||
if (meta.logger) meta.logger.debug(`plug.mmeu01: attribute 523 (max_load) has value ${msg.data['523']}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing is set in the payload here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's for detecting, but ok, will add
converters/fromZigbee.js
Outdated
@@ -1643,20 +1643,62 @@ const converters = { | |||
default: | |||
// if (meta.logger) meta.logger.debug(`plug.mmeu01: unknown vtype=${data[i+1]}, pos=${i+1}`); | |||
} | |||
payload[index] = value; | |||
// if (meta.logger) meta.logger.debug(`plug.mmeu01: recorded index ${index} with value ${value}`); | |||
switch (index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should compact this code with if else. e.g.
if (index === 3) payload.temperature = calibrateAndPrecisionRoundOptions(value, options, 'temperature');
else if (index === 100) payload.state = value === 1 ? 'ON' : 'OFF';
etc...
Sames goes for all if's here: https://github.com/Koenkk/zigbee-herdsman-converters/pull/1874/files#diff-b676ab0df4d49b8572967cb4c92a2dc6264091131f6b1828ca13d0f9656e367aR1677
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not see a big difference, but - as you wish ;-)
Put some comments, but would like to thank you a lot, personally I'm very interested in the auto_off function as I have my kettle connected to this device. |
- removed extra logging; - led_disabled renamed to led-disabled_night; - added previously empty ppayload - consumer_overload Changes to be committed: modified: converters/fromZigbee.js modified: converters/toZigbee.js modified: devices.js modified: lib/exposes.js
Thanks and You are welcome ;-) |
Changed access.STATE to access.STATE_SET for changable states: - auto_off - power_outage_memory - led_disabled_night Changes to be committed: modified: lib/exposes.js
Done |
In fact it is a value of W, not a boolean one Changes to be committed: modified: converters/fromZigbee.js modified: lib/exposes.js
finally done ;-) |
big thanks! |
@PeterVoronov how does the auto_off work? I've tested with a kettle but the plug does not automatically turn off once the water is cooked (checked that the power is 0). The power outage works correctly |
In my case it switched off after 20 minutes after I set the auto_off on a system without load. |
Extending functionality for lumi.plug.mmeu01, i.e. ZNCZ04LM:
New states:
auto_off - auto off state, to switch the plug off in case of low level of consumption (< 2.6 W);
consumer_connected - show the status of connection of the consume device(s) to the plug;
led_disabled - show the state of the led disable at night feature;
power_outage_memory - show the state of power outage memory feature;
New switches:
auto_off - auto off feature, to switch the plug off in case of low level of consumption (<2.6 W);
led_disabled - feature to set led disabled at night;
Changes to be committed:
modified: converters/fromZigbee.js
modified: converters/toZigbee.js
modified: devices.js
modified: lib/exposes.js