def _valid_device(value, device_type):
 config = OrderedDict()
 for (key, device) in value.items():
  if ('packetid' in device.keys()):
   msg = (('You are using an outdated configuration of the rfxtrx ' + 'device, {}.'.format(key)) + ' Your new config should be:\n    {}: \n        name: {}'.format(device.get('packetid'), device.get(ATTR_NAME, 'deivce_name')))
   _LOGGER.warning(msg)
   key = device.get('packetid')
   device.pop('packetid')
  key = str(key)
  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))
  if (device_type == 'sensor'):
   config[key] = DEVICE_SCHEMA_SENSOR(device)
  elif (device_type == 'light_switch'):
   config[key] = DEVICE_SCHEMA(device)
  else:
   raise vol.Invalid('Rfxtrx device is invalid')
  if (not config[key][ATTR_NAME]):
   config[key][ATTR_NAME] = key
 return config

def _valid_device ( value , device_type ) : config = OrderedDict ( ) for ( key , device ) in value . items ( ) : if ( 'packetid' in device . keys ( ) ) : msg = ( ( 'You are using an outdated configuration of the rfxtrx ' + 'device, {}.' . format ( key ) ) + ' Your new config should be:\n    {}: \n        name: {}' . format ( device . get ( 'packetid' ) , device . get ( ATTR_NAME , 'deivce_name' ) ) ) _LOGGER . warning ( msg ) key = device . get ( 'packetid' ) device . pop ( 'packetid' ) key = str ( key ) 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 ) ) if ( device_type == 'sensor' ) : config [ key ] = DEVICE_SCHEMA_SENSOR ( device ) elif ( device_type == 'light_switch' ) : config [ key ] = DEVICE_SCHEMA ( device ) else : raise vol . Invalid ( 'Rfxtrx device is invalid' ) if ( not config [ key ] [ ATTR_NAME ] ) : config [ key ] [ ATTR_NAME ] = key return config
validate a dictionary of devices definitions .