def device_set(device_data): """ adds a new device to this endpoint device_data: dictionary of device parameters received """ retval = 0 global devices_dict devices_dict[device_data['type']][device_data['id']].update(device_data) common.create_json_file( devices_dict[device_data['type']][device_data['id']], devices_dict[device_data['type']][device_data['id']]['device_file']) return retval
def device_enable(device_data): """ Enables this device device_data: dictionary of device parameters received """ retval = 0 set_device_state(device_data['type'], device_data['id'], device_states[0]) print 'device enabled', device_data['type'], device_data['id'] common.create_json_file( devices_dict[device_data['type']][device_data['id']], devices_dict[device_data['type']][device_data['id']]['device_file']) #vne::gbd:: dump this into config file as well return retval
def device_add(device_data): """ adds a new device to this endpoint device_data: dictionary of device parameters received Read template json for that device Add other current parameters Dump json data into json file for that device Add device to existing list """ retval = 0 device_id = device_data['id'] device_type = device_data['type'] if 'mode' in device_data and device_data['mode'] == 'simulation': device_data['sim_mode'] = True else: device_data['sim_mode'] = False device_template = templates.get_temperature_template( device_data['sim_mode']) device_template.update(device_data) # Set global device Id device_template['gid'] = config.get_device_global_id( device_type, device_id) device_template['data_topic'] = config.get_publish_id( device_type, 'data', device_id) #device_type['status'] = 'registered' global devices_dict devices_dict[device_type][device_id] = device_template set_device_status(device_type, device_id, device_status[1]) fname = 'device_' + device_id + common.config_ext device_file = common.get_platform_delim().join( [common.get_device_config_dir(), device_type, fname]) device_template['device_file'] = device_file common.create_json_file(device_template, device_file) publish_thread = Thread(target=device_publish_thread, args=(device_type, device_id)) publish_thread.start() print 'device added successfully', device_type, device_id return retval
def device_add(device_data): """ adds a new device to this endpoint device_data: dictionary of device parameters received Read template json for that device Add other current parameters Dump json data into json file for that device Add device to existing list """ retval = 0 #vne::tbd device_template = {} device_template = templates.get_temperature_template() device_template.update(device_data) device_id = device_data['id'] fname = 'device_' + device_id + common.config_ext device_type = device_data['type'] #device_type['status'] = 'registered' global devices_dict devices_dict[device_type][device_id] = device_template set_device_status(device_type, device_id, device_status[1]) device_file = common.get_platform_delim().join( [common.get_device_config_dir(), device_type, fname]) device_template['device_file'] = device_file common.create_json_file(device_template, device_file) publish_thread = Thread(target=device_publish_thread, args=( device_type, device_id, )) publish_thread.start() print 'device added successfully', device_type, device_id return retval