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

VeSync new device support #44865

Closed
step2zero opened this issue Jan 5, 2021 · 32 comments
Closed

VeSync new device support #44865

step2zero opened this issue Jan 5, 2021 · 32 comments

Comments

@step2zero
Copy link

step2zero commented Jan 5, 2021

The problem

Lack of support new devices from VeSync integration.
Especially Levoit Purifier C200, I was able to make it working with minor edits in "pyvesync" module.
It's generally responding to the same, API/Calls as existing LV-PUR131S.

I was editing a few lines:

if device_type in ['LV-PUR131S', 'Core200S']:
        return VeSyncAir131(config, manager)

fan_types = ['LV-PUR131S', 'Core200S']

Result:

Device Name:... Purifier
Model: ........ Core200S
Subdevice No: . None
Status: ....... on
Online: ....... online
Type: ......... wifi-air
CID: .......... 0MF-kisiTG2TEk_Gz7jKJENNccUESbc3
UUID: ......... a5ca76bb-2841-47c0-b9fa-06eaf1552e37
Active Time : . 0  minutes
Fan Level: .... 2
Air Quality: .. None
Mode: ......... manual
Screen Status:  off
Filter List: .. 0  percent

Environment

  • Home Assistant Core release with the issue: 2020.12.7
  • Last working Home Assistant Core release (if known):
  • Operating environment (OS/Container/Supervised/Core): Home Assistant OS 5.9
  • Integration causing this issue: VeSync
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/vesync/

Problem-relevant configuration.yaml

Traceback/Error logs

Additional information

@probot-home-assistant
Copy link

Hey there @markperdue, @webdjoe, @TheGardenMonkey, mind taking a look at this issue as its been labeled with an integration (vesync) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@comi8903
Copy link

Is there any way to add these changes? I'd edit the file myself, but I'm unfamiliar with it and I cannot find the the pevsync folder. I am using HassOS/Hass.io. Any help would be appreciated.

@step2zero
Copy link
Author

step2zero commented Jan 13, 2021 via email

@comi8903
Copy link

I would love if you could share your fork. I've currently forked vesync into a custom component as well and edited the lines in the vesync.py file to include the Core200S purifier, but I'm not sure where to put that file itself and I'm totally unclear on the "local copy of the PyVeSync library. I don't know how to obtain that or where to store it within my system. Any help would be appreciated.

@webdjoe
Copy link
Contributor

webdjoe commented Jan 13, 2021

Unless the Core200S has the same api calls, adding this line won't work. I am in the process of redesigning the library to make adding devices easier. If you would like to send the captures or submit a PR, I will be happy to add it

@comi8903
Copy link

Thank you. An updated component would be really nice.

@timcappalli
Copy link

Classic300S would be awesome as well.

Unknown device Classic300S

Here are some sample commands.

Turn On

POST https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 HTTP/2.0

{
    "acceptLanguage": "en",
    "accountID": "removed",
    "appVersion": "VeSync 3.0.54",
    "cid": "removed",
    "configModule": "WiFiBTOnboardingNotify_AirHumidifier_Classic300S_US",
    "debugMode": false,
    "deviceRegion": "US",
    "method": "bypassV2",
    "payload": {
        "data": {
            "enabled": true,
            "id": 0
        },
        "method": "setSwitch",
        "source": "APP"
    },
    "phoneBrand": "SM-G973U1",
    "phoneOS": "Android 10",
    "timeZone": "America/New_York",
    "token": "removed",
    "traceId": "1611977385269"
}

Turn Off

POST https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 HTTP/2.0

{
    "acceptLanguage": "en",
    "accountID": "removed",
    "appVersion": "VeSync 3.0.54",
    "cid": "removed",
    "configModule": "WiFiBTOnboardingNotify_AirHumidifier_Classic300S_US",
    "debugMode": false,
    "deviceRegion": "US",
    "method": "bypassV2",
    "payload": {
        "data": {
            "enabled": false,
            "id": 0
        },
        "method": "setSwitch",
        "source": "APP"
    },
    "phoneBrand": "SM-G973U1",
    "phoneOS": "Android 10",
    "timeZone": "America/New_York",
    "token": "removed",
    "traceId": "1611977385269"
}

Get Humidifier Status

POST https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 HTTP/2.0

{
    "acceptLanguage": "en",
    "accountID": "removed",
    "appVersion": "VeSync 3.0.54",
    "cid": "removed",
    "configModule": "WiFiBTOnboardingNotify_AirHumidifier_Classic300S_US",
    "debugMode": false,
    "deviceRegion": "US",
    "method": "bypassV2",
    "payload": {
        "data": {},
        "method": "getHumidifierStatus",
        "source": "APP"
    },
    "phoneBrand": "SM-G973U1",
    "phoneOS": "Android 10",
    "timeZone": "America/New_York",
    "token": "removed",
    "traceId": "1611977539676"
}

Set Target Humidity

POST https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 HTTP/2.0

