rstrouse / relayEquipmentManager

A hardware controller for GPIO, I2c, SPI, and generic devices.
GNU General Public License v3.0
38 stars 19 forks source link

Trigger Statement #79

Open dakowals opened 3 months ago

dakowals commented 3 months ago

I am trying to have an input from my SM BAS control an output relay as a safety. I have a relay named "Flow Out" control operation of my SWG. I also have an input "Flow In" to tell me there is flow in the system for various other functions. Both states are sent to my poolController. How can I have the input(BAS) automatically control the output(relay) whenever the input is active. I'm sure there are several ways to accomplish this. Both are features on my poolController main page. I would like to use a trigger to control this, but I am unsure of the language to use. I am not very familiar. Can someone please help. Thanks, Screenshot 2024-08-19 201024 Screenshot 2024-08-19 201108 Screenshot 2024-08-19 201238

rstrouse commented 3 months ago

Are you trying to turn on a relay when there is flow on the chlorinator? Unfortunately, that output is probably not what you are expecting.

Triggers on a relay change the state of the relay and they work like this. When an event is received on the connection socket it will capture that event. In this case the feature event that is sent when the feature state information changes. Then filters are applied to check to see if the payload of the event is for the specific trigger. For instance if you define a filter for the name == AutoFill and the name attribute on the event payload it will not ignore the trigger.

This is an example of the event that is sent when the feature is turned on. If the event was turning the feature off it would have the isOn set to false.

{
      "id": 129,
      "freezeProtect": false,
      "isOn": true,
      "name": "Feature 1",
      "type": {
          "val": 0,
          "name": "generic",
          "desc": "Generic"
      },
      "showInFeatures": true,
      "endTime": "2024-08-24T21:13:26.484-0700"
 }

Now for the binding. If you want to conditionally set the relay state to on when the feature is on then you would simply set the expression on the binding to. The binding expression is javascript and the data object is the socket payload.

return data.isOn;