From dc7c300884a60b4dde4a0b8b55a79c56b9619cbe Mon Sep 17 00:00:00 2001 From: Kaden Napper Date: Sun, 27 Sep 2026 18:49:08 +1000 Subject: [PATCH] Fix monetary sensor compatibility --- custom_components/up_banking/const.py | 2 ++ custom_components/up_banking/sensor.py | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/custom_components/up_banking/const.py b/custom_components/up_banking/const.py index 8ff5f79..88333c7 100644 --- a/custom_components/up_banking/const.py +++ b/custom_components/up_banking/const.py @@ -10,3 +10,5 @@ DEFAULT_SCAN_INTERVAL = timedelta(minutes=5) STORAGE_VERSION = 1 STORAGE_KEY = f"{DOMAIN}.seen_transactions" API_URL = "https://api.up.com.au/api/v1" +# Home Assistant's monetary device class requires the ISO 4217 code internally. +CURRENCY_CODE = "AUD" diff --git a/custom_components/up_banking/sensor.py b/custom_components/up_banking/sensor.py index 0ab851b..390f989 100644 --- a/custom_components/up_banking/sensor.py +++ b/custom_components/up_banking/sensor.py @@ -6,13 +6,12 @@ from typing import Any from homeassistant.components.sensor import SensorDeviceClass, SensorEntity, SensorStateClass from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CURRENCY_AUSTRALIAN_DOLLAR from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity -from .const import DOMAIN +from .const import CURRENCY_CODE, DOMAIN from .coordinator import UpCoordinator @@ -24,7 +23,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry, async_add_e class UpBalanceSensor(CoordinatorEntity[UpCoordinator], SensorEntity): _attr_device_class = SensorDeviceClass.MONETARY _attr_state_class = SensorStateClass.TOTAL - _attr_native_unit_of_measurement = CURRENCY_AUSTRALIAN_DOLLAR + _attr_native_unit_of_measurement = CURRENCY_CODE _attr_has_entity_name = True def __init__(self, coordinator: UpCoordinator, account_id: str) -> None: