diff --git a/custom_components/aliexpress_openplatform/sensor.py b/custom_components/aliexpress_openplatform/sensor.py index 22c0939..6830294 100644 --- a/custom_components/aliexpress_openplatform/sensor.py +++ b/custom_components/aliexpress_openplatform/sensor.py @@ -11,7 +11,6 @@ SensorEntityDescription, SensorStateClass, ) -from homeassistant.const import CURRENCY_EURO from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, DataUpdateCoordinator, @@ -26,10 +25,12 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant + from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import StateType _LOGGER = logging.getLogger(__name__) +CURRENCY_USD = "$" async def async_setup_entry( @@ -166,7 +167,7 @@ class AliexpressCommissionsSensor(SensorEntity, CoordinatorEntity): """Sensor for tracking total commissions earned.""" def __init__(self, coordinator: AliexpressOpenPlatformCoordinator) -> None: - """Initialize the Total commissions' sensor.""" + """Initialize the Total commissions sensor.""" super().__init__(coordinator) self._attr_unique_id = "aliexpress_total_commissions" self.entity_description = SensorEntityDescription( @@ -174,9 +175,20 @@ def __init__(self, coordinator: AliexpressOpenPlatformCoordinator) -> None: key="aliexpress_total_commissions", icon="mdi:cash-multiple", state_class=SensorStateClass.TOTAL_INCREASING, - native_unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_USD, ) + @property + def device_info(self) -> DeviceInfo | None: + """Return device information for this sensor.""" + return { + "identifiers": {(DOMAIN, "aliexpress_device")}, + "name": "Aliexpress OpenPlatform", + "manufacturer": "Aliexpress", + "model": "OpenPlatform API", + "configuration_url": "https://portals.aliexpress.com", + } + @property def native_value(self) -> StateType | date | datetime | Decimal: """Return the total commissions if data is available.""" @@ -210,6 +222,16 @@ def __init__(self, coordinator: AliexpressOpenPlatformCoordinator) -> None: state_class=SensorStateClass.TOTAL_INCREASING, ) + @property + def device_info(self) -> DeviceInfo | None: + """Return device information for this sensor.""" + return { + "identifiers": {(DOMAIN, "aliexpress_device")}, + "name": "Aliexpress OpenPlatform", + "manufacturer": "Aliexpress", + "model": "OpenPlatform API", + } + @property def native_value(self) -> StateType | date | datetime | Decimal: """Return the total number of orders if data is available.""" @@ -239,9 +261,19 @@ def __init__(self, coordinator: AliexpressOpenPlatformCoordinator) -> None: key="aliexpress_total_paid", icon="mdi:currency-usd", state_class=SensorStateClass.TOTAL_INCREASING, - native_unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_USD, ) + @property + def device_info(self) -> DeviceInfo | None: + """Return device information for this sensor.""" + return { + "identifiers": {(DOMAIN, "aliexpress_device")}, + "name": "Aliexpress OpenPlatform", + "manufacturer": "Aliexpress", + "model": "OpenPlatform API", + } + @property def native_value(self) -> StateType | date | datetime | Decimal: """Return the total amount paid by customers if data is available."""