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:
Fabian Affolter
2017-06-05 17:35:26 +02:00
committed by GitHub
parent 2b850f417e
commit 13df925795
12 changed files with 29 additions and 44 deletions

View File

@@ -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):