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

Child lock and Filter life don't work in 2H and Pro H #229

Open
torifat opened this issue Nov 21, 2021 · 19 comments
Open

Child lock and Filter life don't work in 2H and Pro H #229

torifat opened this issue Nov 21, 2021 · 19 comments
Labels
bug Something isn't working

Comments

@torifat
Copy link
Owner

torifat commented Nov 21, 2021

Child lock and Filter life don't work in 2H and Pro H. They throw Cannot read properties of undefined (reading 'value').

20/11/2021, 19:08:09] [homebridge-xiaomi-mi-air-purifier] This plugin threw an error from the characteristic 'Lock Physical Controls': Unhandled error thrown inside read handler for characteristic: Cannot read properties of undefined (reading 'value'). See https://git.io/JtMGR for more info.
[20/11/2021, 19:08:09] [homebridge-xiaomi-mi-air-purifier] This plugin threw an error from the characteristic 'Filter Life Level': Unhandled error thrown inside read handler for characteristic: Cannot read properties of undefined (reading 'value'). See https://git.io/JtMGR for more info.
[20/11/2021, 19:08:09] [homebridge-xiaomi-mi-air-purifier] This plugin threw an error from the characteristic 'Filter Change Indication': Unhandled error thrown inside read handler for characteristic: Cannot read properties of undefined (reading 'value'). See https://git.io/JtMGR for more info.

Version is homebridge-xiaomi-mi-air-purifier v2.0.0
NPM 8.1.4
Node 16.13

Affected Devices

  • Xiaomi Air Purifier 2H
  • Xiaomi Air Purifier 2S
  • Xiaomi Air Purifier Pro H

Reported by @Dane03 in #226 (comment)
Reported by @guesq in #226 (comment)

@torifat torifat added the bug Something isn't working label Nov 21, 2021
This was referenced Nov 22, 2021
@torifat
Copy link
Owner Author

torifat commented Nov 22, 2021

I need some volunteers to test 2* and Pro devices. I don't own those devices, so it's tough for me to test.

@luluhoc
Copy link

luluhoc commented Nov 22, 2021

@torifat made a pull request #233

@torifat
Copy link
Owner Author

torifat commented Nov 23, 2021

Thanks, @luluhoc. Can you please share the output of the following code snippet?

require('miio')
  .device({
    address: "?.?.?.?",
    token: "YOUR_TOKEN",
  })
  .then(console.log);

It should output something like:

MiioDevice {
  model=zhimi.airpurifier.mb3,
  types=miio:air-purifier, sensor, miio, air-purifier,
  capabilities=fan-speed, miio:led-brightness, pm2.5, relative-humidity, temperature, switchable-mode, mode, switchable-power, restorable-state, power, state
}

⚠️ If it spits out any private information please remove it before sharing.

@guesq
Copy link

guesq commented Nov 23, 2021

Thanks, @luluhoc. Can you please share the output of the following code snippet?

require('miio')
  .device({
    address: "?.?.?.?",
    token: "YOUR_TOKEN",
  })
  .then(console.log);

It should output something like:

MiioDevice {
  model=zhimi.airpurifier.mb3,
  types=miio:air-purifier, sensor, miio, air-purifier,
  capabilities=fan-speed, miio:led-brightness, pm2.5, relative-humidity, temperature, switchable-mode, mode, switchable-power, restorable-state, power, state
}

⚠️ If it spits out any private information please remove it before sharing.

@torifat, this is the output of my device. Looks like my device is Air Purifier 2. I thought it was 2H. Sorry for the misinformation.

MiioDevice {
  model=zhimi.airpurifier.m1,
  types=miio:air-purifier, sensor, miio, air-purifier,
  capabilities=miio:buzzer, miio:led-brightness, miio:switchable-led, pm2.5, relative-humidity, temperature, switchable-mode, mode, switchable-power, restorable-state, power, state
}

@torifat
Copy link
Owner Author

torifat commented Nov 23, 2021

Thank you, this will help me a lot.

@cbrunnkvist
Copy link
Contributor

cbrunnkvist commented Nov 23, 2021

