Add and use currency cent constant (#40261)

This commit is contained in:
springstan 2020-09-19 17:34:54 +02:00 committed by GitHub
parent 7de1fe7416
commit b088830382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View File

@ -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):

View File

@ -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

View File

@ -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."""

View File

@ -384,6 +384,7 @@ DEGREE = "°"
# Currency units
CURRENCY_EURO = ""
CURRENCY_DOLLAR = "$"
CURRENCY_CENT = "¢"
# Temperature units
TEMP_CELSIUS = f"{DEGREE}C"