Enable sensor for discovery (#5974)

* Enable sensor for discovery

* Remove blank line
This commit is contained in:
Fabian Affolter 2017-02-14 08:54:13 +01:00 committed by Paulus Schoutsen
parent 462b47c725
commit f82ac0af60
2 changed files with 7 additions and 4 deletions

View File

@ -20,7 +20,8 @@ _LOGGER = logging.getLogger(__name__)
TOPIC_MATCHER = re.compile(
r'homeassistant/(?P<component>\w+)/(?P<object_id>\w+)/config')
SUPPORTED_COMPONENTS = ['binary_sensor']
SUPPORTED_COMPONENTS = ['binary_sensor', 'sensor']
@callback
@ -39,8 +40,7 @@ def async_start(hass, discovery_topic, hass_config):
try:
payload = json.loads(payload)
except ValueError:
_LOGGER.warning(
"Unable to parse JSON %s: %s", object_id, payload)
_LOGGER.warning("Unable to parse JSON %s: %s", object_id, payload)
return
if component not in SUPPORTED_COMPONENTS:

View File

@ -29,7 +29,10 @@ PLATFORM_SCHEMA = mqtt.MQTT_RO_PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup MQTT Sensor."""
"""Set up MQTT Sensor."""
if discovery_info is not None:
config = PLATFORM_SCHEMA(discovery_info)
value_template = config.get(CONF_VALUE_TEMPLATE)
if value_template is not None:
value_template.hass = hass