esphome-configs
esphome-configs copied to clipboard
Using MJ-SD01 for Tessan Dimmer (MJ-SD02) creates flickering LEDs
Thanks for the great resource. As noted, I used the configuration from MJ-SD01 and applied it as is to the Tessan Dimmer (MJ-SD02).
Everything seems to be a perfect mapping. However I noticed that in the "off" state, the LEDs flicker, which I did not notice on the MJ-SD01.
In looking at the configuration, I believe the issue is caused by the lack of nesting of the if
statements in the interval:
if (dimmer_vals.is_on()) {
id(dimmer_lvl) = dimmer_vals.get_brightness();
}
if (id(dimmer_lvl) > .19) { id(led2).turn_on(); }
if (id(dimmer_lvl) < .20) { id(led2).turn_off(); }
if (id(dimmer_lvl) > .39) { id(led3).turn_on(); }
if (id(dimmer_lvl) < .40) { id(led3).turn_off(); }
if (id(dimmer_lvl) > .59) { id(led4).turn_on(); }
if (id(dimmer_lvl) < .60) { id(led4).turn_off(); }
if (id(dimmer_lvl) > .79) { id(led5).turn_on(); }
if (id(dimmer_lvl) < .80) { id(led5).turn_off(); }
if (!dimmer_vals.is_on()) {
id(led2).turn_off();
id(led3).turn_off();
id(led4).turn_off();
id(led5).turn_off();
}
Because the if (id(dimmer_lvl) > .19) { id(led2).turn_on(); }
statements are not in the if (dimmer_vals.is_on())
block the LED lights are briefly toggled on prior to being turned of in the if (!dimmer_vals.is_on())
.
This reorganization addresses the flickering, at least in my case.
if (dimmer_vals.is_on()) {
id(dimmer_lvl) = dimmer_vals.get_brightness();
if (id(dimmer_lvl) > .19) { id(led2).turn_on(); }
if (id(dimmer_lvl) < .20) { id(led2).turn_off(); }
if (id(dimmer_lvl) > .39) { id(led3).turn_on(); }
if (id(dimmer_lvl) < .40) { id(led3).turn_off(); }
if (id(dimmer_lvl) > .59) { id(led4).turn_on(); }
if (id(dimmer_lvl) < .60) { id(led4).turn_off(); }
if (id(dimmer_lvl) > .79) { id(led5).turn_on(); }
if (id(dimmer_lvl) < .80) { id(led5).turn_off(); }
}
if (!dimmer_vals.is_on()) {
id(led2).turn_off();
id(led3).turn_off();
id(led4).turn_off();
id(led5).turn_off();
}
Hope this is helpful.
Again, great resource.