Added `percent` entity to `cpu`.

This commit is contained in:
Fabio Manganiello 2023-04-17 02:22:40 +02:00
parent 711cc2b239
commit b4fbd3e915
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
2 changed files with 7 additions and 0 deletions

View File

@ -792,6 +792,7 @@ class SystemPlugin(SensorPlugin, EntityManager):
'cpu': {
'info': self._cpu_info,
'times': self._cpu_times_avg(),
'percent': self.cpu_percent().output / 100.0, # type: ignore
},
}
)
@ -824,6 +825,11 @@ class SystemPlugin(SensorPlugin, EntityManager):
for key, time_percent in cpu['times'].items()
],
),
PercentSensor(
id='system:cpu:percent',
name='Percent',
value=cpu['percent'],
),
],
)
]

View File

@ -197,6 +197,7 @@ class CpuData:
info: CpuInfo
times: CpuTimes
percent: float = percent_field()
@dataclass