Do not call update() in constructor (#8892)
This commit is contained in:
1 parent
f513f6271e
commit
be94f6e939
5 files changed
+25
-23
No files matched your search
@@ -4,18 +4,18 @@ Allows to configure custom shell commands to turn a value for a sensor.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.command_line/
|
||||
"""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
import subprocess
|
||||
from datetime import timedelta
|
||||
|
||||
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_VALUE_TEMPLATE, CONF_UNIT_OF_MEASUREMENT, CONF_COMMAND,
|
||||
STATE_UNKNOWN)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -42,7 +42,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
value_template.hass = hass
|
||||
data = CommandSensorData(command)
|
||||
|
||||
add_devices([CommandSensor(hass, data, name, unit, value_template)])
|
||||
add_devices([CommandSensor(hass, data, name, unit, value_template)], True)
|
||||
|
||||
|
||||
class CommandSensor(Entity):
|
||||
@@ -53,10 +53,9 @@ class CommandSensor(Entity):
|
||||
self._hass = hass
|
||||
self.data = data
|
||||
self._name = name
|
||||
self._state = STATE_UNKNOWN
|
||||
self._state = None
|
||||
self._unit_of_measurement = unit_of_measurement
|
||||
self._value_template = value_template
|
||||
self.update()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
||||
Reference in new issue
Block a user