Announcement

Collapse
No announcement yet.

Event question

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

    Event question


    #2
    Try this:
    Assuming the motion sensor is "M1" and the light is "L1"
    This script would be triggered by M1 Off. Save it as a .VB script.
    It's off the top of my head, but should do what you want.

    Sub Main(Parm as Object)
    Dim PrevBright as Integer = hs.DeviceValue("L1") ' Remember the level
    hs.ExecX10("L1","DDim",Int(PrevBright * .5)) ' dims to 50% of the previous level
    hs.WaitSecs(30)
    If hs.IsOn("M1") Then
    hs.ExecX10("L1","DDim",PrevBright) ' restore the level if motion is now on
    Else
    hs.ExecX10("L1","Off") ' otherwise turn off the light.
    End If
    End Sub
    Real courage is not securing your Wi-Fi network.

    Comment


      #3
      Thanks for the reply, i will try it out this evening.

      Comment


        #4
        Originally posted by Wadenut View Post
        Try this:
        Assuming the motion sensor is "M1" and the light is "L1"
        This script would be triggered by M1 Off. Save it as a .VB script.
        It's off the top of my head, but should do what you want.

        Sub Main(Parm as Object)
        Dim PrevBright as Integer = hs.DeviceValue("L1") ' Remember the level
        hs.ExecX10("L1","DDim",Int(PrevBright * .5)) ' dims to 50% of the previous level
        hs.WaitSecs(30)
        If hs.IsOn("M1") Then
        hs.ExecX10("L1","DDim",PrevBright) ' restore the level if motion is now on
        Else
        hs.ExecX10("L1","Off") ' otherwise turn off the light.
        End If
        End Sub

        Sorry to barf this up, but it seems like exactly (mostly! ) what I need to solve a problem. I can copy and substitute, but I think I'd need something slightly different here.

        Since I'm by no means a scripting genius, if I already have motion events running to turn on the lights, what do I put to exit / quit the script if the motion is now on (the bolded line)? I.E., in our baby room, the lights will turn on by motion. If say, I'm not rocking the rocking chair far enough back, it thinks no one is in the room. The lights in this case would dim, so I'd rock back that extra few inches that allows the motion sensor to see I'm there, which would kick off the existing motion event to set the lights on to my desired level again. The same kind of feature would be useful when taking a shower, too, since you could be in there moving around but the motion sensor won't know...and WAF goes negative if the lights go off while in the shower.

        If there's some hole in my logic, please feel free to point it out, too. More I'm finding automation is nice when you have it well thought out, and I haven't always done that.

        Comment


          #5
          You could try this. If the motion sensor is still off after 30 seconds, it turn off the light.

          Code:
          Sub Main(Parm as Object)
          Dim PrevBright as Integer = hs.DeviceValue("L1") ' Remember the level
          hs.ExecX10("L1","DDim",Int(PrevBright * .5)) ' dims to 50% of the previous level
          hs.WaitSecs(30)
          If hs.IsOff("M1") Then 
          hs.ExecX10("L1","Off") ' turn off the light.
          End If
          End Sub
          Mike____________________________________________________________ __________________
          HS3 Pro Edition 3.0.0.548, NUC i3

          HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

          Comment


            #6
            I'm getting this error:

            1/6/2013 11:03:58 AM - Error - Running script, script run or compile error in file: msoff2GBR.txt1006:Expected ')' in line 1 More info: Expected ')'

            Code:
            Sub Main(Parm as Object)
            Dim PrevBright as Integer = hs.DeviceValue("q26") ' Remember the level
            hs.transmit("q26","DDim",Int(PrevBright * .5)) ' dims to 50% of the previous level
            hs.WaitSecs(60)
            If hs.IsOff("d7") Then 
            hs.transmit("q26","Off") ' turn off the light.
            End If
            End Sub
            Any ideas? I think I see both an open and close parenthesis there in line 1...

            Comment


              #7
              OH!

              ...it seems to run just fine, and do what it's supposed to do, when you name the script file .vb instead of .txt. I had assumed it didn't matter, because I've got some other stuff in there running out of txt files from various plugins.

              Comment

              Working...
              X