mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Upgrade py-cpuinfo to 7.0.0 (#39155)
This commit is contained in:
parent
7874711936
commit
c86c522eb1
@ -2,6 +2,6 @@
|
|||||||
"domain": "cpuspeed",
|
"domain": "cpuspeed",
|
||||||
"name": "CPU Speed",
|
"name": "CPU Speed",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/cpuspeed",
|
"documentation": "https://www.home-assistant.io/integrations/cpuspeed",
|
||||||
"requirements": ["py-cpuinfo==5.0.0"],
|
"requirements": ["py-cpuinfo==7.0.0"],
|
||||||
"codeowners": ["@fabaff"]
|
"codeowners": ["@fabaff"]
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@ from homeassistant.helpers.entity import Entity
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTR_BRAND = "Brand"
|
ATTR_BRAND = "brand"
|
||||||
ATTR_HZ = "GHz Advertised"
|
ATTR_HZ = "ghz_advertised"
|
||||||
ATTR_ARCH = "arch"
|
ATTR_ARCH = "arch"
|
||||||
|
|
||||||
HZ_ACTUAL_RAW = "hz_actual_raw"
|
HZ_ACTUAL = "hz_actual"
|
||||||
HZ_ADVERTISED_RAW = "hz_advertised_raw"
|
HZ_ADVERTISED = "hz_advertised"
|
||||||
|
|
||||||
DEFAULT_NAME = "CPU speed"
|
DEFAULT_NAME = "CPU speed"
|
||||||
|
|
||||||
@ -30,7 +30,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the CPU speed sensor."""
|
"""Set up the CPU speed sensor."""
|
||||||
name = config[CONF_NAME]
|
name = config[CONF_NAME]
|
||||||
|
|
||||||
add_entities([CpuSpeedSensor(name)], True)
|
add_entities([CpuSpeedSensor(name)], True)
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ class CpuSpeedSensor(Entity):
|
|||||||
"""Representation of a CPU sensor."""
|
"""Representation of a CPU sensor."""
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the CPU sensor."""
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = None
|
self._state = None
|
||||||
self.info = None
|
self.info = None
|
||||||
@ -62,10 +61,12 @@ class CpuSpeedSensor(Entity):
|
|||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
if self.info is not None:
|
if self.info is not None:
|
||||||
attrs = {ATTR_ARCH: self.info["arch"], ATTR_BRAND: self.info["brand"]}
|
attrs = {
|
||||||
|
ATTR_ARCH: self.info["arch_string_raw"],
|
||||||
if HZ_ADVERTISED_RAW in self.info:
|
ATTR_BRAND: self.info["brand_raw"],
|
||||||
attrs[ATTR_HZ] = round(self.info[HZ_ADVERTISED_RAW][0] / 10 ** 9, 2)
|
}
|
||||||
|
if HZ_ADVERTISED in self.info:
|
||||||
|
attrs[ATTR_HZ] = round(self.info[HZ_ADVERTISED][0] / 10 ** 9, 2)
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -75,9 +76,8 @@ class CpuSpeedSensor(Entity):
|
|||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest data and updates the state."""
|
"""Get the latest data and updates the state."""
|
||||||
|
|
||||||
self.info = cpuinfo.get_cpu_info()
|
self.info = cpuinfo.get_cpu_info()
|
||||||
if HZ_ACTUAL_RAW in self.info:
|
if HZ_ACTUAL in self.info:
|
||||||
self._state = round(float(self.info[HZ_ACTUAL_RAW][0]) / 10 ** 9, 2)
|
self._state = round(float(self.info[HZ_ACTUAL][0]) / 10 ** 9, 2)
|
||||||
else:
|
else:
|
||||||
self._state = None
|
self._state = None
|
||||||
|
@ -1157,7 +1157,7 @@ py-august==0.25.0
|
|||||||
py-canary==0.5.0
|
py-canary==0.5.0
|
||||||
|
|
||||||
# homeassistant.components.cpuspeed
|
# homeassistant.components.cpuspeed
|
||||||
py-cpuinfo==5.0.0
|
py-cpuinfo==7.0.0
|
||||||
|
|
||||||
# homeassistant.components.melissa
|
# homeassistant.components.melissa
|
||||||
py-melissa-climate==2.0.0
|
py-melissa-climate==2.0.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user