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

Lumi.plug.mmeu01.part two improvement #1874

Merged
merged 12 commits into from Dec 8, 2020

Conversation

PeterVoronov
Copy link
Contributor

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

… 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
@PeterVoronov
Copy link
Contributor Author

Hello,
there is my second improvement for this plugs ...
Most useful things:
Consumer connected state and possibility to check, is power outage memory is set on or off.

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'),
Copy link
Owner

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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'),
Copy link
Owner

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted

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}`);
Copy link
Owner

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?

Copy link
Owner

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']});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

}
if (msg.data.hasOwnProperty('523')) {
// 0x020B
if (meta.logger) meta.logger.debug(`plug.mmeu01: attribute 523 (max_load) has value ${msg.data['523']}`);
Copy link
Owner

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.

Copy link
Contributor Author

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

@@ -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) {
Copy link
Owner

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

Copy link
Contributor Author

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 ;-)

@Koenkk
Copy link
Owner

Koenkk commented Dec 7, 2020

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
@PeterVoronov
Copy link
Contributor Author

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.

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
@PeterVoronov
Copy link
Contributor Author

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
@PeterVoronov
Copy link
Contributor Author

finally done ;-)
At least it all working for me ...

@Koenkk Koenkk merged commit e258710 into Koenkk:master Dec 8, 2020
@Koenkk
Copy link
Owner

Koenkk commented Dec 8, 2020

big thanks!

@Koenkk
Copy link
Owner

Koenkk commented Dec 8, 2020

@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

@PeterVoronov
Copy link
Contributor Author

@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.
There is listed a parameter for the power threshold , but i didn't saw a parameter for the timeout.

Koenkk added a commit that referenced this pull request Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants