示例#1
0
 def icon(self):
     """Icon to use in the frontend, if any."""
     if self._key == "battery":
         return icon_for_battery_level(
             battery_level=self._device.battery_level_percent,
             charging=self._device.car_state.get("ign", False),
         )
     if self._key == "gsm_lvl":
         return icon_for_signal_level(signal_level=self._device.gsm_level_percent)
     return self._icon
示例#2
0
def test_signal_icon():
    """Test icon generator for signal sensor."""
    from homeassistant.helpers.icon import icon_for_signal_level

    assert icon_for_signal_level(None) == "mdi:signal-cellular-outline"
    assert icon_for_signal_level(0) == "mdi:signal-cellular-outline"
    assert icon_for_signal_level(5) == "mdi:signal-cellular-1"
    assert icon_for_signal_level(40) == "mdi:signal-cellular-2"
    assert icon_for_signal_level(80) == "mdi:signal-cellular-3"
    assert icon_for_signal_level(100) == "mdi:signal-cellular-3"