State sensors and custom icons: Convert to binary sensor or what?

I have multiple sensors that are practically binary in nature, but use 0/255 or on/off for their states to represent open/closed. Also, I have a custom value template on an energy monitor that converts floats < 5 (watts) as “off”, otherwise “on”.

What single method works best for all three use cases so that I can set custom state icons?

For example, my 0/255 sensor is just always an eye. My default on/off contact sensor defaults to a door (ironically, since the former sensor can basically only be a door sensor, while this one is in my mailbox…). And then the energy monitor is a washing machine. So I want to set the first as mdi:door-open/mdi:door-closed, the second as the mailbox versions of open/closed, and the latter as the appropriate washing machine mdi icons.

It looks like I could create a binary sensor for all three, but I also thought I could add stuff to customize.yml to modify them though that doesn’t seem to be working. Might be user error/syntax issues. My binary sensor template works fine, but I’m adding yet another entity just so I can add stupid icons, and that seems messy and wasteful. This is really dumb if I’m layering it on top of an already custom state sensor, though I guess refactoring is what I should be doing anyway.

Anyway, what’s the best way to do this? To phrase the root question another way, what’s the best way to customize icons without unnecessarily creating extra entities?

Taking particular note of the device class option to customise your binary sensors.

For the 0/255 sensors your value template will be something like:

value_template: >
  {% if is_state('sensor.your_sensor_here', '255') %}
  {% elif is_state('sensor.your_sensor_here', '0') %}
  {% else %}
  {% endif %}

The simpler template:

value_template: {{ is_state('sensor.your_sensor_here', '0') }}

Will work if you are 100% sure there are no other states than 0 and 255.

If there are no device classes applicable to your sensors you can use the icon_template option.

Unfortunately for me, neither mailboxes nor washing machines are device class options. Also this pattern will be creating two extra entities just for the sake of icons, which is what I was trying to avoid if possible. This does seem to be my only working option I’ve found so far though.

For future readers, that’s a very clean and functioning example. Thank you.