{
    "acceptLanguage": "en",
    "accountID": "removed",
    "appVersion": "VeSync 3.0.54",
    "cid": "removed",
    "configModule": "WiFiBTOnboardingNotify_AirHumidifier_Classic300S_US",
    "debugMode": false,
    "deviceRegion": "US",
    "method": "bypassV2",
    "payload": {
        "data": {
            "target_humidity": 34
        },
        "method": "setTargetHumidity",
        "source": "APP"
    },
    "phoneBrand": "SM-G973U1",
    "phoneOS": "Android 10",
    "timeZone": "America/New_York",
    "token": "removed",
    "traceId": "1611977719771"
}

Set Mist Level

POST https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 HTTP/2.0

{
    "acceptLanguage": "en",
    "accountID": "removed",
    "appVersion": "VeSync 3.0.54",
    "cid": "removed",
    "configModule": "WiFiBTOnboardingNotify_AirHumidifier_Classic300S_US",
    "debugMode": false,
    "deviceRegion": "US",
    "method": "bypassV2",
    "payload": {
        "data": {
            "id": 0,
            "level": 7,
            "type": "mist"
        },
        "method": "setVirtualLevel",
        "source": "APP"
    },
    "phoneBrand": "SM-G973U1",
    "phoneOS": "Android 10",
    "timeZone": "America/New_York",
    "token": "removed",
    "traceId": "1611977680498"
}

Set to Auto

POST https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 HTTP/2.0

{
    "acceptLanguage": "en",
    "accountID": "removed",
    "appVersion": "VeSync 3.0.54",
    "cid": "removed",
    "configModule": "WiFiBTOnboardingNotify_AirHumidifier_Classic300S_US",
    "debugMode": false,
    "deviceRegion": "US",
    "method": "bypassV2",
    "payload": {
        "data": {
            "mode": "auto"
        },
        "method": "setHumidityMode",
        "source": "APP"
    },
    "phoneBrand": "SM-G973U1",
    "phoneOS": "Android 10",
    "timeZone": "America/New_York",
    "token": "removed",
    "traceId": "1611977701963"
}

@kitkat270
Copy link

A fix for the Levoit131S would be fantastic. I'm not a dev, but happy to test any potential fixes.

Thank you
:-)

@synergicmind
Copy link

I would also love to see Core200S to be added.

@aetchells55
Copy link

Likewise would love to see the Levoit 200S Humidifier added. Like @kitkat270, I am not a developer but am happy to test any enhancements. Once upon a time, software/hardware testing was my profession.

@derekisastro
Copy link

Noob here ... can someone describe where I put what file to enable this as a custom component? Currently, the VeSync integration does not work for me. So I am trying to add it as a custom component but cannot find clear and easy to understand instructions anywhere. It might be that I can't understand something but there is talk of files and folders and sometimes neither exist.

@webdjoe
Copy link
Contributor

webdjoe commented Feb 9, 2021 via email

@derekisastro
Copy link

The current integration now detects nothing, none of my switches or outlets show up as entities. I was pursuing the custom components as a way of getting around the failing integration. I have had previous versions of HA detect the switches and outlets. I can confirm, at this stage, that by downgrading from the current HA to 0.116.4 the switches and outlets are now visible and usable.
I am trying to see if I can pinpoint when the devices/entities were 'lost'. Currently upgrading to 0.118.5. I have not been using HA much recently and so had recently re-installed HA.
A coder friend of mine says that he believes the error logs are occurring due to some dimmer state of 1 or more of the entities. None of the switches is a dimmer switch but he seemed to think the current integration was 'hanging' a not detecting a device because of the dimmer state it was either, expecting and not finding, or finding and not expecting.

@derekisastro
Copy link

Upgrading to 0.118.5 has broken them. They still exist as entities but are categorized as 'unavailable' and are not functional.

@derekisastro
Copy link

I can confirm that 0.116.4 is the last update that worked correctly. Updating to 0.117.1 results in entities detected but not functional. Beyond that, at some point recently (perhaps the last update or 2 until this day) the entities were totally lost/missing/undetectable.

Staying on 0.116.4 is one solution for me, alternatively, with a little direction, I'd be happy to upgrade to the most recent version of HA but make a copy of the 0.116.4 VeSync components and try to use the copied files as a custom component in the current HA build. I would need direction in how to do this, especially, what specific files I need to make copies of and the file structure I'd need to make in the custom components folder. Staying on 0.116.4 seems far easier at the moment.

@flostingapplesauce
Copy link

Is there any hope for the humidifier being included?

@derN3rd
Copy link

derN3rd commented Mar 29, 2021

pyvsync was updated at 9th Feb to support the Classic 300S humidifier.
AFAIK this just needs to be updated and added into the VeSync integration

Edit:
The newest pyvesync is already in master. See #48128
So only code changed are required now

@kernelpanic85
Copy link
Contributor

kernelpanic85 commented Apr 19, 2021

Another +1 for Core 200S purifier support. This is Levoit's other smart purifier in addition to the 131. Any chance we can get this added? I have one and am happy to test anything.

