Entities Functions


Indéx navigation

Read Functions.

Get Entity Attribute Value.

Example

cb.getEntityAttributeValue("Room1", "temperature")
.then((result) => console.log(result))
.catch((err) => console.log(err))

Get Entity Attribute.

Example

cb.getEntityAttribute("Room1", "temperature")
.then((result) => console.log(result))
.catch((err) => console.log(err))

Get Entity Attributes.

Example

cb.getEntityAttrs("Room1")
.then((result) => console.log(result))
.catch((err) => console.log(err))

Get Entity.

Example

cb.getEntity('Room1')
.then((result) => console.log(result))
.catch((err) => console.log(err))

Get entities list of an entity type.

Example

cb.getEntityListType('Room')
.then((entities) => {console.log(entities)})
.catch((err) => console.log(err))

Get All Entities.

Example

cb.listEntities()
.then((entities) => {console.log(entities)})
.catch((err) => console.log(err))

Create Functions.

Create Entity.

Example

cb.createEntity({
    "id": "Room1",
    "temperature": {
        "metadata": {
            "accuracy": {
                "type": "Number",
                "value": 0.8
            }
        },
        "type": "Number",
        "value": 26.5
    },
    "type": "Room"
}).then((result) => console.log(result))
.catch((err) => console.log(err))

Update Functions.

Update Entity Attribute Value.

Example

cb.updateEntityAttributeValue('Room1', 'temperature', 16)
.then((result) => {console.log(result)})
.catch((err) => console.log(err))

Update Attribute Data.

Example

cb.updateJSONAttrEntity('Room1', 'temperature', {
    "type": "Number",
    "value": 34.982398
})
.then((result) => console.log(result))
.catch((err) => console.log(err))

Replace All Entity Attributes.

Example

cb.replaceAllEntityAttributes("RoomTest", {
    "pressure": {
        "value": 720,
        "type": "Integer"
    }
})
.then((result) => console.log(result))
.catch((err) => console.log(err))

Update Existing Entity Attributes.

Example

cb.updateEntityAttrs('Room1', { 
    "temperature": {
        "value": 75.9345,
        "type": "Float"
    }
})
.then((result) => console.log(result))
.catch((err) => console.log(err))

Update Or Append Entity Attributes.

Example

cb.addJSONAttributeToEntity("Room1",{
    "pressure":{
              "value": 90,
              "type": "Integer"
        }
})
.then((result) => console.log(result))
.catch((err) => console.log(err))

Delete Functions.

Delete Entity.

Example

cb.deleteEntity("Room1")
.then((result) => console.log(result))
.catch((err) => console.log(err))

Delete Entity Attribute.

cb.deleteEntityAttribute("RoomTest", "pressure")
.then((result) => console.log(result))
.catch((err) => console.log(err))