JeffResc / Sonoff-D1-Dimmer

Sonoff D1 Dimmer running ESPHome
https://jeffresc.dev/blog/2020-10-10
MIT License
8 stars 6 forks source link

Dimmer doesn't turn off completely with version 2021.9? #9

Open Protoncek opened 3 years ago

Protoncek commented 3 years ago

Another day, another problem... Today i updated my dimmer with latest version of ESPHome (2021.9.1) program and now dimmer doesn't turn off at all - it stays at appr. 1% no matter what i do. If i turn on/off with button (on gpio4) brightness changes just a tiny bit - like, say from 1% to 0.8% - i can see tiny difference, but won't turn off. Via HA command it goes to any percentage i have it set, but again, it won't go off, but it stays at just under 1%.

ESPHome log however nicely says that it went down to zero. Just it's not true...

Going back to 2021.8.2 solves the problem. Absolutely NO changes made in program...

Now i managed to go back to 2021.8.2 and it works again - luckily i have a parallel "test" installation...

Any clues?

luca-iodice commented 3 years ago

Same problem here

luca-iodice commented 3 years ago

The issue seems to be related to this commit https://github.com/esphome/esphome/pull/2320

larsenglund commented 3 years ago

I have the same problem.

larsenglund commented 3 years ago

It's strange though since the log clearly states that we sending zero brightness into control_dimmer: [15:42:34][D][custom:093]: Interpreting brightness 0.000000 as 0 And that just sends that zero to the dimmer IC via Serial.write so there should be no problem.. hmm..

larsenglund commented 3 years ago

I think I fixed the problem (works for me™), made a pull request for it here https://github.com/JeffResc/Sonoff-D1-Dimmer/pull/10

Protoncek commented 3 years ago

Now it turns off completely, yes, but now there's another problem: when light is off then ESPHome doesn't "see" that and continously thinks that it's on. Condition

if:
  condition:
    light.is_off: pavle_dimmer

always returns false ("ON"), even when light is off. so now i can't turn off light with button, connected to ESPHome (directly, not via HA). Interesting is that state in HA is off, just state inside ESPHome is always ON...

larsenglund commented 3 years ago

@Protoncek indeed, seems that the off-state is not updated when turning off due to zero brightness. I tried adding state->turn_off(); and state->publish_state(); in write_state but that didn't help :(

Protoncek commented 3 years ago

Well, at least i’m glad that you also found the problem and it’s not just me… I hope you (or @JeffResc ) will find the problem. Many thanks!