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
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(
rule.yaml ) for each action. The only difference between them is
payload_schema section of
action section of
sensor.py is almost exactly the same.
Is there a general way to write rules and sensors?