This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

Is there one rule and sensor that applies to all actions?

Hello,

I’m searching for a general way to write rules and sensors.

For example, I have 2 timing action: action_a, action_b:

**action_a brief definition:**
parameters:
  param_a_1:
    type: object
    required: true
  param_a_2:
    type: object
    required: true
**action_b brief definition:**
parameters:
  param_b_1:
    type: string
    required: true
  param_b_2:
    type: array
    required: true
  param_b_3:
    type: string
    required: true

I save the action and its param as key-value pair(change to yaml for human read) in stackstorm mongodb:

deploy_time: "2021-08-19 23:00"
action: pack1.action_a
params:
  param_a_1:
    key_1: value_1
  param_a_2:
    key_a_2: value_a_2
deploy_time: "2021-08-19 23:00"
action: pack2.action_b
params:
  param_b_1: "string_1"
  param_b_2:
    - object_1
    - object_2
  param_b_3: "string_3"

Then I write a sensor to read stackstorm Datastore. Sensor will compare current system time and deploy_time, if current system time is later than deploy_time, sensor will generate a playload to rule.

As you can image, I have to write 3 very similar file( sensor.py; sensor.yaml; rule.yaml ) for each action. The only difference between them is payload_schema section of sensor.yaml
and action section of rule.yaml.
sensor.py is almost exactly the same.

Is there a general way to write rules and sensors?