Fix units for Flick Electric sensor (#69396)

pull/69415/head
Brynley McDonald 2022-04-06 21:57:06 +12:00 committed by GitHub
parent a3e0a1d04d
commit 38cfa83e23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -7,7 +7,12 @@ from pyflick import FlickAPI, FlickPrice
from homeassistant.components.sensor import SensorEntity from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION, ATTR_FRIENDLY_NAME from homeassistant.const import (
ATTR_ATTRIBUTION,
ATTR_FRIENDLY_NAME,
CURRENCY_CENT,
ENERGY_KILO_WATT_HOUR,
)
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
@ -20,7 +25,6 @@ SCAN_INTERVAL = timedelta(minutes=5)
ATTRIBUTION = "Data provided by Flick Electric" ATTRIBUTION = "Data provided by Flick Electric"
FRIENDLY_NAME = "Flick Power Price" FRIENDLY_NAME = "Flick Power Price"
UNIT_NAME = "cents"
async def async_setup_entry( async def async_setup_entry(
@ -35,7 +39,7 @@ async def async_setup_entry(
class FlickPricingSensor(SensorEntity): class FlickPricingSensor(SensorEntity):
"""Entity object for Flick Electric sensor.""" """Entity object for Flick Electric sensor."""
_attr_native_unit_of_measurement = UNIT_NAME _attr_native_unit_of_measurement = f"{CURRENCY_CENT}/{ENERGY_KILO_WATT_HOUR}"
def __init__(self, api: FlickAPI) -> None: def __init__(self, api: FlickAPI) -> None:
"""Entity object for Flick Electric sensor.""" """Entity object for Flick Electric sensor."""