mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Rename _mqtt_topic to valid_subscribe_topic.
This commit is contained in:
parent
29a8403741
commit
4e864b5caa
@ -88,8 +88,8 @@ MQTT_BASE_PLATFORM_SCHEMA = vol.Schema({
|
||||
|
||||
|
||||
# Service call validation schema
|
||||
def _mqtt_topic(value, invalid_chars='\0'):
|
||||
"""Validate MQTT topic."""
|
||||
def valid_subscribe_topic(value, invalid_chars='\0'):
|
||||
"""Validate that we can subscribe using this MQTT topic."""
|
||||
if isinstance(value, str) and all(c not in value for c in invalid_chars):
|
||||
return vol.Length(min=1, max=65535)(value)
|
||||
raise vol.Invalid('Invalid MQTT topic name')
|
||||
@ -97,13 +97,7 @@ def _mqtt_topic(value, invalid_chars='\0'):
|
||||
|
||||
def valid_publish_topic(value):
|
||||
"""Validate that we can publish using this MQTT topic."""
|
||||
return _mqtt_topic(value, invalid_chars='#+\0')
|
||||
|
||||
|
||||
def valid_subscribe_topic(value):
|
||||
"""Validate that we can subscribe using this MQTT topic."""
|
||||
return _mqtt_topic(value)
|
||||
|
||||
return valid_subscribe_topic(value, invalid_chars='#+\0')
|
||||
|
||||
MQTT_PUBLISH_SCHEMA = vol.Schema({
|
||||
vol.Required(ATTR_TOPIC): valid_publish_topic,
|
||||
|
Loading…
x
Reference in New Issue
Block a user