def get(self, unique_id): """Show the settings and status for an output""" if not utils_general.user_has_permission('edit_controllers'): abort(403) try: dict_data = get_from_db(OutputSchema, Output, unique_id=unique_id) measure_schema = DeviceMeasurementsSchema() list_data = return_list_of_dictionaries( measure_schema.dump(DeviceMeasurements.query.filter_by( device_id=unique_id).all(), many=True)) control = DaemonControl() output_state = control.output_state(unique_id) return { 'output settings': dict_data, 'output device measurements': list_data, 'output state': output_state }, 200 except Exception: abort(500, message='An exception occurred', error=traceback.format_exc())
def get(self, unique_id): """Show the settings for an function""" if not utils_general.user_has_permission('view_settings'): abort(403) try: list_data = get_from_db(FunctionSchema, CustomController, unique_id=unique_id) function_channel_schema = FunctionChannelSchema() list_channels = return_list_of_dictionaries( function_channel_schema.dump( FunctionChannel.query.filter_by( function_id=unique_id).all(), many=True)) measure_schema = DeviceMeasurementsSchema() list_measurements = return_list_of_dictionaries( measure_schema.dump( DeviceMeasurements.query.filter_by( device_id=unique_id).all(), many=True)) return {'function settings': list_data, 'function channels': list_channels, 'device measurements': list_measurements}, 200 except Exception: abort(500, message='An exception occurred', error=traceback.format_exc())
def get(self, device_id): """Show the settings for all device measurements with the device_id""" if not utils_general.user_has_permission('view_settings'): abort(403) try: measure_schema = DeviceMeasurementsSchema() list_data = return_list_of_dictionaries( measure_schema.dump( DeviceMeasurements.query.filter_by( device_id=device_id).all(), many=True)) if list_data: return {'device measurement settings': list_data}, 200 except Exception: abort(500, message='An exception occurred', error=traceback.format_exc())
def get(self, unique_id): """Show the settings for an input.""" if not utils_general.user_has_permission('view_settings'): abort(403) try: list_data = get_from_db(InputSchema, Input, unique_id=unique_id) measure_schema = InputChannelSchema() list_channels = return_list_of_dictionaries( measure_schema.dump( InputChannel.query.filter_by(input_id=unique_id).all(), many=True)) measure_schema = DeviceMeasurementsSchema() list_measurements = return_list_of_dictionaries( measure_schema.dump(DeviceMeasurements.query.filter_by( device_id=unique_id).join(DeviceMeasurements.conversion, isouter=True).all(), many=True)) return { 'input settings': list_data, 'input channels': list_channels, 'device measurements': list_measurements }, 200 except Exception: abort(500, message='An exception occurred', error=traceback.format_exc())
def get(self, unique_id): """Show the settings for a math""" if not utils_general.user_has_permission('view_settings'): abort(403) try: dict_data = get_from_db(MathSchema, Math, unique_id=unique_id) measure_schema = DeviceMeasurementsSchema() list_data = return_list_of_dictionaries( measure_schema.dump( DeviceMeasurements.query.filter_by( device_id=unique_id).all(), many=True)) return {'math settings': dict_data, 'device measurements': list_data}, 200 except Exception: abort(500, message='An exception occurred', error=traceback.format_exc())