Closed wildekek closed 1 year ago
@ShayBox: I don't think this helps with readability. The protection_status represents an enumerated state, not a binary state. So it would not work for the over current protection state. What is the problem you're trying to solve here?
id(protection_status).state
is an enumerated state, but once you add the condition == 2
it becomes a binary state expression. Instead of checking if the boolean expression and returning true for true and false for false you can just return the expression. It just simplifies the code.
EDIT: For the one you linked it would be lambda: return id(protection_status).state == 2;
Indeed I get it, thanks! What I think makes it even more simple is to specify the enumerated states and publish them inside the protection_status sensor. I'll work on that an push a fix.
I used bitmasking to get the binary sensor states, cleanest solution imo.
This format can be replaced with just
lambda: return id(protection_status).state == 1;
Originally posted by @ShayBox in https://github.com/wildekek/riden-esphome/issues/5#issuecomment-1698852593