oxan / esphome-stream-server

Stream server (serial-to-wifi bridge) for ESPHome
Other
179 stars 72 forks source link

Idea: Use UARTStream instead of hardcoded UARTComponent #19

Closed mjkl-gh closed 1 year ago

mjkl-gh commented 2 years ago

First of all thanks for writing this component. Some years ago I found an older version and I've been putting it to great use since.

While reading through the code, I couldn't help but notice the comments of "ESPHome doesn't know the Stream abstraction yet, so hardcode to use a UART for now."

Somewhere around the same time, I stumbled upon this from the Midea component:

https://www.esphome.io/api/appliance__base_8h_source.html

It implements a UARTStream class that takes the UARTcomponent and wraps the Stream class around it. Although it wouldn't change the functionality, it might be more in line with what you envisioned when you wrote this component.

oxan commented 1 year ago

Thanks for the suggestion! My thoughts behind that comment were that it'd be nice if ESPHome had a stream abstraction just like sensors/lights/etc, so that this component could be used with more sources than a UART. That's mostly a config-generation thing, and the Stream class doesn't really help there. Besides, the Stream class is from Arduino, and I prefer to reduce dependencies on Arduino over tightening them.

In any case, I don't think it's very relevant, as there aren't much other popular stream sources that could be integrated in ESPHome.