Migrate CPUSpeed to new entity naming style (#75080)
This commit is contained in:
parent
b62ebbe974
commit
05d2b955ee
2 changed files with 17 additions and 2 deletions
|
@ -7,8 +7,11 @@ from homeassistant.components.sensor import SensorEntity
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import FREQUENCY_GIGAHERTZ
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
ATTR_BRAND = "brand"
|
||||
ATTR_HZ = "ghz_advertised"
|
||||
ATTR_ARCH = "arch"
|
||||
|
@ -30,12 +33,16 @@ class CPUSpeedSensor(SensorEntity):
|
|||
"""Representation of a CPU sensor."""
|
||||
|
||||
_attr_icon = "mdi:pulse"
|
||||
_attr_name = "CPU Speed"
|
||||
_attr_has_entity_name = True
|
||||
_attr_native_unit_of_measurement = FREQUENCY_GIGAHERTZ
|
||||
|
||||
def __init__(self, entry: ConfigEntry) -> None:
|
||||
"""Initialize the CPU sensor."""
|
||||
self._attr_unique_id = entry.entry_id
|
||||
self._attr_device_info = DeviceInfo(
|
||||
name="CPU Speed",
|
||||
identifiers={(DOMAIN, entry.entry_id)},
|
||||
)
|
||||
|
||||
def update(self) -> None:
|
||||
"""Get the latest data and updates the state."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue