From b088830382e0cd18d6a6d4cedcfe915ca6a5b967 Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Sat, 19 Sep 2020 17:34:54 +0200 Subject: [PATCH] Add and use currency cent constant (#40261) --- homeassistant/components/griddy/sensor.py | 4 ++-- homeassistant/components/isy994/const.py | 3 ++- homeassistant/components/nsw_fuel_station/sensor.py | 4 ++-- homeassistant/const.py | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/griddy/sensor.py b/homeassistant/components/griddy/sensor.py index acdcefee527..7a155586fac 100644 --- a/homeassistant/components/griddy/sensor.py +++ b/homeassistant/components/griddy/sensor.py @@ -1,7 +1,7 @@ """Support for August sensors.""" import logging -from homeassistant.const import ENERGY_KILO_WATT_HOUR +from homeassistant.const import CURRENCY_CENT, ENERGY_KILO_WATT_HOUR from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import CONF_LOADZONE, DOMAIN @@ -29,7 +29,7 @@ class GriddyPriceSensor(CoordinatorEntity): @property def unit_of_measurement(self): """Return the unit of measurement.""" - return f"¢/{ENERGY_KILO_WATT_HOUR}" + return f"{CURRENCY_CENT}/{ENERGY_KILO_WATT_HOUR}" @property def name(self): diff --git a/homeassistant/components/isy994/const.py b/homeassistant/components/isy994/const.py index 75c7b3b9de1..7724420f391 100644 --- a/homeassistant/components/isy994/const.py +++ b/homeassistant/components/isy994/const.py @@ -46,6 +46,7 @@ from homeassistant.components.switch import DOMAIN as SWITCH from homeassistant.const import ( AREA_SQUARE_METERS, CONCENTRATION_PARTS_PER_MILLION, + CURRENCY_CENT, CURRENCY_DOLLAR, DEGREE, ENERGY_KILO_WATT_HOUR, @@ -401,7 +402,7 @@ UOM_FRIENDLY_NAME = { UOM_DOUBLE_TEMP: UOM_DOUBLE_TEMP, "102": "kWs", "103": CURRENCY_DOLLAR, - "104": "¢", + "104": CURRENCY_CENT, "105": LENGTH_INCHES, "106": f"mm/{TIME_DAYS}", "107": "", # raw 1-byte unsigned value diff --git a/homeassistant/components/nsw_fuel_station/sensor.py b/homeassistant/components/nsw_fuel_station/sensor.py index 5e9a9835bf4..b6c0d1a5d9b 100644 --- a/homeassistant/components/nsw_fuel_station/sensor.py +++ b/homeassistant/components/nsw_fuel_station/sensor.py @@ -7,7 +7,7 @@ from nsw_fuel import FuelCheckClient, FuelCheckError import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA -from homeassistant.const import ATTR_ATTRIBUTION +from homeassistant.const import ATTR_ATTRIBUTION, CURRENCY_CENT, VOLUME_LITERS import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle @@ -179,7 +179,7 @@ class StationPriceSensor(Entity): @property def unit_of_measurement(self) -> str: """Return the units of measurement.""" - return "¢/L" + return f"{CURRENCY_CENT}/{VOLUME_LITERS}" def update(self): """Update current conditions.""" diff --git a/homeassistant/const.py b/homeassistant/const.py index c35437283cc..f3bb26d3ef0 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -384,6 +384,7 @@ DEGREE = "°" # Currency units CURRENCY_EURO = "€" CURRENCY_DOLLAR = "$" +CURRENCY_CENT = "¢" # Temperature units TEMP_CELSIUS = f"{DEGREE}C"