SMA Guard against older pysma (#18278)
parent
17f04c1736
commit
cff4755708
|
@ -37,11 +37,11 @@ def _check_sensor_schema(conf):
|
||||||
"""Check sensors and attributes are valid."""
|
"""Check sensors and attributes are valid."""
|
||||||
try:
|
try:
|
||||||
import pysma
|
import pysma
|
||||||
except ImportError:
|
valid = [s.name for s in pysma.SENSORS]
|
||||||
|
except (ImportError, AttributeError):
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
valid = list(conf[CONF_CUSTOM].keys())
|
valid.extend(conf[CONF_CUSTOM].keys())
|
||||||
valid.extend([s.name for s in pysma.SENSORS])
|
|
||||||
for sname, attrs in conf[CONF_SENSORS].items():
|
for sname, attrs in conf[CONF_SENSORS].items():
|
||||||
if sname not in valid:
|
if sname not in valid:
|
||||||
raise vol.Invalid("{} does not exist".format(sname))
|
raise vol.Invalid("{} does not exist".format(sname))
|
||||||
|
|
Loading…
Reference in New Issue