Add icon translations to Syncthing (#112297)

This commit is contained in:
Joost Lekkerkerker 2024-03-05 14:20:50 +01:00 committed by GitHub
parent 2c34c918fc
commit 446314bb27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 23 deletions

View File

@ -20,14 +20,3 @@ EVENTS = {
"StateChanged": STATE_CHANGED_RECEIVED,
"FolderPaused": FOLDER_PAUSED_RECEIVED,
}
FOLDER_SENSOR_ICONS = {
"paused": "mdi:folder-clock",
"scanning": "mdi:folder-search",
"syncing": "mdi:folder-sync",
"idle": "mdi:folder",
}
FOLDER_SENSOR_ALERT_ICON = "mdi:folder-alert"
FOLDER_SENSOR_DEFAULT_ICON = "mdi:folder"

View File

@ -0,0 +1,16 @@
{
"entity": {
"sensor": {
"syncthing": {
"default": "mdi:folder-alert",
"state": {
"unknown": "mdi:folder",
"idle": "mdi:folder",
"scanning": "mdi:folder-search",
"syncing": "mdi:folder-sync",
"paused": "mdi:folder-clock"
}
}
}
}
}

View File

@ -13,9 +13,6 @@ from homeassistant.helpers.event import async_track_time_interval
from .const import (
DOMAIN,
FOLDER_PAUSED_RECEIVED,
FOLDER_SENSOR_ALERT_ICON,
FOLDER_SENSOR_DEFAULT_ICON,
FOLDER_SENSOR_ICONS,
FOLDER_SUMMARY_RECEIVED,
SCAN_INTERVAL,
SERVER_AVAILABLE,
@ -57,6 +54,7 @@ class FolderSensor(SensorEntity):
"""A Syncthing folder sensor."""
_attr_should_poll = False
_attr_translation_key = "syncthing"
STATE_ATTRIBUTES = {
"errors": "errors",
@ -116,15 +114,6 @@ class FolderSensor(SensorEntity):
"""Could the device be accessed during the last update call."""
return self._state is not None
@property
def icon(self):
"""Return the icon for this sensor."""
if self._state is None:
return FOLDER_SENSOR_DEFAULT_ICON
if self.state in FOLDER_SENSOR_ICONS:
return FOLDER_SENSOR_ICONS[self.state]
return FOLDER_SENSOR_ALERT_ICON
@property
def extra_state_attributes(self):
"""Return the state attributes."""