mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use dict[key] for required config keys and keys with default values. (#22830)
This commit is contained in:
parent
58220a9448
commit
fa2e07d7c5
@ -26,9 +26,9 @@ DEFAULT_NAME = 'MQTT Camera'
|
|||||||
DEPENDENCIES = ['mqtt']
|
DEPENDENCIES = ['mqtt']
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
vol.Required(CONF_TOPIC): mqtt.valid_subscribe_topic,
|
vol.Required(CONF_TOPIC): mqtt.valid_subscribe_topic,
|
||||||
vol.Optional(CONF_UNIQUE_ID): cv.string,
|
vol.Optional(CONF_UNIQUE_ID): cv.string,
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ class MqttCamera(MqttDiscoveryUpdate, Camera):
|
|||||||
|
|
||||||
self._sub_state = await subscription.async_subscribe_topics(
|
self._sub_state = await subscription.async_subscribe_topics(
|
||||||
self.hass, self._sub_state,
|
self.hass, self._sub_state,
|
||||||
{'state_topic': {'topic': self._config.get(CONF_TOPIC),
|
{'state_topic': {'topic': self._config[CONF_TOPIC],
|
||||||
'msg_callback': message_received,
|
'msg_callback': message_received,
|
||||||
'qos': self._qos,
|
'qos': self._qos,
|
||||||
'encoding': None}})
|
'encoding': None}})
|
||||||
@ -121,7 +121,7 @@ class MqttCamera(MqttDiscoveryUpdate, Camera):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of this camera."""
|
"""Return the name of this camera."""
|
||||||
return self._config.get(CONF_NAME)
|
return self._config[CONF_NAME]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user