Use dict[key] for required config keys and keys with default values. (#22830)
This commit is contained in:
parent
58220a9448
commit
fa2e07d7c5
1 changed files with 3 additions and 3 deletions
|
@ -26,9 +26,9 @@ DEFAULT_NAME = 'MQTT Camera'
|
|||
DEPENDENCIES = ['mqtt']
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Required(CONF_TOPIC): mqtt.valid_subscribe_topic,
|
||||
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.hass, self._sub_state,
|
||||
{'state_topic': {'topic': self._config.get(CONF_TOPIC),
|
||||
{'state_topic': {'topic': self._config[CONF_TOPIC],
|
||||
'msg_callback': message_received,
|
||||
'qos': self._qos,
|
||||
'encoding': None}})
|
||||
|
@ -121,7 +121,7 @@ class MqttCamera(MqttDiscoveryUpdate, Camera):
|
|||
@property
|
||||
def name(self):
|
||||
"""Return the name of this camera."""
|
||||
return self._config.get(CONF_NAME)
|
||||
return self._config[CONF_NAME]
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue