pyvesync icon indicating copy to clipboard operation
pyvesync copied to clipboard

Add support for Levoit EverestAir™ Smart True HEPA Air Purifier if possible.

Open wtstreetglow opened this issue 2 years ago • 38 comments
trafficstars

Hello,

Would it be possible to add support for the subject air purifier to home assistant?

If so, what kinds of things would you need from myself. I do own the device but am not a programmer but trade.

Thank you for any insights you can give. It is very much appreciated.

wtstreetglow avatar Dec 16 '22 11:12 wtstreetglow

Please follow directions here: https://github.com/webdjoe/pyvesync#feature-requests and post packet captures (in code blocks). Please ensure to redact your token, accountId, cid & uuid.

webdjoe avatar Dec 26 '22 19:12 webdjoe

Thank you for this guidance. I will take care of this over the next week or so. Very much appreciate it!!Sent from my iPhoneOn Dec 26, 2022, at 2:43 PM, Joe Trabulsy @.***> wrote: Please follow directions here: https://github.com/webdjoe/pyvesync#feature-requests and post packet captures (in code blocks). Please ensure to redact your token, accountId, cid & uuid.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

wtstreetglow avatar Dec 26 '22 20:12 wtstreetglow

I have the same air purifier. I tried to use Charles Proxy and I'm getting the same error when using the trusted certificate as in #177

spencer-scott avatar Mar 16 '23 17:03 spencer-scott

I haven't tried this myself, but this is a new way to capture packets that's been proposed: #180

webdjoe avatar Mar 31 '23 13:03 webdjoe

I just picked one of the EverestAirs up, does the Charles Proxy still work or no? If it does i'll buy the app (is there a free one?) and get the info needed, but looks like only Android method works now?

kasper79 avatar May 23 '23 13:05 kasper79

Charles Proxy doesn't work for this. I have an android device, but I believe you have to have a rooted android device in order to perform the packet capture which I do not have nor do I know how to make a device rooted. Fingers crossed someone with a rooted android comes along.

spencer-scott avatar May 23 '23 14:05 spencer-scott

It worked for me on iOS using Charles Proxy for iOS. I have full captures and was attempting to develop support myself but was still familiarizing myself with the code base. Would be very happy to share the captures instead - I verified that they are complete.

On Tue, May 23 2023 at 7:28 AM, Spencer Reynolds < @.*** > wrote:

Charles Proxy doesn't work for this. I have an android device, but I believe you have to have a rooted android device in order to perform the packet capture which I do not have nor do I know how to make a device rooted. Fingers crossed someone with a rooted android comes along.

