flespi Assets API
Assets are virtual entities in flespi that represent physical objects or resources that can be monitored by different tracking devices over time. An asset maintains a historical record of its associations with devices, enabling seamless aggregation of telemetry data even when the monitoring device changes. Key features: * Can be linked with one or multiple devices sequentially * Automatically tracks intervals of device associations * Maintains history of which device was linked to the asset at any given time * Can be assigned to calculators to provide access to this history from their expressions * Facilitates transition from device-centric to asset-centric data architecture The primary advantage of assets is their ability to maintain continuous monitoring history regardless of device changes. For example, a trailer asset can aggregate trip data from different trucks that pulled it, driver asset can aggregate trip data from different assigned devices or a vehicle asset can combine telemetry from both its main GPS tracker and a backup beacon device. ###### Asset intervals Asset can be assigned to the specific device on a certain temporal interval by creating corresponding interval using **POST /gw/assets/{assets.selector}/intervals** call. When assignment to the interval is registered, asset automatically merges this assignment into all previously registered intervals and update or delete them accordingly. At certain cases it can even split previously registered intervals onto new smaller parts. Asset maintain a history of such assignments which can be retrieved with **GET /gw/assets/{assets.selector}/intervals**. Each asset interval contains these properties: * **timestamp** - interval registration timestamp; * **begin** - interval begin time; * **end** - interval ending time, may be zero to indicate this interval as unlimited; * **device_id** - device ID connected to this interval, zero device ID is possible and can be interpreted in your application as unassignment; * **meta** - any custom data connected to this interval, maximum 8 KiB of JSON size allowed; Once new asset interval is registered the system automatically in real-time recalculates current intervals and issue interval create, update or delete events to maintain uninterrupted and actual timeline of interval assignments. Such events are published into asset logs and additionally you may track them via MQTT in the corresponding real-time only topics: * **flespi/interval/gw/assets/{asset_id}/created** - asset interval was created; * **flespi/interval/gw/assets/{asset_id}/updated** - asset interval was updated; * **flespi/interval/gw/assets/{asset_id}/deleted** - asset interval was deleted; Last interval registered into the asset is automatically published into retain topic **flespi/state/gw/assets/{asset_id}/last**. You can subscribe to this topic to stay current with the latest device to asset assignment. Interval that is registered into the asset and is active according to current time is automatically published into retain topic **flespi/state/gw/assets/{asset_id}/active**. You can subscribe to this topic to stay current with the currently active device to asset assignment. When active interval is finished MQTT message with null payload is published in the topic. Messages posted in asset MQTT topics contain 'trace' user property which you may use to link actual interval modification event with REST API call that was responsible for it. There is no possibility to delete interval assignment once it is registered but it is possible to replace it with a new interval with zero device_id which your application can correspondingly interpret. When retrieving intervals you may even skip such intervals by using `device_id != 0` filter. ###### Asset logs Table with the list of existing log event codes (event_code property in log record) for asset: Event code | Description -----|------ 1|asset was created via REST API 2|asset was updated via REST API 3|asset was deleted via REST API 4|asset was removed from account(moved to account) 5|asset was restored from recycle bin via REST API 20|asset was blocked, see [customer](/docs/#/platform/customer) for more information 21|asset was unblocked, see [customer](/docs/#/platform/customer) for more information 1600|asset was added to calculator 1601|asset was removed from calculator 1602|asset was added to group 1603|asset was removed from group 1604|posted asset interval registration 1605|asset interval was created 1606|asset interval was updated 1607|asset interval was deleted