Is it possible to use the same PID Controller again on any device?

Is it possible to use the same PID define inside a rule for any “thing”. Let’s say I defined the PID parameters, and I wanna keep using it without the need to define a new rule for each “thing” each time, or simply by using the same PID controller again after I configured it the first time.

I was thinking I could use one rule and add actions for each newly device added in it, but I don’t think it is a good practice to use one rule for all “things” which could reach a count of 100 or more.

I think there needs to be more details given for us to give a good answer.

By PID are you referring to PID Controller Automation - Automation | openHAB or do you have an actual external device or software that implements the PID? Or have you implemented something yourself?

What rules language?

File based rules or managed rules?

You put Thing in quotes. Does that mean you are actually referring to OH Things? (Note that the add-on I linked to above operates on Items, not Things).

Do your rules for each new “thing” need to do something different?

yes the automation one in OpenHAB.

I write rules using javascript automation binding normally for the actions.

either file or managed rules.

it can be a defined item.

generally I want to use the same PID controller that I’m going to configure in any rule without reconfiguring it again.

If I understand, you have multiple things you want to control based on the same PID trigger.

In file based rules you can define the rule trigger as a global variable. Triggers are just a JS Object and can be defined outside of the context of a JSRule.

In the UI you can click on the Code tab and copy the configured trigger and paste that into the code tab of another rule. But the triggers will remain separate.

configuration: {}
triggers:
  - id: ec386862-6fc4-4aea-a42c-3fc3b31be5dc
    label: PID Controller Trigger
    configuration:
      kp: 1
      loopTime: 1001
      input: AlarmClock
      setpoint: Allspeakersgroup_Idling
      ki: 2
      kd: 3
      kdTimeConstant: 4
      integralMinValue: 6
      integralMaxValue: 7
      pInspector: Allspeakersgroup_Image
      iInspector: Allspeakersgroup_Stop
      dInspector: AllChristmasLights
      eInspector: AllLights
    type: pidcontroller.trigger
conditions: []
actions: []
1 Like

I think something like this. By copying you mean importing the rule trigger?

I literally mean copy and paste.

Open the rule with the configured PID trigger.
Click the Code tab.
Copy the PID trigger.
Open/create the second rule you want to use the same trigger.
Open the Code tab.
Paste the contents of the clipboard.

1 Like