Announcement

Collapse
No announcement yet.

Device value conditions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Device value conditions

    Hey guys !

    We are trying to set an event with conditional device value instead of specific values like (...in the range or less than ).

    Basically, we created virtual devices for some special setpoints we adjust via hstouch. The virtual device holds the correct value that can be changed via touch.

    We want an event to trigger at a specific device status but conditionnaly to this variable setpoint. The conditions only offer specific ranges or values but we need to read the virtual device's value in order for it to work.

    We could probably have a simple script to do this in the actions instead of using the generic trigger conditions. Im sure someone has written this script but cant find any references for it in the forums.

    Can someone point me to a good thread or the script directly ?

    Thx ahead !

    #2
    Anyone can point me to an existing script ? Thx guys

    Comment


      #3
      with HS3, the C# script below should work:

      Code:
      public object Main(object[] parms)
      {
          string[] parmsArray = parms[0].ToString().Split(new Char [] {','});
          
          int dvRef1 = Convert.ToInt32(parmsArray[0]);
          int dvRef2 = Convert.ToInt32(parmsArray[1]);
          string eventToTrigger = parmsArray[2];
          
          if(hs.DeviceValueEx(dvRef1) == hs.DeviceValueEx(dvRef2))
          {
              hs.TriggerEvent(eventToTrigger);
          }
      
          return 0;
      }
      call the script with 3 parameters separated by comas. First and second parameters are ref# of device to compare, third parameter is the event to run when they are equal.

      Comment


        #4
        Thats great Spud! Exactly what I need but will it work under hs2, I am still running this version until all plugins are migrated. Thx a lot !

        Comment


          #5
          Originally posted by loowee View Post
          Thats great Spud! Exactly what I need but will it work under hs2, I am still running this version until all plugins are migrated. Thx a lot !
          I believe it would need to be slightly adapted to work with HS2.

          Comment


            #6
            Thx Spud !

            Ok, we've tried it Under HS2 and it gives us syntax errors, can you confirm what would be different in HS2 ?

            Also, if you could give us an example of the variables you set in the script call, I cant find where to put my virtual devices codes in there.

            For reference, here is our setup :

            Humidity level device code : #8
            Setpoint virtual device code : H5

            Event name : Exchanger-heat-go

            BAsically, we want the exchanger event to start when humidity level reaches the setpoint level that corresponds to the virtual device's H5 value.

            Thx, almost there !

            Comment

            Working...
            X