pschroeder89 / homebridge-levoit-humidifiers

Levoit Humidifiers Plugin for Apple HomeKit via Homebridge
Apache License 2.0
68 stars 9 forks source link

Night Mode #10

Closed Holydevil66 closed 2 years ago

Holydevil66 commented 2 years ago

Great and sleek plugin, good job 👍 I’m just missing the night mode, maybe as a separate switch, to turn off the display within automations. Is such an implementation possible?

jordanwmcdonald commented 2 years ago

Thanks for this plugin! I second this enhancement request. I'm not sure exactly how the VeSync app handles it natively - it appears to wake the humidifer screen briefly for any changes made from the VeSync app, but then after a few seconds the humidifier screen turns off again.

pschroeder89 commented 2 years ago

Definitely possible. I will add this sometime this week.

pschroeder89 commented 2 years ago

Hi @Holydevil66 @afroeagle, I've added a switch for Sleep / Night Mode in 1.5.0-beta3. Would you mind testing it out when you can? You will probably need to clear your device cache in Homebridge, first. Thanks!

jordanwmcdonald commented 2 years ago

Hey @pschroeder89 thanks for the update! I was actually messing around with 1.5.0-beta1 when it first dropped. Here's my situation:

  1. I tried clearing the cache for that specific Humidifier Classic 300, but couldn't get it to fully work (I could control the night light, display on/off, and the unit on/off, but couldn't set the humidity and get it to work on Auto.
  2. I took the nuclear option and removed the configuration for your Plugin, rebooted Homebridge, removed the Plugin entirely, rebooted Homebridge, and reinstalled and configured your Plugin from scratch.
  3. I can't get it to work at all now (device shows as 'No Response' in Home.app) and get this error when I attempt to modify any and every setting (the 'characteristic' changes, of course):
[2/3/2022, 10:22:17 PM] [homebridge-levoit-humidifiers] This plugin threw an error from the characteristic 'Brightness': Unhandled error thrown inside write handler for characteristic: Converting circular structure to JSON
    --> starting at object with constructor 'ClientRequest'
    |     property 'socket' -> object with constructor 'TLSSocket'
    --- property '_httpMessage' closes the circle. See https://git.io/JtMGR for more info.
pschroeder89 commented 2 years ago

Just a heads up that Auto will not respect the humidity slider unfortunately. You need to be on Manual for the Humidity slider value to apply. With that being said, beta1 had some other problems. From the Homebridge side, I don’t think there is a way to have the slider do anything when in Auto mode.

As for the circular JSON error, the plug-in is up to date and you’re seeing this issue? Are you sure your credentials are correct in the config file?

Either way, I’ll add some logic to print a better message.

Let me know if the config looks good…if so, I’ll take a deeper look tomorrow.

jordanwmcdonald commented 2 years ago

Thanks for your hard work. So does this mean that it will function in an automatic fashion when set to Manual in Homebridge? Or that I need to configure automations in the Home.app to mimic native Auto mode?

The config file looks good.

Here are screenshots of the current operating state in native app and Home.app.

image

image

pschroeder89 commented 2 years ago

Hey @afroeagle, I made some adjustments due to your feedback, and the general confusion people have had around Auto / Manual modes. I've been wanting to improve this aspect for a while, so I'm glad I was able to get to it.

I spent a lot of time trying to understand why HomeKit will sometimes put those nice display names under the accessories, and found that if you have 4 accessories, it will add them. If you have less or more, it doesn't. So the new implementation is missing the descriptions underneath because we now have 5 services / accessories.

The 5 accessories are:

  1. Target Humidity

    • Sets humidifier to Auto and sets the Target Humidity to the desired level.
  2. Mist Level

    • Sets humidifier to Manual and sets the Mist Level to the desired level.
  3. Sleep Mode

    • This switches the device between Sleep Mode (On) and Auto Mode (Off)
    • Sleep Mode Target Humidity is controlled by the Target Humidity slider, too.
  4. Night Light

  5. Display Toggle

services2 services manual auto