@torifat This is the 2S:

MiioDevice {
  model=zhimi.airpurifier.ma2,
  types=miio:air-purifier, sensor, miio, air-purifier,
  capabilities=miio:buzzer, miio:led-brightness, miio:switchable-led, pm2.5, relative-humidity, temperature, switchable-mode, mode, switchable-power, restorable-state, power, state
}

(edit: relevant to #10)
Are you saying there differences depending on which version of the miio NPM module is installed?

@torifat
Copy link
Owner Author

torifat commented Nov 23, 2021

@cbrunnkvist 2* & 3* devices use different method and property names. In my fork, I'm trying to make them same. For example this - torifat/miio@856110e. However, my end goal is to move to https://github.com/maxinminax/node-mihome.

@luluhoc
Copy link

luluhoc commented Nov 23, 2021

Thanks, @luluhoc. Can you please share the output of the following code snippet?

require('miio')
  .device({
    address: "?.?.?.?",
    token: "YOUR_TOKEN",
  })
  .then(console.log);

It should output something like:

MiioDevice {
  model=zhimi.airpurifier.mb3,
  types=miio:air-purifier, sensor, miio, air-purifier,
  capabilities=fan-speed, miio:led-brightness, pm2.5, relative-humidity, temperature, switchable-mode, mode, switchable-power, restorable-state, power, state
}

⚠️ If it spits out any private information please remove it before sharing.

I will give you later, I can open another PR if you want i can leave your old properties and just add conditional if model is PRO

also check this out this guy listed all properties https://github.com/syssi/xiaomi_airpurifier

@torifat
Copy link
Owner Author

torifat commented Nov 23, 2021

Can you folks try the new version 2.0.1 and see if it fixes your problem.

also check this out this guy listed all properties https://github.com/syssi/xiaomi_airpurifier

@luluhoc Thanks, but I don't actually need those. Xiaomi has an official API that gives you those. I'm asking you folks to run it to see what miio library gives us, not what is supported.

@luluhoc
Copy link

luluhoc commented Nov 23, 2021

Can you folks try the new version 2.0.1 and see if it fixes your problem.

also check this out this guy listed all properties https://github.com/syssi/xiaomi_airpurifier

@luluhoc Thanks, but I don't actually need those. Xiaomi has an official API that gives you those. I'm asking you folks to run it to see what miio library gives us, not what is supported.

I will try it later when I'll get home from work :)

@guesq
Copy link

guesq commented Nov 23, 2021

Can you folks try the new version 2.0.1 and see if it fixes your problem.

also check this out this guy listed all properties https://github.com/syssi/xiaomi_airpurifier

@luluhoc Thanks, but I don't actually need those. Xiaomi has an official API that gives you those. I'm asking you folks to run it to see what miio library gives us, not what is supported.

@torifat Thanks for your effort.
There are no error messages when starting Homebridge now.
The values of Filter Life Level and Filter Change Indication should be correct.
Filter Life Level

But when Fan speed is enabled and I'm trying to adjust the fan speed in Home app, I get the following errors:

[homebridge-xiaomi-mi-air-purifier] This plugin threw an error from the characteristic 'Rotation Speed': Unhandled error thrown inside write handler for characteristic: Mode `none` not supported. See https://git.io/JtMGR for more info.

When Child Lock is enabled and switched on or off in Home app, I get the following errors:

[homebridge-xiaomi-mi-air-purifier] This plugin threw an error from the characteristic 'Lock Physical Controls': Unhandled error thrown inside write handler for characteristic: device.changeChildLock is not a function. See https://git.io/JtMGR for more info.

@torifat
Copy link
Owner Author

torifat commented Nov 23, 2021

Thanks @guesq, that's quite helpful. I will fix both of those issues soon.

@cbrunnkvist
Copy link
Contributor

Confirmed on 2S it doesn't spam logs anymore now 👍 , also power switch works fine. And if I enable speed control, it logs the same exception as @guesq's on changing its value:

2021-11-24, 4:24:19 PM { speed: 65 }
2021-11-24, 4:24:19 PM [Raspberry-HOOBS 1F84@Air Purifier 2S@Air Purifier 2S@Rotation Speed] Unhandled error thrown inside write handler for characteristic: Mode `none` not supported

@cbrunnkvist
Copy link
Contributor

cbrunnkvist commented Nov 24, 2021

An observation: at first sight it is a little bit ambiguous as to what should actually happen when you adjust Fan Speed because in the Mi Home app, (-for the 2S at least-), in two (🅰️Auto and 🌙Night) out of its three possible operating modes, there is no fan speed slider shown. Only the third mode (🖤Manual) lets the user pick a constant speed.

In the (Apple-)Home app however, the slider is shown all the time. However, in the other older plugins, while the Fan Speed is always visible, touching actually has the side effect of instantly throwing the device into Manual mode, which actually makes a lot of sense then. 🙂

@torifat
Copy link
Owner Author

torifat commented Dec 3, 2021

@guesq and @cbrunnkvist I just released a new version homebridge-xiaomi-mi-air-purifier@2.0.2. Can you folks please check if it fixes the fan speed and child lock problem 🙏🏽.

@guesq
Copy link

guesq commented Dec 3, 2021

@guesq and @cbrunnkvist I just released a new version homebridge-xiaomi-mi-air-purifier@2.0.2. Can you folks please check if it fixes the fan speed and child lock problem 🙏🏽.

@torifat Tested. While adjusting Fan Speed, the following messages show in logs:

MiioDevice {
  model=zhimi.airpurifier.m1,
  types=miio:air-purifier, sensor, miio, air-purifier,
  capabilities=fan-speed, miio:buzzer, miio:led-brightness, miio:switchable-led, pm2.5, relative-humidity, temperature, switchable-mode, mode, switchable-power, restorable-state, power, state
}
[12/4/2021, 6:30:30 AM] [homebridge-xiaomi-mi-air-purifier] This plugin threw an error from the characteristic 'Rotation Speed': Unhandled error thrown inside write handler for characteristic: device.changeFanSpeed is not a function. See https://git.io/JtMGR for more info.

While Child Lock is switched, the following messages show in logs:

[12/4/2021, 6:32:01 AM] [homebridge-xiaomi-mi-air-purifier] This plugin threw an error from the characteristic 'Lock Physical Controls': Unhandled error thrown inside write handler for characteristic: . See https://git.io/JtMGR 

@XaXBullen
Copy link

XaXBullen commented Dec 4, 2021

@guesq and @cbrunnkvist I just released a new version homebridge-xiaomi-mi-air-purifier@2.0.2. Can you folks please check if it fixes the fan speed and child lock problem 🙏🏽.

Still 2.0.1 listed as the newest version in Hoobs!

Now it was showing up in Hoobs, 2.0.2 installed. Now it don’t even show the Fan speed control in HomeKit even if it is on in Hoobs. 🤔

@Hawksama
Copy link

[21/12/2021, 06:50:24] [homebridge-xiaomi-mi-air-purifier] This plugin threw an error from the characteristic 'Active': Unhandled error thrown inside write handler for characteristic: device.power is not a function. See https://git.io/JtMGR for more info. MiioDevice { model=zhimi.airp.mb3a, types=miio, capabilities= }

@Moskvitch
Copy link

Moskvitch commented Jan 19, 2022

First of all, a big thank you very much for this.
I installed the latest 2.0.2, but as many have noted trying to use the fan speed slider results in the same following error, on either model MC1 or MA2:
Thanks again for looking into this.

MiioDevice {
model=zhimi.airpurifier.mc1,
types=miio:air-purifier, sensor, miio, air-purifier,
capabilities=fan-speed, miio:buzzer, miio:led-brightness, miio:switchable-led, pm2.5, relative-humidity, temperature, switchable-mode, mode, switchable-power, restorable-state, power, state
}
[1/19/2022, 9:47:30 PM] [homebridge-xiaomi-mi-air-purifier] This plugin threw an error from the characteristic 'Rotation Speed': Unhandled error thrown inside write handler for characteristic: device.changeFanSpeed is not a function. See https://git.io/JtMGR for more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants