mirror of
https://github.com/home-assistant/core.git
synced 2025-12-02 22:18:08 +00:00
Do not call update() in constructor (#7912)
* Do not call update() in constructor * Do not call update() in constructor * Remove unused import
This commit is contained in:
@@ -8,9 +8,9 @@ import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
REQUIREMENTS = ['py-cpuinfo==3.2.0']
|
||||
@@ -22,6 +22,7 @@ ATTR_HZ = 'GHz Advertised'
|
||||
ATTR_ARCH = 'arch'
|
||||
|
||||
DEFAULT_NAME = 'CPU speed'
|
||||
|
||||
ICON = 'mdi:pulse'
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
@@ -34,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up the CPU speed sensor."""
|
||||
name = config.get(CONF_NAME)
|
||||
|
||||
add_devices([CpuSpeedSensor(name)])
|
||||
add_devices([CpuSpeedSensor(name)], True)
|
||||
|
||||
|
||||
class CpuSpeedSensor(Entity):
|
||||
@@ -44,8 +45,8 @@ class CpuSpeedSensor(Entity):
|
||||
"""Initialize the sensor."""
|
||||
self._name = name
|
||||
self._state = None
|
||||
self.info = None
|
||||
self._unit_of_measurement = 'GHz'
|
||||
self.update()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
||||
Reference in New Issue
Block a user