I've tested these features and they appear to work as expected. I'd really appreciate it if you could do some testing, too. The beta is 1.5.0-beta5. I've also improved some logging that might help with the error you described earlier.

Holydevil66 commented 2 years ago

Well done :) I have installed the actual 1.5.0-beta5 after clearing the device cache, works pretty well and as expected after having split the device to single accessories. The only caveat I noticed and that also occurred in previous versions of the plugin, is the home bridge warning about the plugin slowing it down:

[5.2.2022, 11:43:55] [homebridge-levoit-humidifiers] This plugin slows down Homebridge. The read handler for the characteristic 'Current Relative Humidity' was slow to respond! See https://git.io/JtMGR for more info. [5.2.2022, 11:43:55] [homebridge-levoit-humidifiers] This plugin slows down Homebridge. The read handler for the characteristic 'On' was slow to respond! See https://git.io/JtMGR for more info. [5.2.2022, 11:43:55] [homebridge-levoit-humidifiers] This plugin slows down Homebridge. The read handler for the characteristic 'On' was slow to respond! See https://git.io/JtMGR for more info. [5.2.2022, 11:43:55] [homebridge-levoit-humidifiers] This plugin slows down Homebridge. The read handler for the characteristic 'Brightness' was slow to respond! See https://git.io/JtMGR for more info. [5.2.2022, 11:43:55] [homebridge-levoit-humidifiers] This plugin slows down Homebridge. The read handler for the characteristic 'Active' was slow to respond! See https://git.io/JtMGR for more info. [5.2.2022, 11:43:55] [homebridge-levoit-humidifiers] This plugin slows down Homebridge. The read handler for the characteristic 'Current Humidifier-Dehumidifier State' was slow to respond! See https://git.io/JtMGR for more info. [5.2.2022, 11:43:55] [homebridge-levoit-humidifiers] This plugin slows down Homebridge. The read handler for the characteristic 'Current Relative Humidity' was slow to respond! See https://git.io/JtMGR for more info. [5.2.2022, 11:43:55] [homebridge-levoit-humidifiers] This plugin slows down Homebridge. The read handler for the characteristic 'Relative Humidity Humidifier Threshold' was slow to respond! See https://git.io/JtMGR for more info. [5.2.2022, 11:43:55] [homebridge-levoit-humidifiers] This plugin slows down Homebridge. The read handler for the characteristic 'Rotation Speed' was slow to respond! See https://git.io/JtMGR for more info.

jordanwmcdonald commented 2 years ago

Hey @afroeagle, I made some adjustments due to your feedback, and the general confusion people have had around Auto / Manual modes. I've been wanting to improve this aspect for a while, so I'm glad I was able to get to it.

I spent a lot of time trying to understand why HomeKit will sometimes put those nice display names under the accessories, and found that if you have 4 accessories, it will add them. If you have less or more, it doesn't. So the new implementation is missing the descriptions underneath because we now have 5 services / accessories.

The 5 accessories are:

  1. Target Humidity

    • Sets humidifier to Auto and sets the Target Humidity to the desired level.
  2. Mist Level

    • Sets humidifier to Manual and sets the Mist Level to the desired level.
  3. Sleep Mode

    • This switches the device between Sleep Mode (On) and Auto Mode (Off)

    • Sleep Mode Target Humidity is controlled by the Target Humidity slider, too.

  4. Night Light

  5. Display Toggle

services2

services

manual

auto

I've tested these features and they appear to work as expected. I'd really appreciate it if you could do some testing, too. The beta is 1.5.0-beta5. I've also improved some logging that might help with the error you described earlier.

Wow, sincerely impressive, @pschroeder89! All is working flawlessly, thank you.

pschroeder89 commented 2 years ago

Thanks for testing @Holydevil66! There have been other reports of the same errors throughout the development of this plugin. I did some initial research on it and responded here: https://github.com/pschroeder89/homebridge-levoit-humidifiers/issues/14

I have also removed the mandatory .5 second wait in 1.5.0-beta8 that was implemented to prevent VeSync from rate-limiting users. Unless someone is doing a lot of requests over and over, I think this should be fine and may cut down on the errors you're seeing. I've noticed the plugin is a lot faster from this change.

