Add support in Vesync for Levoit 400s Air Purifier

I was working with the pyvesync Repo and got support for the 400s air purifier added. It’s the same api values as the 200s, just a bigger unit.

May we update the HA Vesync integration to pull in the pyvesync info as well?

I’ve got two 400S that I’d like to integrate into Home Assistant. @bwalshin , can you share what edits to what files you made to get this working? Thanks!

Hey @ajw , The edits were made on the pyvesync code, but still needs to be updated on the Home Assistant component integration code.

Let me know if this helps.

Thanks. I was able to login to my home assistant container and manually edit the pyvesync and the home assistant vesync files to get the 400S working. Pretty straight forward once I started poking around.

Hey all, I also have a 400S but no luck to integrate it with my HA on pi4.
Vesync integration does not find any entities and I also tried pyvesync with no success. I managed to transfer the pyvesync into my custom_components folder, as well as I added the vesync login credentials in the configuration.yalm file, but nothing happens.
Does anybody have the complete step by step process of how to use the Vesync integration along with pyvesync in order to get HA to communicate with the Levoit 400S air purifier?
Any help will be much appreciated. Thank you.

Note: I tried the below as well:

Hey bwalshin. I am struggling to setup my HA on pi4 to see my Levoit 400s.
Can you post step by step instructions on how to make this work?
Thank you

These are the steps I took to make my s400 be visible.

I have my install in a docker so this first step might be different for you depending on your install.
So I have a docker container running on my synology nas, in the details panel of the container it is possible to open a terminal within the container.

Once you have a terminal in the container find where the pyvesync library is installed. I ran this command to make it easy on myself. Warning this searches the entire file system so be careful cuz it might take a while.

$ find / -iname "*vesync*" 

This was my path: “/usr/local/lib/python3.9/site-packages/pyvesync”

from here you can update the,, and
Take a look at the link to the git repo for the details on what needs to be updated.
For me, the following worked: Warning depending on what version of the library you have this might break things so be careful and only do this if you verified that the new changes aren’t “Breaking changed”.

$ rm
$ rm
$ rm
$ wget   
$ wget  
$ wget

Once you updated the library you then need to update the integration py files.
I found them at this path: “/usr/src/homeassistant/homeassistant/components/vesync”
One your there open up: and update DEV_TYPE_TO_HA to look like this:

    "LV-PUR131S": "fan",                                                                                               
    "Core200S": "fan",                                                                                                 
    "Core400S": "fan",                                                                                                 

and PRESET_MODES to look like this:

    "LV-PUR131S": [FAN_MODE_AUTO, FAN_MODE_SLEEP],                                                                     
    "Core200S": [FAN_MODE_SLEEP],                                                                                      
    "Core400S": [FAN_MODE_AUTO, FAN_MODE_SLEEP],                                                                       

After that, you should be all set. Good luck and I take no responsibility for what you do to your system. This is what worked for me.

Add this to your config to have the air_quality attribute be a sensor.

  - platform: template                                                                                                 
        friendly_name: "(Indoor Air Quality)"                                                                          
        unit_of_measurement: "(ugm3)"                                                                                   
        value_template: "{{ state_attr('fan.filter', 'air_quality') }}"                                                
        unique_id: indoor_air_quality                                                                                      

thnx for the tutorial, it almost works!
getting the controls for the Core400s in both home assistant and HomeKit as well.
only thing i cant seem to get to work is the BONUS, the “indoor air quality” sensor!
are you sure thats the correct code you posted?
i have to add it to the configuration.yaml, right ?
i mean im getting the sensor (after adding the lines to the configuration.yaml and restarting HA) as an entity in home assistant but it has no value… i must be doing something wrong i guess ?!

what does your template code look like for the sensor? I tried to bonus part and works as advertised! :slight_smile:

exactly as its posted up there…

what is the name of your fan entity? I presume it isn’t fan.filter, right?

1 Like

thnx that was the hint i needed!
It was not written anywhere, neither that you have to change “fan.filter” nor what to change it into
thnx its working now!

you’re welcome!

I’m working on updating this integration (on the shoulders of others). Currently it (hopefully) works for all humidifiers, but a similar fix will be needed for the fans so all models in the library work with HA. I don’t have a fan so to do it, I’d need a tester (or 2).

I have a test repo and created a new topic. VeSync development particularly for Levoit Humdifiers