Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions homeassistant/components/rfxtrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ def _valid_device(value, device_type):
if not len(key) % 2 == 0:
key = '0' + key

if get_rfx_object(key) is None:
raise vol.Invalid('Rfxtrx device {} is invalid: '
'Invalid device id for {}'.format(key, value))
try:
if get_rfx_object(key) is None:
raise vol.Invalid('Rfxtrx device {} is invalid: Invalid'
' device id for {}'.format(key, value))
except ImportError:
_LOGGER.warning('Restart Home Assistant to'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't vol.Invalid be raised? Otherwise a possible invalid configuration could be passed as valid. What consequences would that have for downstream code?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we raise an error here, I think the rfxtrx lib never will be installed?
If the key is invalid the first time HA starts, the rfxtrx component should still load and install the rfxtrx lib, but the switch/sensor with an error will not be loaded.

' validate the rfxtrx config again.')

if device_type == 'sensor':
config[key] = DEVICE_SCHEMA_SENSOR(device)
Expand Down