Skip to main content

In-device scenarios

AirNgin supports scenarios that are stored and executed directly inside the Device, in addition to server-side scenarios that are evaluated in the cloud.

What is an in-device scenario?

An in-device scenario is saved in the Device's local storage and executed locally by firmware. This can provide faster response and keeps the scenario usable without a continuous cloud round trip.

Difference from cloud scenarios

  • Cloud scenario: evaluated/executed by AirNgin server services and depends on cloud connectivity.
  • In-device scenario: stored and executed by the Device firmware.

Your firmware is responsible for persisting, enabling/disabling, and executing the local scenario safely.

Receive scenario definitions

In-device scenarios use dedicated Direct Device topics and must not be confused with DeviceSetting or normal ServerToDevice commands.

Scenario definition/update topic:

projectCode/SendScenarioSetting

This topic currently has no AES variant.

Example definition payload:

{
"operationName": "saveScenario",
"code": 100,
"name": "good night",
"devices": {
"AIRN1234567890": [
{"operationName": "ch1", "value": "off", "delay": 0},
{"operationName": "ch2", "value": "on", "delay": 0}
]
}
}

operationName may request saving or deleting a scenario. code is the scenario identifier used by later execution requests. A Device should store only the entries relevant to itself and should replace a previously stored definition when the same scenario code is updated.

Run, enable, or disable an in-device scenario

Runtime scenario actions arrive through:

projectCode/ReceiveRunScenario

This topic also remains non-AES in the current Direct Device contract.

The firmware should execute only scenarios that are currently valid/enabled according to the received scenario state and the product's local safety rules.