Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle boundary condition when selecting battery icon (#235)
We need to be able to handle floating point numbers right on the boundary between two icons. This means our from..to configurations must perfectly align at each end, and the algorithm to select those must not be both less-than-or-equal (<=) AND more-than-or-equal (>=). After this change: >>> get_icon_between(icon_states["battery_charge_level"], 0) 'battery-alert-variant-outline' >>> get_icon_between(icon_states["battery_charge_level"], 9.9) 'battery-alert-variant-outline' >>> get_icon_between(icon_states["battery_charge_level"], 10) 'battery-10' >>> get_icon_between(icon_states["battery_charge_level"], 39) 'battery-30' >>> get_icon_between(icon_states["battery_charge_level"], 39.9) 'battery-30' >>> get_icon_between(icon_states["battery_charge_level"], 39.9999) 'battery-30' >>> get_icon_between(icon_states["battery_charge_level"], 40) 'battery-40' >>> get_icon_between(icon_states["battery_charge_level"], 99.99) 'battery-90' >>> get_icon_between(icon_states["battery_charge_level"], 100) 'battery' >>> get_icon_between(icon_states["battery_charge_level"], 101) 'battery'
- Loading branch information