Enable autodiscovery for mqtt cameras (#13697)
* Enable autodiscovery for mqtt cameras, BREAKING CHANGE: homogenisation topic->state_topic * fix line too long * fix topic->state_topic in test * image shall not be the state of entitypull/13713/head
parent
b70b23ef83
commit
703eea0c93
|
@ -19,7 +19,6 @@ from homeassistant.helpers import config_validation as cv
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_TOPIC = 'topic'
|
||||
|
||||
DEFAULT_NAME = 'MQTT Camera'
|
||||
|
||||
DEPENDENCIES = ['mqtt']
|
||||
|
@ -33,9 +32,13 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up the MQTT Camera."""
|
||||
topic = config[CONF_TOPIC]
|
||||
if discovery_info is not None:
|
||||
config = PLATFORM_SCHEMA(discovery_info)
|
||||
|
||||
async_add_devices([MqttCamera(config[CONF_NAME], topic)])
|
||||
async_add_devices([MqttCamera(
|
||||
config.get(CONF_NAME),
|
||||
config.get(CONF_TOPIC)
|
||||
)])
|
||||
|
||||
|
||||
class MqttCamera(Camera):
|
||||
|
|
|
@ -20,10 +20,12 @@ TOPIC_MATCHER = re.compile(
|
|||
r'(?:(?P<node_id>[a-zA-Z0-9_-]+)/)?(?P<object_id>[a-zA-Z0-9_-]+)/config')
|
||||
|
||||
SUPPORTED_COMPONENTS = [
|
||||
'binary_sensor', 'cover', 'fan', 'light', 'sensor', 'switch', 'lock']
|
||||
'binary_sensor', 'camera', 'cover', 'fan',
|
||||
'light', 'sensor', 'switch', 'lock']
|
||||
|
||||
ALLOWED_PLATFORMS = {
|
||||
'binary_sensor': ['mqtt'],
|
||||
'camera': ['mqtt'],
|
||||
'cover': ['mqtt'],
|
||||
'fan': ['mqtt'],
|
||||
'light': ['mqtt', 'mqtt_json', 'mqtt_template'],
|
||||
|
|
Loading…
Reference in New Issue