ThingFacet Actions

In ThingFacet an Action represents:

  • Device state change, for example, receiving current reading sent by a temperature sensor
  • Device actuation commands, for example, changing the state of the device via updating attribute(s) (e.g. camera rotation, starting a servo motor, reducing the flow of a greenhouse sprayer etc).

Here are some examples:

Action Reading RFID Value
#
Action(name: "NextRfidAction", documentation: "Read next RFID tag"):
  Workflow(Limit: "1", Live: "1", Timeout: "0"):
    Task(name: "Main", while: "true"):
      Event(name: "Argument", as: "ActionArgument")
      Invoke(name: "ReadId", waitFor: "Argument", get: "[%:Event.Argument.URL.Value:%]", StopChar: "0x0D", ReadTimeout: "-1", WriteTimeout: "-1", RepeatDelay: "1")
      Output(name: "Result", as: "ActionResult"):
        Value:
          RFID: "[%:[%:@Output:%]Invoke.ReadId.Message.Value:%]"
Preset Camera
#
Action(name: "SyncPresetAction", documentation: "Synchronize camera state and preset"): 
  Workflow(Limit: "1", Live: "1", Timeout: "PT20S"): 
    Task(name: "Main", while: "true"): 
      Event(name: "Argument", as: "ActionArgument")
      Invoke(name: "SetPreset", waitFor: "Argument", skip-if: "[%:[:AD:].Preset/no-value(Value):%]", delayAfter: "PT5S"
        get: "[%:[:AA:].URL.Value:%]/cgi-bin/decoder_control.cgi?[:UP:][%:amp:%]command=15[%:amp:%]sit=[%:[:AD:].Preset.Value:%]")
      Output(name: "Result", as: "ActionResult"): 
        Value:
          State: "[%:[%:@Output:%]/if([:POK:]) then 'ON' else 'OFF':%]"
          Preset: "[%:[%:@Output:%]/if([:POK:]) then '[%:[:AD:].Preset.Value:%]' else null():%]"
Take Picture From a Camera
#
Action(name: "TakePictureAction", documentation: "Synchronize camera state and snapshot image"): 
  Workflow(Limit: "1", Live: "1", Timeout: "PT10S"): 
    Task(name: "Main", while: "true"): 
      Event(name: "Argument", as: "ActionArgument")
      Invoke(name: "GetImage", waitFor: "Argument", delay: "PT1S", get: "[%:[:AA:].URL.Value:%]/cgi-bin/video_snapshot.cgi?[:UP:]")
      Output(name: "Result", as: "ActionResult"): 
        Value:
          State: "[%:[%:@Output:%]/if([:IOK:]) then 'ON' else 'OFF':%]"
          Image: "[%:[%:@Output:%]/if([:IOK:]) then Invoke/GetImage/Message/Value/text() else '/img/no-image.jpg':%]