Announcement

Collapse
No announcement yet.

Assistance writing first script please

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

    Assistance writing first script please


    #2
    right here goes...you can test me aswell this is written without testing. To define "winter"/"summer" I would suggest (and this is a personal suggestion) using two events. The trigger for each event is a date event using the year wildcard, the only reason I would use events is that they are easier to edit later (perhaps if you wanted to change what you defined summer/winter as) on than going into a script - perhaps a consideration if the landlord was going to end up administering the system.

    I would then create a virtual device, giving it a device code (general consensus I understand is one above the X10 'P' housecode, I go backwards to perhaps 'Z1'). The action of the above summer/winter events is to set this device value to either 1 for summer or 2 for winter. You can do this by adding the action, then clicking device action, then find what you have called this virtual device. A couple of boxes down you should have the command set a device value, and then set this on the winter event to 2 and 1 for the summer.

    Now onto the script...something like this perhaps would work, there are many different ways of scripting, some better than others - mine are by no means the best...looking at this though, you might be able to get away with it with a combination of events and conditions, the trigger being device value greater than 19 with the condition of winter/summer and the action is turn the device off. You could copy the events and change them as you see fit...

    Code:
    Sub Main(ByVal Parms As Object)
    
    Dim HighPoint As Integer = 21
    Dim LowPoint As Integer = 19
    Dim Season As Integer = hs.devicevalue("Z1")
    
    If hs.devicevalue("/1") > HighPoint And Season = 1 Then
    hs.execX10("A1", "On", 0, 0)
    ElseIf hs.devicevalue("/2") > HighPoint And Season = 1 Then
    hs.execX10("A1", "On", 0, 0)
    ElseIf hs.devicevalue("/3") > HighPoint And Season = 1 Then
    hs.execX10("A1", "On", 0, 0)
    ElseIf hs.devicevalue("/4") > HighPoint And Season = 1 Then
    hs.execX10("A1", "On", 0, 0)
    ElseIf hs.devicevalue("/1") < LowPoint And Season = 1 Then
    hs.execX10("A1", "Off", 0, 0)
    ElseIf hs.devicevalue("/2") < LowPoint And Season = 1 Then
    hs.execX10("A1", "Off",0, 0)
    ElseIf hs.devicevalue("/3") < LowPoint And Season = 1 Then
    hs.execX10("A1", "Off", 0, 0)
    ElseIf hs.devicevalue("/4") < LowPoint And Season = 1 Then
    hs.execX10("A1", "Off", 0, 0)
    End If
    
    If hs.devicevalue("/1") > HighPoint And Season = 2 Then
    hs.execX10("A1", "On", 0, 0)
    ElseIf hs.devicevalue("/2") > HighPoint And Season = 2 Then
    hs.execX10("A1", "On", 0, 0)
    ElseIf hs.devicevalue("/3") > HighPoint And Season = 2 Then
    hs.execX10("A1", "On", 0, 0)
    ElseIf hs.devicevalue("/4") > HighPoint And Season = 2 Then
    hs.execX10("A1", "On", 0, 0)
    ElseIf hs.devicevalue("/1") < LowPoint And Season = 2 Then
    hs.execX10("A1", "Off", 0, 0)
    ElseIf hs.devicevalue("/2") < LowPoint And Season = 2 Then
    hs.execX10("A1", "Off",0, 0)
    ElseIf hs.devicevalue("/3") < LowPoint And Season = 2 Then
    hs.execX10("A1", "Off", 0, 0)
    ElseIf hs.devicevalue("/4") < LowPoint And Season = 2 Then
    hs.execX10("A1", "Off", 0, 0)
    End If
    
    End Sub
    I think the above should work or at least give you an idea....

    Comment


      #3
      Here's how I update a virtual device with 2 events that run every night just after midnight.
      Attached Files
      💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

      Comment


        #4
        Aw shucks, you guys are great! Thanks a lot - got me well on my way.
        I'll update when i have progress to report.

        thanks again.

        -Dale

        Comment


          #5
          Hey Rupp,

          If you don't mind me asking how are you you using this?

          I assume you changing the setpoints/mode in your thermostat?

          Hey can you tell me why you have one event with AND the other with OR?
          Last edited by smokey1384; May 19, 2011, 11:24 PM.

          Comment


            #6
            everything worked with x10, now how do i control z-wave via scripts?

            Hi everyone, thanks so much for your help. I built a working proof-of-concept using your advice and it worked just fine.

            My test was done with an x10 controller. i'm now building the actual solution with better equipment. i have a HomeTroller-SE with z-wave usb stick and some z-wave appliance plugs.

            I'm trying to rework my scripts to control the z-wave appliance plugs, but don't know the correct commands. When using x10, i used a command like this:

            If hs.devicevalue("/1") > 50 Then
            hs.execX10("A1", "On", 0, 0)

            This turned the x10 device code "A1" to on. What's the appropriate command to turn on my z-wave device? It's named "Fan Controller" with code "Q1 (2)".


            Thanks!

            Comment


              #7
              You might find it will still work providing you change the device code as I think the execX10 commands does send some commands to ZWave also (?), there is also a hs.zwaveaction command in the help files that you might want to take a look at in case there are specialist commands that the fan controller needs to have sent to it...

              Comment


                #8
                Yes, that worked. Thanks Mr. Happy!

                Comment

                Working...
                X