mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 06:17:07 +00:00
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 entity
This commit is contained in:
parent
b70b23ef83
commit
703eea0c93
@ -19,7 +19,6 @@ from homeassistant.helpers import config_validation as cv
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONF_TOPIC = 'topic'
|
CONF_TOPIC = 'topic'
|
||||||
|
|
||||||
DEFAULT_NAME = 'MQTT Camera'
|
DEFAULT_NAME = 'MQTT Camera'
|
||||||
|
|
||||||
DEPENDENCIES = ['mqtt']
|
DEPENDENCIES = ['mqtt']
|
||||||
@ -33,9 +32,13 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||||
"""Set up the MQTT Camera."""
|
"""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):
|
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')
|
r'(?:(?P<node_id>[a-zA-Z0-9_-]+)/)?(?P<object_id>[a-zA-Z0-9_-]+)/config')
|
||||||
|
|
||||||
SUPPORTED_COMPONENTS = [
|
SUPPORTED_COMPONENTS = [
|
||||||
'binary_sensor', 'cover', 'fan', 'light', 'sensor', 'switch', 'lock']
|
'binary_sensor', 'camera', 'cover', 'fan',
|
||||||
|
'light', 'sensor', 'switch', 'lock']
|
||||||
|
|
||||||
ALLOWED_PLATFORMS = {
|
ALLOWED_PLATFORMS = {
|
||||||
'binary_sensor': ['mqtt'],
|
'binary_sensor': ['mqtt'],
|
||||||
|
'camera': ['mqtt'],
|
||||||
'cover': ['mqtt'],
|
'cover': ['mqtt'],
|
||||||
'fan': ['mqtt'],
|
'fan': ['mqtt'],
|
||||||
'light': ['mqtt', 'mqtt_json', 'mqtt_template'],
|
'light': ['mqtt', 'mqtt_json', 'mqtt_template'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user