Computed Attributes

shahab 3 years ago

Hello everyone,
I am exploring computed attributes and cannot able to identify where can i see that
in computed attributes docs it says "Computed attributes are applied to all incoming positions of a linked device."
as per my understanding if I assigned a computed attribute to a device then it will come in position websocket message.
if not the case then please tell me how and where can i use this like rest api of something else?

Anton Tananaev 3 years ago

I don't really understand the question. Computed attributes are expression that are executed when you receive some data from a device. There's an API to create and assign them. Hopefully it clarified what they're.

shahab 3 years ago

where can i access the result of the execution
for example
i have to calculate voltage from speed by some formula and i want this voltage to be realtime as speed will change and based on that voltage has to be changed

Anton Tananaev 3 years ago

The results are in the position attributes, like all the other data that's coming from devices.

shahab 3 years ago

It is not coming in my case
I have created a computed attribute which takes speed and multiple it with number to get voltage( image attached below)
https://imgtr.ee/i/screenshot-2023-06-06-100157-pm.pOIMY
I have attached this to a device and but when i check websocket message of that device, i wasn't able to find one
This is that device websocket position message

{
  "positions": [
    {
      "id": 61867948,
      "attributes": {
        "channel.id": 54861,
        "ignition": true,
        "gnss.realtime.status": true,
        "gsm.cellid": 51602,
        "gsm.lac": 5067,
        "gsm.mcc": 404,
        "gsm.mnc": 49,
        "ident": "358979100209983",
        "peer": "106.211.165.226:19840",
        "sat": 15,
        "protocol.id": 13,
        "protocol.number": 34,
        "report.reason": 0,
        "server.timestamp": 1686069262.951667,
        "distance": 39.12,
        "totalDistance": 11586855,
        "motion": true,
        "hours": 539232000
      },
      "deviceId": 182,
      "serverTime": "2023-06-06T16:34:23.400+00:00",
      "deviceTime": "2023-06-06T16:34:22.000+00:00",
      "fixTime": "2023-06-06T16:34:22.000+00:00",
      "outdated": false,
      "valid": true,
      "latitude": 17.46969,
      "longitude": 78.363884,
      "altitude": 0,
      "speed": 12.958968,
      "course": 233,
      "address": null,
      "accuracy": 0,
      "network": null
    }
  ]
}

I want a key named voltage in this websocket position message

Anton Tananaev 3 years ago

It probably means you haven't linked the attribute to your device.

shahab 3 years ago

Just again check it with the new message and it's working
Thank you