Do not call update() in constructor (#8859)

This commit is contained in:
Fabian Affolter authored and Paulus Schoutsen committed 2017-08-06 10:21:55 -07:00
1 parent ac9c1235bb
commit d8ca04a4bc
19 files changed
+43 -57

No files matched your search

+4 -6
View File
@@ -10,12 +10,12 @@ from datetime import timedelta
import requests
import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
CONF_NAME, CONF_MONITORED_VARIABLES, ATTR_ATTRIBUTION)
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['pybbox==0.0.5-alpha']
@@ -23,7 +23,7 @@ _LOGGER = logging.getLogger(__name__)
BANDWIDTH_MEGABITS_SECONDS = 'Mb/s' # type: str
CONF_ATTRIBUTION = "Powered by Bouygues Telecom"
ATTRIBUTION = "Powered by Bouygues Telecom"
DEFAULT_NAME = 'Bbox'
@@ -65,7 +65,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
for variable in config[CONF_MONITORED_VARIABLES]:
sensors.append(BboxSensor(bbox_data, variable, name))
add_devices(sensors)
add_devices(sensors, True)
class BboxSensor(Entity):
@@ -81,8 +81,6 @@ class BboxSensor(Entity):
self.bbox_data = bbox_data
self._state = None
self.update()
@property
def name(self):
"""Return the name of the sensor."""
@@ -107,7 +105,7 @@ class BboxSensor(Entity):
def device_state_attributes(self):
"""Return the state attributes."""
return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION,
ATTR_ATTRIBUTION: ATTRIBUTION,
}
def update(self):