Skip to content

Interacting with sockets

A SocketMaster represents a device, which controls several sockets. A socket can be switched on or off and can be queried for additional information, such as how much energy has been consumed.

Example - Retrieving all SocketMasters

Use the socketMasters connection either as a root query or nested inside a campsite:

query campsites {
campsites {
edges {
node {
id
label,
socketMasters {
edges {
node {
label
}
}
}
}
}
}
}

This will return a all socket masters, grouped by campsite.

query socketMasters {
socketMasters {
edges {
node {
id
label
}
}
}
}

This will return a all socket masters.

Both options accept additional parameters to filter and/or sort the resulting connection.

Example - Retrieve Socket master for specific campsite

Query all Socket-Masters for a specific site, including associated sockets.

query GetSocketMastersForCampSite {
socketMasters(
filters: {campsite: "Q2FtcHNpdGU6NThjOWI1MDYtZmQ4ZS00YTVlLWE1NjAtMTQwOTQ2Y2YwNWQ5"}
) {
edges {
node {
label
externalId
socketsCount
sockets {
label
id
index
}
}
}
}
}

A possible response could look like this:

{
"data": {
"socketMasters": {
"edges": [
{
"node": {
"label": "A Socket-Master device",
"externalId": "661ecd98-34a5-4624-9693-6d2c4ba891ee",
"socketsCount": 11,
"sockets": [
{
"label": "Socket 1",
"id": "U29ja2V0TWFzdGVyU29ja2V0OjZkMjQ2Njk4LTViZGItNGIxOC1iNTk1LTRlNzdkNmEzNTFjZA==",
"index": 0
},
{
"label": "Socket 2",
"id": "U29ja2V0TWFzdGVyU29ja2V0OjI0NzRiMDc5LTdjZGUtNDRmYS1hNjFiLWQ5MzY0MTVmNGI3Mg==",
"index": 1
},
{
"label": "Socket 3",
"id": "U29ja2V0TWFzdGVyU29ja2V0OjU5YWMwYjQ1LWRhYTUtNDVhZC1iYjNhLWJmYzI1OGQxNjFkYw==",
"index": 2
},
{
"label": "Socket 4",
"id": "U29ja2V0TWFzdGVyU29ja2V0OjBiMTBlZGE4LTkyMzQtNDE0Yy1hOTI5LTczZjUwNWY5NzI1MQ==",
"index": 3
}
]
}
}
]
}
}
}

Example - Switching a socket

To request a socket to switch on or off, use the requestSocketSwitchState mutation:

mutation requestSocketState($socketId: GlobalID!, $state: SocketSwitchState!) {
requestSocketSwitchState(socketId: $socketId, state: $state) {
...on SocketMasterSetSwitchStateCommand {
executionState
id
}
...on OperationInfo {
messages {
kind, message
}
}
}
}

Example variables for the requestSocketSwitchState mutation:

{
"socketId": "U29ja2V0TWFzdGVyU29ja2V0OjZkMjQ2Njk4LTViZGItNGIxOC1iNTk1LTRlNzdkNmEzNTFjZA==",
"state": "OFF"
}

You will receive either a SocketMasterSetSwitchStateCommand to indicate a successful request or a list of messages indicating any errors.