It would be really cool if this existing Integration could handle On / Off functions and also report the current Humidity for this device.
I got the same device, as there are other levoit devices supported i hope someone will help with this, if there is anything I can do please tell me.
+1 for this one, also will be glad to help.
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.
Andril, very pleased to here that you are working on this. I just had a look at core/homeassistant/components/vesync/ and see no recent changes. Do you have a link so that I can test it ?
Oh, sorry I didn’t mention. It’s WIP, of course, and I don’t know, when I’ll get a time to run all HA requirements for merging.
I will post that today, so you could test it from custom_components.
@Kertz1954
GitHub - formatBCE/HA_VeSync_Classic300s - here’s my repo with custom component.
You can download that, unpack to custom_components and restart HA.
Pay attention, that for consistency I named it VeSync-FormatBCE.
Add it via regular Configuration-Integrations flow.
Let me know, if it works for you.
Ok, thanks. I will look at it tomorrow.
I also created this issue in pyvesync repo Error on creating several Vesync devices from one physical device · Issue #83 · webdjoe/pyvesync · GitHub to investigate API calls failure.
Andril,
My feedback after installing VeSync-FormatBCE.
After host reboot.
1 entities:
humidifier.humber
state: on
state attributes:
min_humidity: 30
max_humidity: 80
available_modes:
- auto
- sleep
- manual low
- manual mid
- manual high
humidity: 65
mode: auto
mist_virtual_level: 5
mist_level: 2
water_lacks: false
humidity_high: false
water_tank_lifted: false
display: true
automatic_stop_reach_target: true
night_light_brightness: 0
friendly_name: humber
supported_features: 1
device_class: humidifier
After host reboot.
now 2 entities:
humidifier.humber +
light.humber_night_light
state: off
state attributes:
supported_color_modes:
- brightness
friendly_name: humber (night light)
supported_features: 0
After host reboot.
now 3 entities:
humidifier.humber + light.humber_night_light +
switch.humber_display
state: unavailable
state attributes:
restored: true
supported_features: 0
friendly_name: humber (display)
Not available due to folowing error log.
vesync_formatbce: Error on device update!
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 432, in _async_add_entity
await entity.async_device_update(warning=False)
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 550, in async_device_update
await task
File “/usr/local/lib/python3.8/concurrent/futures/thread.py”, line 57, 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.8/site-packages/pyvesync/vesyncfan.py”, line 757, in update
self.get_details()
File “/usr/local/lib/python3.8/site-packages/pyvesync/vesyncfan.py”, line 738, in get_details
outer_result = r.get(‘result’, {})
AttributeError: ‘NoneType’ object has no attribute ‘get’
Having read your GitHub thread, no surprise here with this error.
Functionality.
All functions work well except for the switch.humber_display (mobile app in one hand, mouse in the other).
Overall, a very good start. If the call to the API is just an EndPoint problem, I hope it can be fixed soon.
Jeff
Hello Jeff!
Thank you for checking!
Yes, that’s that error which is bothering me a lot
Looks like that endpoint is pretty unstable.
We’re trying to parse app packets to check, if app itself does use another API (updated etc.), because official app seems th be more responsive, than pyvesync.
If you can try intercept packets (see that issue conversation), it would help a lot - my smartphone can’t do it for some reason…
I will try tomorrow. My android phone is somewhat old., but no harm in trying.
Hi Andril,
Another day, another test. I downloaded the Packet Capture App and was ready to do the installation. But a gut feeling prompted me not to do the install. Maybe I am being too over cautious.
However, not to be beaten by a software problem, I took another approach and hacked the init.py file and removed all references of light.
I uninstalled your test version, rebooted, copied my hacked version over, rebooted and I got the main entity.
I then reloaded the integration, restarted the core and now also have the switch entity.
And to cap it all, no errors in the log file relating to this issue.
I restarted the core once more to remove some other non related errors and have spent a good hour testing, from the App and vice versa and still no log errors.
Conclusion. The light (night_light) is the main cause of the errors.
I hope the above actions help narrow the problem down.
Jeff
Hi Jeff.
Believe me or not, but all the code there is identical for all parts. Also, while testing it, I was simply calling “update” on main device - and getting errors for it randomly.
You can try delete integration and re-add it - there’s 90% chance that you’ll get an error for either humidifier itself or display switch.
I guess, the best possible solution for now is to disable adding of night light and display, to ensure humidifier itself is working.
Andrii
Hi Andril,
I believe you, just back after a few hours away and now see this in the log. Why did the errors only start at 17:01:01. Very strange.
This error originated from a custom integration.
Logger: homeassistant.helpers.entity
Source: custom_components/vesync_formatbce/common.py:107
Integration: VeSync-FormatBCE
First occurred: 17:01:01 (112 occurrences)
Last logged: 18:57:02
Update for switch.humber_display fails
Update for humidifier.humber fails
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 350, in async_update_ha_state
await self.async_device_update()
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 558, in async_device_update
raise exc
File “/usr/local/lib/python3.8/concurrent/futures/thread.py”, line 57, 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.8/site-packages/pyvesync/vesyncfan.py”, line 757, in update
self.get_details()
File “/usr/local/lib/python3.8/site-packages/pyvesync/vesyncfan.py”, line 738, in get_details
outer_result = r.get(‘result’, {})
AttributeError: ‘NoneType’ object has no attribute ‘get’
Can you send me another version to test with just the humifier as suggested.
Jeff
Hey Jeff!
AFK right now.
You may go to common.py file, and comment out (place # sign before) respective lines for adding fan to switch and lights (there’s just one place, where same device is been added in three lines, comment out two latter of them). Then re-add integration.
Cheers
Andrii
Hello,
thanks a lot for your work !
I just bought a Levoit Classic 300S, it’s a great product. So, I tried to use your custom component vesync_formatbce after added the VeSync extension (login OK), but my humidifier is not detected.
Could you please give me some clues how to modify the file configuration.yaml ?
Thanks.
David
Hi David
If you added this code to custom_components, then after HA reboot just go to Configuration-Integrations and search for VeSync. You’ll find two there - one vanilla VeSync, and another - with FormatBCE. Add the latter. It should pick humidifier automatically, no need to change yaml.
If it doesn’t detect, try to remove and add integration back (not the code, just login itself) - due to described bug it lags often.
BR
Andrii.
Hi,
thanks a lot for you answer. It begins to work now.
I’ll wait until tomorrow to see if others options populate.
David