arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
21.71k stars 4.72k forks source link

Support Levoit Core200s (WIP, Feedback requested) #21502

Closed blenk92 closed 1 month ago

blenk92 commented 1 month ago

Description:

Hi there, I bought one of these devices https://levoit.com/collections/air-purifiers/products/core-200s-smart-true-hepa-air-purifier and figured that is uses a esp32 (the solo1 variant) to talk to another MCU via a serial protocol. I've reversed the protocol (well at least the relevant parts I would say) to control the air purifier using Tasmota.

This PR contains my initial implementation, to proof that its generally possible to that (so its still kind of in a POC state in some places). However, it should already give a rough idea on how the protocol works... However, before I spend additional efforts in making it better, I would like to request some indication if the project would generally be interested in support these devices. I say 'these' because Levoit offers a bunch of similar devices, I only own a Core200S but I could imagine that other models are similar, maybe even using an extended version of the protocol (and there are still some fields in the status messages that seem to be unused on my device).

Since this is quite a large patch already, I would also like to ask what else I would need provide in order to get the levoit devices (ore at least the core200S) officially supported.

Screenshot to show you how the web interface currently looks like: Screenshot_2024-05-26_23-59-41

Related issue (if applicable): fixes #

Checklist:

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

barbudor commented 1 month ago

Hi @blenk92 As this device is based on ESP32, have you considered a Berry driver instead of a native one ? I think it could make more sense

blenk92 commented 1 month ago

Hi @blenk92 As this device is based on ESP32, have you considered a Berry driver instead of a native one ? I think it could make more sense

Hi @barbudor,

actually, I didn't. Seems like I missed that option completely. Thanks for the hint, will check it out later today.

blenk92 commented 1 month ago

Hi @blenk92 As this device is based on ESP32, have you considered a Berry driver instead of a native one ? I think it could make more sense

Hi @barbudor,

took me a bit to work myself into berry, but I think you have a point here. I re-implemented the current state in berry (the original change with the native driver is still available at https://github.com/blenk92/Tasmota/tree/core200s_native for reference)

Please let me know how we can proceed to get this merged ;-)

barbudor commented 1 month ago

Great @blenk92

Merge is not under my control. May be it could be worth adding along a Core2005.md doc along to explain how to use the driver, any configuration etc...

arendst commented 1 month ago

@s-hadinger is this a good implementation of a compiled-in berry driver? I had hoped this functionality could be added by users during runtime keeping the binary small ...

Jason2866 commented 1 month ago

@s-hadinger is this a good implementation of a compiled-in berry driver? I had hoped this functionality could be added by users during runtime keeping the binary small ...

The driver is loaded at runtime by the user. It is not solidfied. So no code size increase when not explicit loaded. Imho nice implementation when the few things Stephan reviewed are fixed.

arendst commented 1 month ago

OK. I leave it to @s-hadinger then 👍

blenk92 commented 1 month ago

Thanks, there are some changes needed, primarily remove the long delay() (above 50ms) and do async with tasmota.set_timer() instead.

You can also consider packaging all these in a single module, and avoid polluting the global namespace.

Thanks for you review. I tried to adapt according to the comments that you left. There is maybe still something open in regards of the async behavior. Maybe you want to have another look ?

Just FYI: I won't have access to my Core200S for ~ 1.5 weeks. So no hurry with the re-review, because I can't test potentially requested changes on my device until then...