I did this: NodeMCU Dimmer
to achieve more or less the same thing. However my dimmer is not in the wall but in a nightstand so I did not use a sonoff.
I would be interested in you HASS configuration with respect to the dimmer. I find mine quite laggy…
my dimmer transmits its value to a sensor and then I have an automation reacting to the sensor. This is not the most elegant way I suppose