If that doesn't improve things on the error side, then I may need to refactor each request to return immediately instead of waiting for VeSync's response. This could lead to potential issues I think, since we will be reporting things within the UI before they've been confirmed by VeSync. Either way, that refactor work would be done in another update, since the above errors are benign.

I may also make it possible to hide some of the services for those users that don't need/want a Display Switch / Manual Mode Slider / Sleep Mode Switch / Night Light Slider, for instance. That could clean things up so you don't have to separate the tiles if you don't want to. Again, this will be for a later date, though.

@Holydevil66 @afroeagle Would you mind checking out beta9 when you can and make sure things look good for you still? Besides the removal of the hardcoded sleeps I mentioned above, I also removed the Sleep Mode switch for Dual200s devices (since they don't support it) and fixed an issue with Target Humidity. Since VeSync only supports a target humidity of 30-80, if the slider is moved under 30%, it will now just send 30%, and if's moved above 80%, it will now just send 80%. Also fixed a bug where On/Off didn't work for the light, only the slider did.

Thanks again for testing!

jordanwmcdonald commented 2 years ago

@pschroeder89 hey thanks! Works great. I tested each control and the only issue was another Circular JSON when changing the Mist slider.

pschroeder89 commented 2 years ago

@afroeagle Is that error consistent when you change the level? In your Homebridge logs, do you see any additional info before/after the mist change (example of the set log below)? Also, did you clear the Homebridge device cache prior to testing this version? Having a cached device can cause some unintended consequences.

Thanks for the info. If the error is not consistent or hasn't been seen since that one time, I will publish 1.5.0 and if it occurs again, please write up another ticket.

[06/02/2022, 10:39:35] [Levoit Humidifiers] Setting Mist Level to 7

jordanwmcdonald commented 2 years ago

Yes, I cleared the cache for the Homebridge device (and did it again for additional testing with results below). I would posit that it is not consistent. Also, I do not use this feature anyway, just thought I'd test it for ya. Happy to dive deeper if you need.

[2/6/2022, 5:51:03 PM] [Levoit Humidifiers] Setting Mist Level to 5
[2/6/2022, 5:51:05 PM] [Levoit Humidifiers] Setting Mist Level to 3
[2/6/2022, 5:51:05 PM] [Levoit Humidifiers] Setting Mist Level to 5
[2/6/2022, 5:51:11 PM] [homebridge-levoit-humidifiers] This plugin threw an error from the characteristic 'Rotation Speed': Unhandled error thrown inside write handler for characteristic: Converting circular structure to JSON
    --> starting at object with constructor 'ClientRequest'
    |     property 'socket' -> object with constructor 'TLSSocket'
    --- property '_httpMessage' closes the circle. See https://git.io/JtMGR for more info.
pschroeder89 commented 2 years ago

I'd love to debug this a bit further. I saw something similar last night for another Characteristic. I thought it was due to a change I made in 1.5.0-beta6, but then realized that the VeSync app had lost connection to the Humidifier. The VeSync app would say "Device is offline". Are you seeing anything like that by any chance?

Edit: beta10 is up with a possible fix for the circular json error. There is still an actual error occurring, which the plugin was trying to output but couldn't because it referenced itself (hence the circular json error). Can you set "enableDebugMode": true in your config and try to get the error again? I think it should now give us the real issue.

pschroeder89 commented 2 years ago

Beta11 is now up, which raises the following error log (even when debug mode is off) if the device is offline in VeSync:

[2/6/2022, 7:14:40 PM] [Levoit Humidifiers] Discovering devices...
[2/6/2022, 7:14:41 PM] [Levoit Humidifiers] VeSync cannot communicate with humidifier! Check the VeSync App.
pschroeder89 commented 2 years ago

I just merged https://github.com/pschroeder89/homebridge-levoit-humidifiers/pull/15 and published 1.5.0. In addition to the new switches and sliders, the plugin is faster and now properly handles error logging.

Thanks a ton for the testing and debugging help @afroeagle and @Holydevil66 !