Can i create a standalone 8266 to control brightness with esphome?

Ive got an older floor lamp that has a reading lamp in it too. I wish to mod it to use usb power (or 12v), be remotely controllable and with the main lamp also brightness would be adjustable. Gadgets wise ive got a D1 mini, a KY-040. Im going to use some mosfets or premade pwm boards to control the leds.
The KY button already controls on and off states fine for both pwm signals but i cannot figure how i make the encoder to control pwm without HA assistance, also still work being controlled by HA slider.

You might be over-thinking it.

Create your PWM light in ESPHome.

Create an automation to control it with the rotary encoder in ESPHome.

Home Assistant will provide a brightness slider for the PWM light. No need to do anything extra there.

If the brightness changes due to the rotary encoder the state of the light (the brightness slider) will be updated in home assistant to reflect that automatically.

If you change the brightness of the light in home assistant the light will change in ESPHome.

No way it is that easy :grinning: Ive been wondering around this for a month. I have not thought of that an automation could control the thing. How would the automation look like? (there is a lot of stuff on that page)