SMA Guard against older pysma (#18278)

pull/18296/head
Johann Kellerman 2018-11-07 08:52:51 +02:00 committed by GitHub
parent c89dade619
commit 35ae85e14e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -37,11 +37,11 @@ def _check_sensor_schema(conf):
"""Check sensors and attributes are valid."""
try:
import pysma
except ImportError:
valid = [s.name for s in pysma.SENSORS]
except (ImportError, AttributeError):
return conf
valid = list(conf[CONF_CUSTOM].keys())
valid.extend([s.name for s in pysma.SENSORS])
valid.extend(conf[CONF_CUSTOM].keys())
for sname, attrs in conf[CONF_SENSORS].items():
if sname not in valid:
raise vol.Invalid("{} does not exist".format(sname))