Announcement

Collapse
No announcement yet.

Newbie needs pointers

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

    Newbie needs pointers

    Would appreciate pointers to examples and documentation for C# scripting including parsing out passed parameters, some optional so some may or may not be passed. I have no formal scripting experience and have hacked my way through VB stuff in the past (HS2 and day job stuff), but burned several hours researching with minimal progress so crying uncle.

    This is for a Zee S2 which is why I'm looking at C# to minimize performance issues. Also if any configs in the Zee need to be modified to reference libraries etc. would appreciate pointers.

    The purpose of the first script I want to write is to do some simple math to manipulate the value of a virtual device including referencing new device configs (a weight value) I want to define somehow. I was able to do simple math with direct script commands in an event but even though I configured the event to not log, the script command still logs, and this is once per minute decrements I don't want filling the log.

    Thanks,
    John

    #2
    I'm not sure you would realistically notice the difference between C# and VB if all you were doing were some simple mathematical functions, if there is a benefit to C# on the Zee then I imagine you will only see it when you start performing complex and involved scripts.

    Comment


      #3
      Any good VB examples and references to do the things noted then?

      Comment


        #4
        Originally posted by jhearty View Post
        Any good VB examples and references to do the things noted then?
        Are you able to elaborate a bit more on what you want to do with some device references and I can probably post an example or point you in the right place.

        Comment


          #5
          Originally posted by mrhappy View Post
          Are you able to elaborate a bit more on what you want to do with some device references and I can probably post an example or point you in the right place.
          Thanks. High level goal is essentially a minute count down timer that can have different devices add different amounts to it's value. I want to assign a default weight value to various device values such as PIR zone 1 violated, HS kitchen switch single click On, single click Off, double click On, etc. When events are triggered by those things or others, run the script. Mandatory parameter would be the Ref ID of a virtual device representing room occupancy minute timer to manipulate it's value. Optional parameters may include the Ref ID of the triggering device and/or a weight value parameter to use in the manipulation calculation that might differ from/override the default weight of the trigger. The weight could be positive or negative integer or zero. If only optional parameter supplied was Ref ID of triggering device, look up its current state and corresponding default weight to use in calculation. Initially, the calculation may simply add weight to current value of the virtual device. The same script will also be called once per minute with only the virtual device Ref ID and decrement its value.

          I was getting stuck looking for examples of parsing the parameters. I started noting different ways to do that might involve needing to edit configs in the Zee to reference other libraries. I also have no idea yet how to implement the default weights, if they should be in a DB or what.

          Comment


            #6
            Originally posted by jhearty View Post
            Thanks. High level goal is essentially a minute count down timer that can have different devices add different amounts to it's value. I want to assign a default weight value to various device values such as PIR zone 1 violated, HS kitchen switch single click On, single click Off, double click On, etc. When events are triggered by those things or others, run the script. Mandatory parameter would be the Ref ID of a virtual device representing room occupancy minute timer to manipulate it's value. Optional parameters may include the Ref ID of the triggering device and/or a weight value parameter to use in the manipulation calculation that might differ from/override the default weight of the trigger. The weight could be positive or negative integer or zero. If only optional parameter supplied was Ref ID of triggering device, look up its current state and corresponding default weight to use in calculation. Initially, the calculation may simply add weight to current value of the virtual device. The same script will also be called once per minute with only the virtual device Ref ID and decrement its value.

            I was getting stuck looking for examples of parsing the parameters. I started noting different ways to do that might involve needing to edit configs in the Zee to reference other libraries. I also have no idea yet how to implement the default weights, if they should be in a DB or what.
            I wonder if a slightly better way of doing this would be to register a script for a device value callback. That way any device in HS that changes value would run the script and pass into that script the device reference, old value and new value (http://www.homeseer.com/support/home...uschangecb.htm).

            Then in the script that is run you can have a simple look up table written manually that determines the significance of the device that has called the script. Then have a value for the weight you hold for that device, then add it to your virtual device. I don't see that you would need a database personally at the minute.

            Does that sound similar to what you are trying to do? With that you would not have to worry about running scripts every minute.

            Comment


              #7
              Originally posted by mrhappy View Post
              I wonder if a slightly better way of doing this would be to register a script for a device value callback. That way any device in HS that changes value would run the script and pass into that script the device reference, old value and new value (http://www.homeseer.com/support/home...uschangecb.htm).

              Then in the script that is run you can have a simple look up table written manually that determines the significance of the device that has called the script. Then have a value for the weight you hold for that device, then add it to your virtual device. I don't see that you would need a database personally at the minute.

              Does that sound similar to what you are trying to do? With that you would not have to worry about running scripts every minute.
              This looks interesting and may help. Thanks for the pointer. I'm thinking though this will only fire when device values change, vs. when they are set again to the same value. This could be common on the HS switches where the same double click could be done multiple times to trigger events without some other value change in between. At any rate I have an example to work with now.

              I tried the example script at the help link unchanged this morning and it seemed to work, but turned into a train wreck. It promptly started logging a few running timers once per second, which would have quickly filled the log. The UnRegister function did not seem to be working. I stopped HomeSeer to stop the logging. I had been avoiding stopping HS due to a defect on linux where Then actions in various events get their sequence changed. Sure enough it happened again. The defect recently got fixed in a beta release but I was holding out for the GA release. Oh well.

              Comment

              Working...
              X