Group Metadata
This section covers operations to manage group metadata and custom data. These operations are performed using an ESPRMGroup instance.
note
To get a group instance, first get the user instance using ESPRMAuth.getLoggedInUser, then use getGroupById or getGroupByName:
try {
const authInstance = ESPRMBase.getAuthInstance();
const userInstance = await authInstance.getLoggedInUser();
if (userInstance) {
// Get group by ID
const group = await userInstance.getGroupById({
groupId: "group_id_123"
});
// Or get group by name
// const group = await userInstance.getGroupByName({
// groupName: "Living Room Devices"
// });
} else {
console.log("No user is currently logged in");
}
} catch (error) {
console.error("Error getting group:", error);
}
Update Metadata
To update the metadata of the current group, use the updateMetadata method.
try {
const metadata = {
room: "kitchen",
floor: 1,
lastUpdated: new Date().toISOString()
};
const response = await group.updateMetadata(metadata);
console.log("Metadata updated successfully:", response);
} catch (error) {
console.error("Error updating metadata:", error);
}