Analogue style rotary dimmer switch - Sonoff + ESPEasy + MQTT

I would recommend to use ESPHome now.

Thanks. I’ll try with ESPHome later today.

Is there any way to use two dimmers with one Sonoff basic? I have a couple of twin dimmers around the house for different lighting zones and it’s not really possible to squeeze two Sonoffs into the space behind the faceplate.
The Sonoff basic has two rows of 4 header pins but not sure if they can all be used.

Why not use an esp32? Plenty of IO.

You have any tutorial to add this Xiaomi Yelight controller to HA ?

Not sure that you can. However I think @hijinx posted that pic to demonstrate a working mode that could be emulated via a rotary encoder and some programming of an esp device.

I looked at that and use ESP32s for other projects but powering it in the space behind the faceplate leads to the same issue as two sonoff basics.
Unless you know of an easy way to power one with minimal space used up?

Yes true. This device seems to be pretty good and safe from what I have read. Quite small too https://www.amazon.com/Industrial-IRM-03-5-MEAN-WELL-Switching/dp/B07CQVNGTY/ref=as_li_ss_tl?ie=UTF8&linkCode=sl1&tag=derushadd-20&linkId=505f395fcda7075a0c96c5bc45fbf1d9&language=en_US

:slight_smile: I was just reading about a similar device https://randomnerdtutorials.com/esp8266-hi-link-hlk-pm03/

Alternatively I wonder would a Sonoff TH10 give me the extra GPIOs I need and still fit everything in one package!
Need to take a look at one of my TH10s I think.

The hlk device needs all those other components around it, the meanwell includes all that.

Sonoff basic (both old and new versions) don’t have enough exposed gpios for double rotary encoders.

Correct @nickrout. Ideas to be implemented in esphome etc.

But in the future it may be possible to support via ble- maybe using esp32 as a gateway similar to how esphome supports mi flora etc

Yes it would be interesting to have one to try.

Hi

Sorry if this is a stupid question but with the double click, how do I set what scenes are being selected?

      then:
        - logger.log: "Double Clicked"
        - homeassistant.service:
            service: input_select.select_next
            data:
              entity_id: input_select.hue_scenes

I can’t figure out how to get it to cycle through the four scenes under Hue group “Livingroom”.

Thanks

So it transpires that I can indeed fit two Sonoff basics in the space behind one faceplate so I now have dual dimmers controlling my kitchen and living room zones. Nice…

I also have double clicks working to cycle through different Hue scenes so I can have all lights on, just worktop spots, just island spots etc. which is really neat.

The long click work great too so I can trigger the relays and reset power to all lights if I need to.

Only one issue, controlling dimming on a single bulb with HA via Hue bridge is perfectly smooth but controlling dimming on a Hue group via HA is really sporadic. Brightness goes up and down at it’s own rate, sometimes doesn’t respond or lags maybe 2-3 seconds.

I’ve tested this every way I can think of and it’s the same. I know it’s more of a HA issue because I notice that I can replicaate it somewhat with the brightness sliders in HA but never really noticed it before because I usually just click the slider to a certain position in HA and the brightnedd goes there but with the rotary dimmer you have more control so the lagginess is a lot more noticeable.
Has anyone else experienced this or know of a way to improve it?

Thanks…

I have seen similar comments regarding the lagginess. I think there is maybe too much going on when constantly changing brightness and it going to all the bulbs in your group.

I am presently using my rotary encoder to do a volume control for a media player, but will set it up for a dimmer and see what happens. Don’t hold your breath though, i have a lot on at work.

Yes - happens for me too. It’s more noticeable with esphome than espeasy- I think because the esphome firmware is more efficient hence sending more update messages per second.

I think the issue is the hue api.

I started a post about it:

I will be trying to implement some rate limiting via nodered

I changed the delta from 3 to 10 and it has made a big difference to the smoothness while dimming.
Doesn’t seem to be as much lag either, presumably because the dimmer is not hammering out brightness change requests as quickly causing the Hue bridge to stumble. It’s smooth enough for me now, probably the best it’s going to get.

1 Like

Great project! I’m using (read: stealing) your idea to use in my own setup here.

I currently have some switches that are wired with a neutral, and some that use a switched live. The ones with existing neutral will be easy to configure as you have, and I’ve come up with a solution for those that only have switched live. It basically involves using 2 Sonoff Basics, so may not be the best option, but to my eye it looks like it should work.

I have another question for you though… I understand the control wiring for the KY-040 (rotating and clicking the switch), but I’m getting a bit lost when trying to figure out the power for the KY-040. In the picture with your breadboard, those pins on the KY-040 are connected to the rails. But when making it for real, where have you connected those pins to on the Sonoff?

Sorry for the basic question - I’m new to all of this, but keen to learn!

1 Like

Could this work with sonoff D1??

If you mean whether this can control the D1 dimmer I would guess yes - this is on the assumption that the D1 is like any other smart dimmable lamp that can be controlled by HA. I have used this solution to dim a zigbee dimmer via zigbee2mqtt rather than a bulb.

If you are asking if the D1 can be flashed with ESPHome and work as the controller… I am sorry but I have no idea. At minimum it needs the spare and available IO pins for the rotary encoder.