Add support for Levoit Classic 300S Smart Ultrasonic Top-Fill Cool Mist Humidifier in the VeSync integration

Seems like you looked into the wrong unit. The 60H does offer VeSync integration via there app.
If its not working i will look into flashing it with ESPHome / possible replacing the integrated controller with a Esp module.

I also dont unterstand the current limitations and where they are from. Seems like we can only get one controllable “output” (light or humidifying or display) to work? All of them together make issues?

Sorry, i got confused with 600HH, i guess.
This one is been sold in Europe? Could find it on amazon.de. It seems to be pretty similar to 300s though, maybe, just rebranding for another market.
If it respond with “Classic300S” as device type, it will work. Otherwise pyvesync repo should be updated with its device type to support it. After that i could extend this HA integration too.

I also dont unterstand the current limitations and where they are from. Seems like we can only get one controllable “output” (light or humidifying or display) to work? All of them together make issues?

This device is using some manufacturer server, which is a bit laggy, and often throws errors instead of accepting requests. Especially, if there’s several requests for one device coming.
Whic is exactly the case, when we want to initialize several Home Assistant entities, which are actually in one physical device (our case - it’s humidifier itself, night light bulb, and display switch). So HA, basically, bombs server with requests for this entities, and server starts throwing errors.
This leads to uninitialized entities there, and from those three, HA can miss either two.
That’s why i recommended to comment out bulb and display initialization code. It is working, but only if server itself works.

BR
Andrii.

Thanks for your explanation.

Yes the one is sold in Europe.

The server thing seems silly, i will look into replacing the controller than. I dont want to rely on the manufacturer servers. I was under the impression that control would be local only.

I will post my findings here.

Yes, this integration is cloud-based.
It’s always better to have local way to rule devices. Good luck there, and please share, if you succeed :slight_smile:

Cheers
Andrii.

Ok Thanks Andril. I will update tomorrow. Keep up the good work !!

1 Like

Hi Andril,

It’s been a week since our last contact, so just a quick update from me to report that all is well here with the VeSync FormatBCE Integration. Not one error to report. I updated my dashboard to use the services available and except for the occasional response lag, it works perfectly. In addition, a new family member arrived last week, one Levoit Air Purifier LV-PUR131S. Therefore, an additional entity created. No problems encountered and no response lag, but I would have expected a new device plus 1 entity !

Jeff

Glad to hear, Jeff. Mine is working too. Looks like, if I stop bombing that server and just use it - it’s almost fine :slight_smile:
I tried to meet all requirements for pull request to HA main repository, but didn’t even manage to run HA test setup. Will try on another PC this week. There’s too many to check for this small change :slight_smile:

Gonna keep updates.

Cheers
Andrii.

On that question about adding device for purifier:

I didn’t touch existing functionality for already supported devices, and there’s no implementation of device. Don’t know if it’s really needed, as we it will have just one entity in it, but it’s definitely doable. :slight_smile:

Thanks for the update on this. It works (with both flavours), so I won’t touch anything !! :slightly_smiling_face:

thanks for your work on this. I was looking for a humidifier to buy that I could tie into HA and the levoit looks like the one to get now. So do I just download your folder and stick it in the custom_components folder? I only really need to have it turn on and off as well as see the humidity levels

Yes, that’s pretty much it. It’s same old VeSync integration, just with added code for humidifier.
You may comment out the code related to screen and night light, to improve main stability. But it will work without modification too.

1 Like

Just got my humidifier in and looking at common.py, not too sure what to comment out. Im guessing these four lines below?

    if manager.fans:
        for fan in manager.fans:
            if HUMI_DEV_TYPE_TO_HA.get(fan.device_type):
                devices[VS_HUMIDIFIERS].append(fan)
                # devices[VS_SWITCHES].append(fan)
                # devices[VS_LIGHTS].append(fan)
                humidifiers_count += 1
                # switches_count += 1
                # lights_count += 1
            else:
                devices[VS_FANS].append(fan)
                fans_count += 1

yep, seems like thats all you need to comment out. I only see an entity for the humidifier. Thanks for all the work again!

Yes, sorry for no response - didn’t get notification. This should be enough.
For me, it works with all other entities for last week without any problems. But it definitely is more stable without that additional stuff.

no worries. I do see some errors in my log:

Logger: pyvesync.helpers
Source: /usr/local/lib/python3.9/site-packages/pyvesync/helpers.py:174
First occurred: 11:10:56 AM (1 occurrences)
Last logged: 11:10:56 AM

HTTPSConnectionPool(host='smartapi.vesync.com', port=443): Max retries exceeded with url: /cloud/v2/deviceManaged/bypassV2 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fafa8e773a0>: Failed to establish a new connection: [Errno -3] Try again'))

and

This error originated from a custom integration.

Logger: homeassistant.helpers.entity
Source: custom_components/vesync_formatbce/common.py:107
Integration: VeSync-FormatBCE
First occurred: 11:10:56 AM (1 occurrences)
Last logged: 11:10:56 AM

Update for humidifier.bedroom_humidifier fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 401, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 609, in async_device_update
    raise exc
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/vesync_formatbce/common.py", line 107, in update
    self.device.update()
  File "/usr/local/lib/python3.9/site-packages/pyvesync/vesyncfan.py", line 757, in update
    self.get_details()
  File "/usr/local/lib/python3.9/site-packages/pyvesync/vesyncfan.py", line 738, in get_details
    outer_result = r.get('result', {})
AttributeError: 'NoneType' object has no attribute 'get'

Anything else I can do to prevent these?

No, this is the error we were talking about - it’s server lags.
If you have ability to intercept API calls for official VeSync app, it would help greatly - pyvesync library developer needs help with it, and could try to update library with new API, if someone could get that info.

Hello Andrii,
I have been struggling integrating my Levoit 400S air purifier. Vesync does not support it…and I had no luck with pyvesync. I tried everything, it just doesn’t show up in my HA (on pi4). Maybe I just do not understand the pyvesync installation process, thus it fails to initiate.
In any event, I was reading your post regarding the 300S Humidifier, and I was wondering if there is a way to also add support for the Levoit 400S air purifier in your repo?

Thank you

Hello!
As far as I can see from docs, pyvesync library doesn’t support 400S yet.
Unfortunately, the only thing I did was adding device, supported by pyvesync, to Home Assistant.
If pyvesync will add support for 400S, it will be possible - but without actual device to test it’ll be pretty hard to implement.
Pyvesync is Python util - you may download it to Windows PC and try run from command line with “python pyvesync” command. Then just login there and try to get device list. Nothing to do with HA on current stage. :slight_smile:
However, as I mentioned, I believe it is not yet supported, so you may ask pyvesync dev to add support for 400S first.

Hello Andrii and many thanks for your reply.
Actually it seems that pyvesync now supports the 400S air purifier.
Here is the link :

I have the 400S and I will be happy to test any update of your repo.

Thank you

Oh, cool! I was looking here pyvesync · PyPI
Looks like docs there outdated.
The response seems to be copied from 200s, and if they similar enough, should be easy.

Well, I can try then.