How to write rules for multiple/loop items

it’s a PWM template rule created from GUI and then recreated by js223 script = it gives me a rule in GUI with code :

configuration: {}
triggers:

  • id: aa3cd1af-21b2-4ea2-b04b-bdcb4912ad93
    label: PWM Trigger
    configuration:
    deadManSwitch: 50000
    dutycycleItem: HeaterSwitch_dutycycle
    minDutycycle: 0
    interval: 600
    maxDutycycle: 100
    type: pwm.trigger
    conditions: []
    actions:
  • inputs: {}
    id: “1”
    configuration:
    itemName: HeaterSwitch
    type: core.ItemCommandAction
  • inputs: {}
    id: “2”
    configuration:
    type: application/javascript
    type: script.ScriptAction

What i want to accomplish is to build items, PWM, PID, other rules for lets say n number of rooms. The code will go to a loop. Current stage is :
1/ i can create PID,PWM rules from jsr233
2/ i can’t create items at all - js / jsr233 - thining off console command like "echo " Item " >> core.items to get rid of the problem
3/ i can’t do it all in one scripting language :slight_smile:
in your example rule i don’t see the rule type referencje to " .withTypeUID(“pwm.trigger”) "

Why recreate it? For that matter, why not use the PWM add-on?

If you are really after creating a rule template like what is posted to the Marketplace, you must do it all in the UI.

That doesn’t matter at all. When you create rules in text files, all you can see in the UI is that the rule exists. It doesn’t actually reflect the actual rule beyond some metadata about the rule.

I don’t know what that is. I don’t know where it comes from. I don’t know what it does. I can’t tell what is supposed to trigger that rule. Even the whole UI metadata for that rule doesn’t show any triggers for this rule.

That configuration section doesn’t actually do anything in this case. Configuration like that is used when one instantiates a rule from a template to capture the configuration parameters that were filled in. But they don’t do anything functionally. If your intent was to trigger this rule to run when those RadiatorACn Items change or receive commands, your original rule doesn’t do that.

[quote=“rlkoshak, post:23, topic:135094, full:true”]

Why recreate it? For that matter, why not use the PWM add-on?

i am using PWM add-on thas why there is type = pwm.trigger - first was done by GUI, then i moved it to jsr233 because my goal is to automated creation of N PWM rules without GUI. THIS IS WORKING

If you are really after creating a rule template like what is posted to the Marketplace, you must do it all in the UI.

That doesn’t matter at all. When you create rules in text files, all you can see in the UI is that the rule exists. It doesn’t actually reflect the actual rule beyond some metadata about the rule.

not exactly when i use SimpleRule in jsr233 i can add a rule from a file and see this rule in GUI.

I don’t know what that is. I don’t know where it comes from. I don’t know what it does. I can’t tell what is supposed to trigger that rule. Even the whole UI metadata for that rule doesn’t show any triggers for this rule.

it’s from PWM automation module and i know how it works. It was tested and working *from GUI and jsr233 , what i want to do now is move from jsr233 to js rule as u advice at the begining

That configuration section doesn’t actually do anything in this case. Configuration like that is used when one instantiates a rule from a template to capture the configuration parameters that were filled in. But they don’t do anything functionally. If your intent was to trigger this rule to run when those RadiatorACn Items change or receive commands, your original rule doesn’t do that.
[/quote]

ok, i will stay with jsr233 for this PWM and PID rules, but still don’t know how to add items which is crucial for me right now