— Reply to this email directly, view it on GitHub ( https://github.com/webdjoe/pyvesync/issues/170#issuecomment-1559528770 ) , or unsubscribe ( https://github.com/notifications/unsubscribe-auth/AD3FRFE3RDHRT4P7HK5UR2DXHTCSPANCNFSM6AAAAAATA2IN3Q ). You are receiving this because you are subscribed to this thread. Message ID: <webdjoe/pyvesync/issues/170/1559528770 @ github. com>

jasonjhofmann avatar May 24 '23 07:05 jasonjhofmann

How did you get it to work if you don't mind me asking? I will share my captures if I can get it to work. In the meantime please do share your captures! I would really like to get this working in Home Assistant for the EverestAir.

spencer-scott avatar Jun 02 '23 13:06 spencer-scott

Feel free to email me captures webdjoe at gmail . I will work on adding the device to the library

webdjoe avatar Jun 17 '23 02:06 webdjoe

Hi, all! I just recently picked one of these up and am interested in helping getting it integrated into HA. @webdjoe, did you ever receive those captures from @jasonjhofmann? If not, I can try to work on getting you what you need! Thanks!

chipdarippa avatar Jun 28 '23 03:06 chipdarippa

This is next on the agenda, just finishing up with the Vital100S/200S

webdjoe avatar Jun 28 '23 12:06 webdjoe

Just picked this up myself too! Would love this to be integrated!

If there is something you need I can try to provide it.

gpala7077 avatar Jul 13 '23 20:07 gpala7077

No I haven't received any captures. The only way to capture is to install the vesync APK on an Android Emulator (like Android Studio) using a generic android OS version. Then using frida as shown in Sections 4,5 in Ultimate Guide. After SSL pinning is disabled, capture packets with SSL proxy with charles or some other software that installs a root certificate.

Check out this for setting frida up. I never used genymotion, only Android Studio which requires a generic android OS to root the device.

webdjoe avatar Jul 18 '23 00:07 webdjoe

No I haven't received any captures. The only way to capture is to install the vesync APK on an Android Emulator (like Android Studio) using a generic android OS version. Then using frida as shown in Sections 4,5 in Ultimate Guide. After SSL pinning is disabled, capture packets with SSL proxy with charles or some other software that installs a root certificate.

Check out this for setting frida up. I never used genymotion, only Android Studio which requires a generic android OS to root the device.

Hi @webdjoe, add me to the list of people with an EverestAir. I'm a former software engineer for a light control company so I have some experience with smart devices and am happy to help if it is still needed. I'll look at these instructions and try to get you the needed captures. Please let me know if you already have what you need.

weberjam007 avatar Jul 28 '23 16:07 weberjam007

While we are awaiting captures, my app tells me that there is a firmware update available for my device. Of course I can't find a changelog or anything. Looking through the app menus I think that it's currently on firmware 1.0.06 and the update is 1.0.10. I would like to fix any issues that may be present with it, but without having a changelog...I also don't want to take the risk of locking it out from this workaround to integration...any thoughts?

chipdarippa avatar Jul 30 '23 02:07 chipdarippa

@weberjam007 I haven't received any captures, happy to integrate if you are successful.

@chipdarippa Firmware updates should be fine, haven't seen any issues with this ever

webdjoe avatar Jul 31 '23 02:07 webdjoe

Hi folks, I heard you need help with captures, I might be able to help since my lab is still active for capturing other VeSync devices.

I will need someone to provide credentials for the device with a disposable email and approval for me to use it.

M1K3SD1 avatar Jul 31 '23 21:07 M1K3SD1

@M1K3SD1 Thank you for offering to assist. I have setup a throwaway account and shared the device with that user (sharing should work..does not need to be the only/direct owner...correct?). Are you able to email me at [email protected] and I will send you the VeSync password. Appreciate your assistance with the captures.

penguinglacier avatar Aug 03 '23 02:08 penguinglacier

@webdjoe Apologies for not replying sooner. My Charles Web Proxy iOS captures are from December, I haven't tried since. It's likely I got lucky (performed these captures before they implemented TLS cert pinning in the app).

The reason I got stuck and was unable to implement the changes myself, is that this isn't a straightforward change (as previous diffs for adding new model support would suggest).

For this model, they completely changed the request and response schemas. I don't understand this code well enough to implement such a large change.

I could not find any metadata in the deviceList Arrays (in any of the various API call responses FW, Room, etc)- that would allow one to determine which syntax to use for which device. Perhaps it's a hardcoded list in the app?

Compare the following:

Date of capture: December 27th, 2022 appVersion: VeSync 4.1.52 build4 POST URL for both: https://smartapi.vesync.com/cloud/v2/deviceManaged/bypassV2 method for both: getPurifierStatus

Model: Levoit Core 600S (WFON_APR_LAP-C601S-WUS_US)

Request

{
	"acceptLanguage": "en",
	"deviceRegion": "US",
	"appVersion": "VeSync 4.1.52 build4",
	"method": "bypassV2",
	"traceId": “1111111111111”,
	"timeZone": "America\/Los_Angeles",
	"configModule": "WFON_APR_LAP-C601S-WUS_US",
	"phoneOS": "iOS 16.0.2",
	"cid": “aaaa11a111111a1111aaaaa1a11a111a",
	"token": “xxxxxxxxxxx”,
	"debugMode": false,
	"accountID": “11111111”,
	"payload": {
		"data": {},
		"source": "APP",
		"method": "getPurifierStatus"
	},
	"userCountryCode": "US",
	"phoneBrand": "iPhone 14 Pro"
}

Response

{
	"traceId": "1111111111111",
	"code": 0,
	"msg": "request success",
	"module": null,
	"stacktrace": null,
	"result": {
		"traceId": "1111111111111",
		"code": 0,
		"result": {
			"enabled": true,
			"filter_life": 73,
			"mode": "manual",
			"level": 1,
			"air_quality": 1,
			"air_quality_value": 1,
			"display": true,
			"child_lock": false,
			"configuration": {
				"display": true,
				"display_forever": true,
				"display_usable": true,
				"light_detection": false,
				"auto_preference": {
					"type": "default",
					"room_size": 0
				}
			},
			"extension": {
				"schedule_count": 0,
				"timer_remain": 0,
				"efficient_mode_time_remain": 0,
				"eco_mode_run_time": 0
			},
			"device_error_code": 0
		}
	}
}

Model: Levoit EverestAir (VS_WFON_APR_LAP-EL551S-AUS_US)

Request

{
	"context": {
		"token": "xxxxxxxxxxx",
		"appVersion": "VeSync 4.1.52 build4",
		"userCountryCode": "US",
		"phoneOS": "iOS16.0.2",
		"acceptLanguage": "en",
		"timeZone": "America\/Los_Angeles",
		"traceId": "1111111111111",
		"phoneBrand": "iPhone 14 Pro",
		"method": "bypassV2",
		"debugMode": false,
		"accountID": "11111111"
	},
	"data": {
		"configModule": "VS_WFON_APR_LAP-EL551S-AUS_US",
		"cid": “bbbb11a111111a1111aaaaa1a11a111a",
		"payload": {
			"method": "getPurifierStatus",
			"data": {},
			"source": "APP"
		}
	}
}

Response

{
	"traceId": "1111111111111",
	"code": 0,
	"msg": "request success",
	"module": null,
	"stacktrace": null,
	"result": {
		"traceId": "1111111111111",
		"code": 0,
		"result": {
			"fanRotateAngle": 75,
			"filterOpenState": 0,
			"powerSwitch": 1,
			"filterLifePercent": 94,
			"workMode": "manual",
			"manualSpeedLevel": 1,
			"fanSpeedLevel": 1,
			"AQLevel": 1,
			"AQPercent": 98,
			"PM25": 3,
			"PM1": 1,
			"PM10": 5,
			"screenState": 0,
			"childLockSwitch": 0,
			"screenSwitch": 1,
			"lightDetectionSwitch": 1,
			"environmentLightState": 1,
			"autoPreference": {
				"autoPreferenceType": "default",
				"roomSize": 0
			},
			"routine": {
				"routineType": "normal",
				"runSeconds": 0
			},
			"scheduleCount": 0,
			"timerRemain": 0,
			"efficientModeTimeRemain": 0,
			"ecoModeRunTime": 0,
			"errorCode": 0
		}
	}
}

jasonjhofmann avatar Aug 04 '23 01:08 jasonjhofmann

Just got an EverestAir, would like to see it in HA, subbing here for updates.

ptr727 avatar Aug 06 '23 23:08 ptr727

@penguinglacier just sent you the file in the email :)