@scherer42
Copy link

+1 for 300S humidifier support. Home assistant log: "Unknown device type - Classic300S"

@provinzio
Copy link

provinzio commented Apr 30, 2021

Hey there,

I bought a Classic300S recently and tried to add it to the component.
This is my first try on a "real" core component and I have actually no idea what I am doing except of the copy pasta 🤣

Would someone mind to have a look into it?
I created a standalone git repo for now, for easy usage as a custom component; just place it in the custom_components folder. (I don't know how to debug a core component)

The auto/sleep mode of the humidifier works, but I don't know how I can add e.g. the "fan" option. In manual mode, it's possible to set the mist level between 1 to 9. It should work like a fan entity. Is it possible to combine two entities together? Or how would I add them together.
I can't create two separate entites, because setting the mist level would e.g. change the humidifer to manual mode.

My further goals:

  • Add switch for display (on/off)
  • Add light entity for night brightness (1,2,3). Can I set these three discrete values instead of 0..255?
  • Add fan entity for mist level
  • Create PR in core repo
  • Add documentation

If you want to help me bring this forward, feel free to work with my code or add PR to it.

@formatBCE
Copy link
Contributor

@provinzio if you want to add several entities together, you want to create a device.
Great job, btw!

@provinzio
Copy link

provinzio commented Apr 30, 2021

I found something about a device_config property. Is this the correct stuff?

If you know more about it. An example (maybe from another project) or a documentation link would help me a lot.
I was too stupid to find more about it earlier. I will look into it next time I touch the code.

@formatBCE
Copy link
Contributor

I wish i knew it - just started to dig in too...
Looks like there's no screen on/off option for purifiers also, btw. If you will add one, i guess, that's fine to have it in separate switch.
Same with moist level - there's no place for it in official "humidifier" type in HA, so i guess, it could be nor additional "data" parameter in YAML, when you set mode (for manual), or separate entity also...

Night light could be a light too :)

@formatBCE
Copy link
Contributor

@provinzio
Or, looking on current implementation, it would be, maybe, possible to add separate mode for each moist level, like "MANUAL_1" ... "MANUAL_9", and modify code to parse it and set moist level.

@formatBCE
Copy link
Contributor

I wonder, why not use this
https://github.com/provinzio/home-assistant-vesync/blob/main/humidifier.py#L192
together with this
https://github.com/provinzio/home-assistant-vesync/blob/main/humidifier.py#L143
(enable SET_SPEED)
to set mist level - seems to be right way to do it.

@provinzio
Copy link

Yeah, I would add the night light and display as light or switch. Might be the best idea. Just have to check how I can set a light with only three levels. It would be weird if the scale goes from 0 to 255 but changes the light after each 255/3.

Or, looking on current implementation, it would be, maybe, possible to add separate mode for each moist level, like "MANUAL_1" ... "MANUAL_9", and modify code to parse it and set moist level.

Interesting idea. But might be cumbersome for HA cards. It might be harder to program a slider which changes the mist level this way. But your idea is definitely better than no implementation at all.

Set percentage and SET Level are features of the FanEntity. That's the other option of which I can think. Combineing a Humidifier entity and a fan entity in a device. Just have to get an idea how it's done :D

@formatBCE
Copy link
Contributor

formatBCE commented Apr 30, 2021 via email

@provinzio
Copy link

I tried to add multiple entities to a device in my dev branch. I think that it failed because I added the Fan in humidifier.py.

As this takes more time to implement for me as I'd like, I won't pursue this any further. (I am actually only using auto/sleep and on/off.)

I'll setup a PR with my current progress.

@alanjames1987
Copy link

@provinzio Looks like your PR was rejected or cancelled but I don't see a reason given by the maintainers of the VeSync module. Do you have more context that I'm not seeing?

@derN3rd
Copy link

derN3rd commented Jun 11, 2021

It was stale, no development happened on it, therefore it was automatically closed.

@formatBCE
Copy link
Contributor

formatBCE commented Jun 17, 2021

I made this extension to VeSync integration.
What I’ve done:

added humidifier entity recognition and load;
added dimmable light entity for night light;
added switch entity for turning display on/off;
included all entities into one device, recognized by HA;
added additional attributes to humidifier state, representing all info, received from pyvesync.
However, there’s several problems (either because I am dumb and doing it wrong, or because of pyvesync library lags):

state update for humidifier is pretty slow, and often HA doesn’t know, that it actually turned device off, showing on state (physically device is off). It updates sometimes to correct state, but inconsistently.
due to several entities, relying on one API device, it’s really hard for pyvesync to init all entities of humidifier, when adding integration. I never had all three together - re-initializing integration after deleting and reboot does add some of them, and does not add other…
I guess it could be fixed with some background tasks, but I just started digging that, thus didn’t resolve it for now due to lack of experience.
Overall, all entities work fine, when added: on/off device, setting mode, humidity, light level, on/off display.

Gonna work on it more.

@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Sep 15, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests