Announcement

Collapse
No announcement yet.

Flash Lamps with restore

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

    Flash Lamps with restore


    #2
    You need to use devicestatus not devicevalue. This should get you going but assumes you do not use dimming:

    PHP Code:
    Sub Main()

    dim v

    v
    =hs.Devicestatus ("A2"

    hs.writelog "initial state of lamps"v
    hs
    .execx10 "A2","on"
    hs.execx10 "A2","off"
    hs.execx10 "A2","on"
    hs.execx10 "A2","off"
    hs.execx10 "A2","on"
    If v=2 then
    hs
    .ExecX10 "A2""on"
    hs.writelog "final set lamps to on"
    else
    hs.ExecX10 "A2""off"
    hs.writelog "final set lamps to off"
    end if


    End Sub 
    Jon

    Comment


      #3
      That great jon00 I'll try that, but sadly that module is a dimmable one. So the inital value coud be anything from 0-100% Does that complicate things too much?

      P.S. also how do you enable your scripting to appear in a post in a box (sorry as I say a newbie to these things)

      Comment


        #4
        To show code in the blue box, highlight the text you want and then press the php button: . You will see it when you reply.

        Try the following:

        PHP Code:
        Sub Main() 

        dim v,x

        v
        =hs.Devicestatus ("A2")  
        x=hs.devicevalue ("A2")

        hs.execx10 "A2","off"
        hs.execx10 "A2","on" 
        hs.execx10 "A2","off" 
        hs.execx10 "A2","on" 
        hs.execx10 "A2","off" 

        If v=2 then 
        hs
        .ExecX10 "A2""on" 
        hs.writelog "final set lamps to on" 
        elseif V=3 then 
        hs
        .ExecX10 "A2""off" 
        hs.writelog "final set lamps to off" 
        elseif V=4 then
        hs
        .ExecX10 "D3""DDim"x
        hs
        .writelog "final set lamps to dim value " x
        else
        hs.writelog "lamp status is unknown"
        end if 


        End Sub 
        I have not tried it but should work.

        Please note that X10 is very bad for flashing lights due to it's transmission method.
        Jon

        Comment


          #5
          I've made a few tweeks, mainly arround log entries so i can see what's going on. And changed lamp moduelto teh office desk light so I don't have to go downstairs to see results! However the final dimmed state doesn't get set even though according to the log the value is correct


          PHP Code:
          Sub Main() 

          dim v,x

          v
          =hs.Devicestatus ("A16")  
          x=hs.devicevalue ("A16")

          hs.writelog "initial state of lamps"v
          hs
          .writelog "initial dim value of lamps"x

          hs
          .execx10 "A16","off"
          hs.execx10 "A16","on" 
          hs.execx10 "A16","off" 
          hs.execx10 "A16","on" 
          hs.execx10 "A16","off" 

          If v=2 then 
          hs
          .ExecX10 "A16""on" 
          hs.writelog "final set lamps to on"
          elseif v=3 then 
          hs
          .ExecX10 "A16""off" 
          hs.writelog "final set lamps to off"
          elseif v=4 then
          hs
          .ExecX10 "A16""DDim"x0
          hs
          .writelog "final set lamps to dim value " x
          else
          hs.writelog "lamp status is unknown"
          end if 


          End Sub 
          PHP Code:
          20/06/2010 11:17:33     final set lamps to dim value      30
          20
          /06/2010 11:17:33     X-10     Command sent to Office Desk LightA16 DDim Dimval30 Data0
          20
          /06/2010 11:17:33     X-10     Command sent to Office Desk LightA16 off Dimval0 Data0
          20
          /06/2010 11:17:33     X-10     Command sent to Office Desk LightA16 on Dimval0 Data0
          20
          /06/2010 11:17:33     X-10     Command sent to Office Desk LightA16 off Dimval0 Data0
          20
          /06/2010 11:17:33     X-10     Command sent to Office Desk LightA16 on Dimval0 Data0
          20
          /06/2010 11:17:33     X-10     Command sent to Office Desk LightA16 off Dimval0 Data0
          20
          /06/2010 11:17:33     initial dim value of lamps     30
          20
          /06/2010 11:17:33     initial state of lamps     4
          20
          /06/2010 11:17:33     Event     Running script in backgroundFlash Lights with restore
          20
          /06/2010 11:17:16     Device Control     DeviceOffice Desk Light (A16Dim by 70

          Comment


            #6
            What dimming module is in use for your lights?
            Jon

            Comment


              #7
              Home Control LM12U

              Comment


                #8
                It may be due to the sheer number of X10 signals being sent. I've added a delay between X10 commands.

                Try this:


                PHP Code:
                Sub Main()  

                dim v,

                v
                =hs.Devicestatus ("A16")   
                x=hs.devicevalue ("A16"

                hs.writelog "initial state of lamps"
                hs
                .writelog "initial dim value of lamps"

                hs
                .execx10 "A16","off" 
                hs.waitsecs 2
                hs
                .execx10 "A16","on" 
                hs.waitsecs 2
                hs
                .execx10 "A16","off"
                hs.waitsecs 2
                hs
                .execx10 "A16","on"
                hs.waitsecs 2
                hs
                .execx10 "A16","off"  
                hs.waitsecs 2
                If v=2 then  
                hs
                .ExecX10 "A16""on"  
                hs.writelog "final set lamps to on"v  
                elseif v=3 then  
                hs
                .ExecX10 "A16""off"  
                hs.writelog "final set lamps to off"v  
                elseif v=4 then 
                hs
                .ExecX10 "A16""DDim"x
                hs
                .writelog "final set lamps to dim value " 
                else 
                hs.writelog "lamp status is unknown" 
                end if

                End sub 
                Jon

                Comment

                Working...
                X