mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Add entity translations to Flick electric (#95345)
This commit is contained in:
parent
071d3a474f
commit
50e36fbdda
@ -8,7 +8,7 @@ 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_FRIENDLY_NAME, CURRENCY_CENT, UnitOfEnergy
|
from homeassistant.const import CURRENCY_CENT, UnitOfEnergy
|
||||||
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
|
||||||
@ -19,8 +19,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
SCAN_INTERVAL = timedelta(minutes=5)
|
SCAN_INTERVAL = timedelta(minutes=5)
|
||||||
|
|
||||||
FRIENDLY_NAME = "Flick Power Price"
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
@ -36,19 +34,13 @@ class FlickPricingSensor(SensorEntity):
|
|||||||
|
|
||||||
_attr_attribution = "Data provided by Flick Electric"
|
_attr_attribution = "Data provided by Flick Electric"
|
||||||
_attr_native_unit_of_measurement = f"{CURRENCY_CENT}/{UnitOfEnergy.KILO_WATT_HOUR}"
|
_attr_native_unit_of_measurement = f"{CURRENCY_CENT}/{UnitOfEnergy.KILO_WATT_HOUR}"
|
||||||
|
_attr_translation_key = "power_price"
|
||||||
|
_attributes: dict[str, Any] = {}
|
||||||
|
|
||||||
def __init__(self, api: FlickAPI) -> None:
|
def __init__(self, api: FlickAPI) -> None:
|
||||||
"""Entity object for Flick Electric sensor."""
|
"""Entity object for Flick Electric sensor."""
|
||||||
self._api: FlickAPI = api
|
self._api: FlickAPI = api
|
||||||
self._price: FlickPrice = None
|
self._price: FlickPrice = None
|
||||||
self._attributes: dict[str, Any] = {
|
|
||||||
ATTR_FRIENDLY_NAME: FRIENDLY_NAME,
|
|
||||||
}
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of the sensor."""
|
|
||||||
return FRIENDLY_NAME
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
|
@ -19,5 +19,12 @@
|
|||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]"
|
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"sensor": {
|
||||||
|
"power_price": {
|
||||||
|
"name": "Flick power price"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user