Add more validation for mysensors (#5493)
* Move isdevice validator under helpers.config_validation. * Check that all persistence files are set and are unique if any is set by user. This is necessary to avoid file name clashes. * Check that a set persistence file has an existing and writable directory. * Check that a device is either a valid device file, "mqtt", or a valid domain name or ip address.
This commit is contained in:
1 parent
b57f5728c5
commit
a09a772f43
3 files changed
+61
-20
No files matched your search
@@ -4,7 +4,6 @@ Use serial protocol of Acer projector to obtain state of the projector.
|
||||
For more details about this component, please refer to the documentation
|
||||
at https://home-assistant.io/components/switch.acer_projector/
|
||||
"""
|
||||
import os
|
||||
import logging
|
||||
import re
|
||||
|
||||
@@ -47,17 +46,8 @@ CMD_DICT = {LAMP: '* 0 Lamp ?\r',
|
||||
STATE_OFF: '* 0 IR 002\r'}
|
||||
|
||||
|
||||
def isdevice(dev):
|
||||
"""Check if dev a real device."""
|
||||
try:
|
||||
os.stat(dev)
|
||||
return str(dev)
|
||||
except OSError:
|
||||
raise vol.Invalid("No device found!")
|
||||
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_FILENAME): isdevice,
|
||||
vol.Required(CONF_FILENAME): cv.isdevice,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int,
|
||||
vol.Optional(CONF_WRITE_TIMEOUT, default=DEFAULT_WRITE_TIMEOUT):
|
||||
|
||||
Reference in new issue
Block a user