M1K3SD1 avatar Aug 08 '23 00:08 M1K3SD1

@M1K3SD1 @penguinglacier Thank you for getting this to me but for some reason the chlsx file that I received had the body JSON stripped from all of the responses. I looked through the chlsx file in a text editor and none of the calls have the response body

webdjoe avatar Aug 09 '23 01:08 webdjoe

Weird, sorry about that, let me recapture it.

M1K3SD1 avatar Aug 11 '23 18:08 M1K3SD1

@webdjoe just sent you a new file, my bad. I was in a hurry and saved it wrong.

FYI @penguinglacier

M1K3SD1 avatar Aug 11 '23 21:08 M1K3SD1

Sorry for delay, please test out this branch. Should have most of the features except the vent rotate, that wasn't part of the captures.

webdjoe avatar Sep 04 '23 01:09 webdjoe

Anyone who has such a device is able to test the branch, please?

M1K3SD1 avatar Sep 06 '23 00:09 M1K3SD1

Can you provide test instructions, ideally to run in a VSCode dev container?

ptr727 avatar Sep 06 '23 02:09 ptr727

Sure thing. Thanks for all the effort getting this updated @webdjoe!

Not sure if it's normal, but when running a command to change something, the device changes immediately, but the terminal doesn't return for about 5 seconds. - Edit: never mind, after power cycling the purifier this seems to have gone away.

Full disclosure, my two Everest Air purifiers are on firmware "1.0.06(1.0.09)". I've avoided updating them because I've wanted to try to dump the ESP32 firmware that run them. At least in the older firmware, the eFuses seemed to not be blown, so I was concerned an update may change that. Because of the older firmware, that may cause issues. Some things in the VeSync app like resetting the filter don't seem to work.

# unsure if they work ev_living.air_quality --> 0 (not sure what this should be. % on the screen is 96-99%) type(ev_living.current_firm_version) --> None ev_living.get_timer() --> not sure what this does, only update() refreshes the timer value ev_living.set_night_light --> this might work, but not sure what it does beyond enabling light detection ev_living.filter_life --> 0 (I haven't been able to reset mine with the app (see above))

Full details attached from everything I tested. There's also some instructions for getting this setup for anyone interested in testing. I'm on an older Intel Mac, with Python 3.10. everestair-testing.txt

Edit 2: Looking at .details, the air quality info there, so maybe it just needs to be mapped? air_quality_value, pm1, pm10, aq_percent

ev_living.details --> {'filter_life': 0, 'mode': 'manual', 'level': 0, 'display': False, 'child_lock': False, 'night_light': 'off', 'air_quality': 0, 'light_detection_switch': True, 'environment_light_state': False, 'screen_switch': True, 'air_quality_value': 6, 'pm1': 4, 'pm10': 8, 'aq_percent': 95, 'fan_rotate_angle': 0, 'filter_open_state': False, 'auto_preference_type': 'default', 'light_detection': True}

erictrudeau avatar Sep 06 '23 02:09 erictrudeau

@M1K3SD1 any chance you could do another capture while setting the angle? That would be a nice feature to have. Thanks!

erictrudeau avatar Sep 06 '23 02:09 erictrudeau

Thank you for the detailed debug, it's a huge help. Regarding the firmware version, I usually notice an improvement on performance and consistency but I'm not sure how it affects the ability to flash the device. It's been awhile since I've messed with esp firmware but I would imagine that it would be tough to flash custom firmware and keep all of the functionality. It is a huge drawback that these are cloud based but at least vesync is doing well so I don't think they are going to disappear anytime soon like insteon.

  • air_quality is the air quality level, I believe 1-4. There was a typo in the key that is fixed
  • aq_percent is the actual percentage. I did this to maintain the consistency of the air_quality key among all of the air purifier models.
  • filter_life should be working, the key is correct.
  • get_timer should pull the timer if it is set. Post any log entries and I try to fix it

webdjoe avatar Sep 08 '23 01:09 webdjoe