Represents a group in the ESP Rainmaker Neo SDK. Nested groups are also ESPRMNeoGroup instances with parentId set.

Instance methods (attached via prototype in methods/ESPRMNeoGroup/):

  • Membership: addNode, removeNode, getNode, getNodes
  • Lifecycle: updateName, delete, leave, createSubGroup
  • Sharing: share, getSharingInfo, removeMember
  • Params: setParams
  • Schedules: getSchedules, createSchedule, deleteAllSchedules
  • Automation: createAutomation, getAutomation, getAutomations

Implements

Constructors

Properties

accessType?: GroupUserAccessType

How the current user accesses this group (from GET /v1/groups).

groupId: string
groupName: string
nodeDetails: Record<string, NodeCapabilityInfo>
nodeIds: string[]
parentId?: string

Present only when this instance is a nested group (see isChildGroup).

subgroups: ESPRMNeoGroup[]

Methods

  • Creates schedules for multiple nodes in this group.

    For each node, calls PUT /v1/groups/{groupId}/nodes/{nodeId}/schedules.

    Parameters

    • nodeSchedules: { nodeId: string; schedules: ScheduleItem[] }[]

      Array of objects, each containing a nodeId and its schedules.

    Returns Promise<ESPRMNeoSchedule[]>

    A promise that resolves to the created schedules across all nodes.

    If nodeSchedules or schedule data is invalid, or any node is not found.

    If creating schedules fails on one or more nodes.

  • Deletes this group from the cloud.

    Calls:

    • Root group: DELETE /v1/groups/{groupId}
    • Nested subgroup: DELETE /v1/groups/{groupId}/subgroups/{subGroupId}

    After a successful delete this instance is stale. Callers should discard it and drop it from any local caches (for a subgroup, remove it from its parent's subgroups array — the SDK cannot reach the parent from here).

    Returns Promise<ESPAPIResponse>

    A promise that resolves with the API response when the group has been deleted.

    If the deletion fails or the API request fails.

  • Retrieves a specific automation by its ID.

    Calls GET /v1/groups/{groupId}/service/automations/{automationId}.

    Parameters

    • automationId: string

      The ID of the automation to retrieve.

    Returns Promise<ESPRMNeoAutomation>

    A promise that resolves to an ESPRMNeoAutomation instance.

    If the automation is not found or the API request fails.

  • Retrieves a specific node from this group by node ID.

    Cloud paths:

    • Root: GET /v1/groups/{groupId}/nodes/{nodeId}/config
    • Nested: GET /v1/groups/{groupId}/subgroups/{subGroupId}/nodes/{nodeId}/config

    With cache: true (default), uses local storage when present; otherwise fetches from the cloud. With cache: false, always fetches from the cloud.

    Multi-subgroup nodes: call getNode on the root group so all subgroup memberships are discovered for the correct MQTT shadow name.

    Parameters

    Returns Promise<ESPRMNeoNode>

    A promise that resolves to an ESPRMNeoNode instance.

    If the node config could not be resolved.

    If the API request fails.

  • Returns users with access to this group (email, phone number, access type, user id).

    Calls:

    • Root group: GET /v1/groups/{groupId}/users
    • Nested subgroup: GET /v1/groups/{groupId}/subgroups/{subGroupId}/users

    The listing scope is decided by the backend from the caller's access level: primary callers see all members; secondary and subgroup-only callers see only the group's primary owners.

    Returns Promise<GroupSharingInfo>

    A promise that resolves to a GroupSharingInfo.

    If the API request fails.

  • Leaves this group (or subgroup) by removing the current (calling) user.

    Calls the remove-member API with the 'me' path alias so the server resolves the authenticated caller:

    • Root group: DELETE /v1/groups/{groupId}/users/{userId} with userId=me.
    • Nested subgroup: DELETE /v1/groups/{groupId}/subgroups/{subGroupId}/users/{userId} with userId=me.

    The last remaining Primary user cannot leave; the group must always have at least one Primary.

    Returns Promise<ESPAPIResponse>

    A promise that resolves with the API response when the user has left.

    If the request fails, the caller is not a member, or the caller is the last remaining Primary user.

  • Removes another member from this group (or subgroup).

    • Root group: DELETE /v1/groups/{groupId}/users/{userId}.
    • Nested subgroup: DELETE /v1/groups/{groupId}/subgroups/{subGroupId}/users/{userId}.

    To remove the current (calling) user, use ESPRMNeoGroup.leave instead.

    Parameters

    • userId: string

      The ID of the user to remove. Must not be the caller.

    Returns Promise<ESPAPIResponse>

    A promise that resolves with the API response.

    If userId is empty or refers to the caller (use leave()).

  • Removes a node association from this group.

    • Root group: DELETE /v1/groups/{groupId}/nodes/{nodeId} (full disassociation from the group).
    • Nested subgroup: DELETE /v1/groups/{groupId}/subgroups/{subGroupId}/nodes/{nodeId} (removes from the subgroup only).

    Parameters

    • nodeId: string

    Returns Promise<ESPAPIResponse>

  • Shares this group with another user.

    Calls:

    • Root group: POST /v1/groups/{groupId}/sharing-requests
    • Nested subgroup: POST /v1/groups/{groupId}/subgroups/{subGroupId}/sharing-requests

    Parameters

    • options: ShareOptions

      Sharing options.

      Options for sharing a group or subgroup.

      • accessType: "primary" | "secondary"
      • username: string

    Returns Promise<ESPAPIResponse>

    A promise that resolves to the API response.

    If username is missing.

    If the API request fails.

  • Updates the name of this group.

    Calls:

    • Root group: PATCH /v1/groups/{groupId}
    • Nested subgroup: PATCH /v1/groups/{groupId}/subgroups/{subGroupId}

    Parameters

    • newName: string

      The new name for the group.

    Returns Promise<ESPAPIResponse>

    A promise that resolves with the API response when the name is successfully updated.

    If updating the name fails or the API request fails.