pace().from_dict(body["namespace"])
                ns_sig = self.namespace.get_namespace_sig()
                parent_ns_sig = self.namespace.get_namespace_sig(section="PARENT")[
                    "namespace"
                ]

                controller_host = ns_sig["host"]
                controller_name = ns_sig["name"]
                controller_sig = ns_sig["namespace"]

                daq_controller = await self.get_daq_controller(
                    host=controller_host,
                    parent_ns_sig=parent_ns_sig,
                    name=controller_name,
                )

                try:
                    metadata = body["metadata"]
                    await self.update_daq_controller_metadata(daq_controller, metadata)
                    PlotManager.add_apps(metadata)
                # add metadata (measurements, etc)
                except KeyError:
                    pass

                path_list = [
                    self.ui_save_base_path,
                    controller_host,
                    self.namespace.get_namespace_as_path(),
                ]
                self.ui_save_path = os.path.join(*path_list)
                DataManager.open_datafile(self.ui_save_path)

                # add plot apps from metadata

                # namespace = body["namespace"]
                registration = await DAQRegistry.get_registration(
                    # namespace=self.daqserver_namespace, type="Controller"
                    # reg_id=self.controller_id,
                    reg_id=ns_sig,
                    type=Namespace.CONTROLLER,
                )
                # print(f"registration2-get: {registration}")
                # registration2 = await DAQRegistry.register(
                #     namespace=self.daqserver_namespace,
                #     type="DAQServer",
                #     config=body["config"],
                # )
                # print(f"registration2: {registration2}")
                if registration:
                    if body["regkey"]:  # daq running (likely a reconnect)
                        # same: daq_server config takes precedence
                        print(f"body = {body}")
                        if body["regkey"] == registration["regkey"]:
                            registration["config"] = body["config"]
                            # registration["config2"] = body["config2"]
                            # RegistrationManager.update(body['id'], registration)
                            # RegistrationManager.update(daq_namespace, registration, type="DAQServer")
                            registration = await DAQRegistry.update_registration(
                                # namespace=self.daqserver_namespace,
                                # reg_id=self.controller_id,
                                reg_id=ns_sig,
                                # namespace=namespace,
                                namespace=self.namespace.to_dict(),
                                registration=registration,
                                type=Namespace.CONTROLLER,
                            )
                else:  # no reg, no connection to daq since UI start
                    if body["regkey"]:  # daq has been running
                        ui_reconfig_request = True
                        registration = {
                            # "regkey": body["regkey"],
                            "config": body["config"],
                            # "config2": body["config2"],
                        }
                        # RegistrationManager.update(body['id'], registration)
                        # RegistrationManager.update(daq_namespace, registration, type="DAQServer")
                        registration = await DAQRegistry.update_registration(
                            # self.daqserver_namespace, registration, type="Controller"
                            # reg_id=self.controller_id,
                            reg_id=ns_sig,
                            # namespace=namespace,
                            namespace=self.namespace.to_dict(),
                            registration=registration,
                            type=Namespace.CONTROLLER,
                        )
                    else:  # daq has started
                        registration = await DAQRegistry.register(
                            # body['id'],
                            # reg_id=self.controller_id,
                            reg_id=ns_sig,
                            # namespace=namespace,
                            namespace=self.namespace.to_dict(),
                            # self.daqserver_namespace,
                            config=body["config"],
                            # config2=body["config2"],
                            type=Namespace.CONTROLLER,
                        )

                # print("before reply")
                # reply = {
                #     "TYPE": "UI",
                #     "SENDER_ID": "ControllerConsumer",
                #     "TIMESTAMP": dt_to_string(),
                #     "SUBJECT": "REGISTRATION",
                #     "BODY": {
                #         "purpose": "SUCCESS",
                #         "regkey": registration["regkey"],
                #         "config": registration["config"],
                #         "config2": registration["config2"],
                #         "config_requested": config_requested,
                #     },
                # }
                reply = {
                    "TYPE": "UI",
                    "SENDER_ID": "ControllerConsumer",
                    "TIMESTAMP": dt_to_string(),
                    "SUBJECT": "REGISTRATION",
                    "BODY": {
                        "purpose": "SUCCESS",
                        "regkey": registration["regkey"],
                        "config": registration["config"],
                        "config_requested": config_requested,
                    },
                }
                # print(f"reply: {reply}")
                # print(json.dumps(reply))
                await self.daq_message({"message": reply})

                controller_registration_map = await DAQRegistry.get_registry(
                    type=Namespace.CONTROLLER
                )

                msg_body = {
                    "purpose": "REGISTRY",
                    "controller_registry": controller_registration_map,
                    # "controller_registry": controller_registration_map,
                    # "instrument_registry": instrument_registration_map,
                }
                message = Message(
                    msgtype="UI",
                    sender_id="ControllerConsumer",
                    subject="DAQServerRegistry",
                    body=msg_body,
                )
                print(f"message_to_dict: {message.to_dict()}")
                # await self.daq_message(message.to_dict())
                await self.channel_layer.group_send(
                    self.manage_group_name,
                    {
                        "type": "daq_message",
                        "message": message.to_dict()["message"],
                    },
                )

                # body={
                #     "purpose": "ADD",
                #     "key": self.registration_key,
                #     "id": self.daq_id,
                #     "config": self.config,
                # },

            if body["purpose"] == "REMOVE":
                print("remove")
                body = message["BODY"]
                namespace = Namespace().from_dict(body["namespace"])
                ns_sig = namespace.get_namespace_sig()

                # RegistrationManager.remove(body['id'])
                # RegistrationManager.remove(self.namespace, type="Controller")
                await DAQRegistry.unregister(
                    # reg_id=self.controller_id,
                    reg_id=ns_sig,
                    type=Namespace.CONTROLLER,
                )

                reply = {
                    "TYPE": "UI",
                    "SENDER_ID": "ControllerConsumer",
                    "TIMESTAMP": dt_to_string(),
                    "SUBJECT": "UNREGISTRATION",
                    "BODY": {
                        "purpose": "SUCCESS",
                    },
                }
                print(f"success: {reply}")
                await self.daq_message({"message": reply})

                controller_registration_map = await DAQRegistry.get_registry(
                    type=Namespace.CONTROLLER
                )

                msg_body = {
                    "purpose": "REGISTRY",
                    "controller_registry": controller_registration_map,
                    # "controller_registry": controller_registration_map,
                    # "instrument_registry": instrument_registration_map,
                }
                message = Message(
                    msgtype="UI",
                    sender_id="ControllerConsumer",
                    subject="DAQServerRegistry",
                    body=msg_body,
                )
                print(f"message_to_dict: {message.to_dict()}")
                # await self.daq_message(message.to_dict())
                await self.channel_layer.group_send(
                    self.manage_group_name,
                    {
                        "type": "daq_message",
