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

Add power outage count to LLKZMK11LM and SSM-U01 #3972

Merged
merged 3 commits into from
Mar 12, 2022

Conversation

McGiverGim
Copy link
Contributor

Adds the power outage count field to the LLKZMK11LM and SSM-U01 devices.

lib/xiaomi.js Outdated
@@ -160,7 +160,7 @@ const numericAttributes2Payload = (msg, meta, model, options, dataObject) => {
payload.mode_switch = {4: 'anti_flicker_mode', 1: 'quick_mode'}[value];
break;
case '5':
if (['JT-BZ-01AQ/A', 'RTCZCGQ11LM'].includes(model.model)) {
if (['JT-BZ-01AQ/A', 'LLKZMK11LM', 'RTCZCGQ11LM', 'SSM-U01'].includes(model.model)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm pretty sure the major part (if not all) the devices of Xiaomi with a field 5 use it for power_outage_count. Maybe is better to simply remove the condition and let it for all waiting for some complains if any?

Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I noticed, this parameter applies only to devices with stationary power supply, so if you remove the filter by models, then it seems to me that you need to add a filter by power source.

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 exactly, only if the device publishes a "5" attribute. Do you know if some battery device publishes it?

Copy link
Contributor

@Otnow Otnow Mar 9, 2022

Choose a reason for hiding this comment

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

Not exactly, only if the device publishes a "5" attribute.

Of course, only if the device publishes a "5" attribute.

Do you know if some battery device publishes it?

So far I haven't come across any.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know if some battery device publishes it?

I'm sorry, but my previous answer is not correct, because I didn't understand the question correctly.

I have 3 battery-powered devices that publishes a "5" attribute, but at the same time it is clearly not the value of power_outage_count, but something else:

  • WSDCGQ12LM

    lumi.sensor_ht.agl02: unknown index 1 with value 3035
    lumi.sensor_ht.agl02: unknown index 3 with value 22
    lumi.sensor_ht.agl02: unknown index 4 with value 424
    lumi.sensor_ht.agl02: unknown index 5 with value 36
    lumi.sensor_ht.agl02: unknown index 6 with value 11
    lumi.sensor_ht.agl02: unknown index 8 with value 284
    lumi.sensor_ht.agl02: unknown index 10 with value 0
    lumi.sensor_ht.agl02: unknown index 12 with value 1
    lumi.sensor_ht.agl02: unknown index 100 with value 2270
    lumi.sensor_ht.agl02: unknown index 101 with value 2098
    lumi.sensor_ht.agl02: unknown index 102 with value 1001
  • RTCGQ12LM

    lumi.motion.agl02: unknown index 1 with value 3060
    lumi.motion.agl02: unknown index 3 with value 25
    lumi.motion.agl02: unknown index 4 with value 424
    lumi.motion.agl02: unknown index 5 with value 776
    lumi.motion.agl02: unknown index 6 with value 19
    lumi.motion.agl02: unknown index 8 with value 291
    lumi.motion.agl02: unknown index 10 with value 0
    lumi.motion.agl02: unknown index 12 with value 1
    lumi.motion.agl02: unknown index 100 with value 0
    lumi.motion.agl02: unknown index 101 with value 2
    lumi.motion.agl02: unknown index 102 with value 3
    lumi.motion.agl02: unknown index 103 with value 1
    lumi.motion.agl02: unknown index 104 with value 168
  • RTCGQ13LM

    lumi.motion.agl04: unknown index 1 with value 3112
    lumi.motion.agl04: unknown index 3 with value 25
    lumi.motion.agl04: unknown index 4 with value 424
    lumi.motion.agl04: unknown index 5 with value 491
    lumi.motion.agl04: unknown index 6 with value 15
    lumi.motion.agl04: unknown index 8 with value 282
    lumi.motion.agl04: unknown index 10 with value 0
    lumi.motion.agl04: unknown index 12 with value 1
    lumi.motion.agl04: unknown index 100 with value 0
    lumi.motion.agl04: unknown index 101 with value 0
    lumi.motion.agl04: unknown index 102 with value 3
    lumi.motion.agl04: unknown index 103 with value 1
    lumi.motion.agl04: unknown index 104 with value 168
    lumi.motion.agl04: unknown index 105 with value 2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Koenkk don't merge this. It seems is not working. Wait please to let me do more tests.

Copy link
Owner

Choose a reason for hiding this comment

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

Ok will wait, can you also add power_outage_count expose to more devices?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, the correct one was if (meta.device.powerSource === 'DC Source').

I'm sorry but I don't have more devices with DC Source to test them. But it you or @Otnow can point me to some of them I will add it. My idea was to wait to reports of "state" with the value to add them in the future.

Copy link
Contributor Author

@McGiverGim McGiverGim Mar 10, 2022

Choose a reason for hiding this comment

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

I suspect that the devices that use the aqara_opple converter will have it. But I can't confirm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Koenkk It seems some devices use the DC Source like LLKZMK11LM and others the Mains (single phase) like the SSM-U01. I have let both finally.

@McGiverGim McGiverGim force-pushed the add_power_outage_count_xiaomi branch 2 times, most recently from 01e5b2e to 42aff4a Compare March 10, 2022 21:02
.withDescription('Enabling prevents both relais being on at the same time')],
.withDescription('Enabling prevents both relais being on at the same time'),
exposes.numeric('power_outage_count', ea.STATE)
.withDescription('Number of power outages (since last pairing)'),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another thing I've observed is that the number of outages does not return to zero when pairing for LLKZMK11LM. It returns to zero for SSM-U01. So I think I will change this message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Message changed.

@Koenkk maybe is better to add a new preset for this, like this:

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'),

With a text that does not specify if it returns to zero or not when pairing or with a parameter that changes the text? There are a more devices that have this attribute.

Copy link
Owner

Choose a reason for hiding this comment

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

Good idea!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added new commit with the preset.

@McGiverGim McGiverGim force-pushed the add_power_outage_count_xiaomi branch from 42aff4a to 57fbcb2 Compare March 11, 2022 11:44
@McGiverGim McGiverGim force-pushed the add_power_outage_count_xiaomi branch 2 times, most recently from 7f7999c to 73ff146 Compare March 12, 2022 07:56
@McGiverGim McGiverGim force-pushed the add_power_outage_count_xiaomi branch from 73ff146 to ca5a8fc Compare March 12, 2022 07:58
@McGiverGim
Copy link
Contributor Author

I think this is now ready to be merged, except if someone can point me some other devices that publish the power_outage_count attribute. In this way I will add the expose.

@Koenkk Koenkk merged commit 038311e into Koenkk:master Mar 12, 2022
@Koenkk
Copy link
Owner

Koenkk commented Mar 12, 2022

thanks!

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.

3 participants