mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +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
|
# Service call validation schema
|
||||||
def _mqtt_topic(value, invalid_chars='\0'):
|
def valid_subscribe_topic(value, invalid_chars='\0'):
|
||||||
"""Validate MQTT topic."""
|
"""Validate that we can subscribe using this MQTT topic."""
|
||||||
if isinstance(value, str) and all(c not in value for c in invalid_chars):
|
if isinstance(value, str) and all(c not in value for c in invalid_chars):
|
||||||
return vol.Length(min=1, max=65535)(value)
|
return vol.Length(min=1, max=65535)(value)
|
||||||
raise vol.Invalid('Invalid MQTT topic name')
|
raise vol.Invalid('Invalid MQTT topic name')
|
||||||
@ -97,13 +97,7 @@ def _mqtt_topic(value, invalid_chars='\0'):
|
|||||||
|
|
||||||
def valid_publish_topic(value):
|
def valid_publish_topic(value):
|
||||||
"""Validate that we can publish using this MQTT topic."""
|
"""Validate that we can publish using this MQTT topic."""
|
||||||
return _mqtt_topic(value, invalid_chars='#+\0')
|
return valid_subscribe_topic(value, invalid_chars='#+\0')
|
||||||
|
|
||||||
|
|
||||||
def valid_subscribe_topic(value):
|
|
||||||
"""Validate that we can subscribe using this MQTT topic."""
|
|
||||||
return _mqtt_topic(value)
|
|
||||||
|
|
||||||
|
|
||||||
MQTT_PUBLISH_SCHEMA = vol.Schema({
|
MQTT_PUBLISH_SCHEMA = vol.Schema({
|
||||||
vol.Required(ATTR_TOPIC): valid_publish_topic,
|
vol.Required(ATTR_TOPIC): valid_publish_topic,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user