mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Enable sensor for discovery (#5974)
* Enable sensor for discovery * Remove blank line
This commit is contained in:
parent
462b47c725
commit
f82ac0af60
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user