Announcement

Collapse
No announcement yet.

Execute an event based on device last change data

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

    Execute an event based on device last change data

    Hi everyone. I have motion sensors in my house. I'd like HomeSeer to track me and turn on lights when I enter a room and off when I leave. (I have PIR motion sensors and not presence sensors.) Assuming i'm the only one home, my thought is that if motion sensor in Room A fires and then the motion sensor in Room B fires, the logic would be I've left Room A and went into Room B. Therefore I would want the lights in Room A to turn off and the lights in Room B to turn on.

    The only way I could think to make this work is to compare the Last Change Times of the motion sensors. The one that changed last would be the room I'm in. I'm thinking that in the Event, I would run a script or command to poll the times but I'm not sure how to write a script for that purpose.

    #2
    try looking at these

    Comment


      #3
      Originally posted by rotunnoe View Post
      I'd like HomeSeer to track me and turn on lights when I enter a room and off when I leave.
      How quickly do you want your lights off event to respond to your entry into another room? For instance, if you are in room 2, but forgot something in one room 1 and go back for it, do you want the lights in room 2 to go off when the lights in room 1 go on, then have the lights in room 2 go back on and the lights in room 1 to go back off when you return (over the course of a minute, say)?

      If that is what you want, then you might be able to have an event for each room to turn on the lights in the room where motion is detected and turn the lights in all other rooms off. The trigger could be, 'if motion detector (in room X) changes and becomes on' possibly with the condition that the lights are not already on in the room.

      My concern with a scheme like that is that if you walk from room to room your house could behave like a pinball machine. And it would get really confusing if you ever had someone visit you.

      The more common approach is to use the delayed device action and remove delayed device action. That sequence is not always self evident, but the logic goes like this:
      When motion is detected in a room, then:
      - remove delayed device actions (if any) for the room lights
      - turn lights on if they are off
      - turn lights off after a delay of M minutes, where M is long enough that an occupant would be likely to trigger the motion event again first.

      The advantage of a scheme like that is that each room becomes a bit more autonomous. The lights do remain on for a time if you leave, but only for the delay you set. It is also better behaved when dealing with more than one occupant.
      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


        #4
        So in your scenario if motion detector = motion then turn lights on and then turn lights off after 5 minutes?

        Then if motion detector = motion again within 5 minutes it will restart or is that the part were I need to remove the delayed sequence before starting the loop again


        Sent from my iPhone using Tapatalk

        Comment


          #5
          Originally posted by rotunnoe View Post
          Then if motion detector = motion again within 5 minutes it will restart or is that the part were I need to remove the delayed sequence before starting the loop again
          If your motion event has as its first action, remove delayed events for the light, then if motion is detected within the delay, the delay will be reset and start over.
          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
            Great work around but I'm still interesting in getting an answer to my original question. Anyone?


            Sent from my iPhone using Tapatalk

            Comment


              #7
              Originally posted by rotunnoe View Post
              Great work around but I'm still interesting in getting an answer to my original question. Anyone?


              Sent from my iPhone using Tapatalk
              Something like this as a script would check two devices to establish which changed first, not sure if this is what you are after or not.

              Code:
              Sub Main(ByVal Parm As Object)
              
                  Try
                      Dim FirstDevice As Integer = 908
                      Dim SecondDevice As Integer = 340
              
                      If hs.devicelastchangeref(FirstDevice) > hs.devicelastchangeref(SecondDevice) Then
                          hs.writelog("Check", "First Device (" & hs.devicename(FirstDevice) & ") Changed First")
                      Else
                          hs.writelog("Check", "Second Device (" & hs.devicename(SecondDevice) & ") Changed First")
                      End If
              
                  Catch ex As Exception : hs.writelog("Check", "Exception: " & ex.message)
                  End Try
              
              End Sub

              Comment


                #8
                Thank you. Is there a way when you write scripts to actually see the values that are being generated by these scripts?


                Sent from my iPhone using Tapatalk

                Comment


                  #9
                  http://tenholder.net/tenWare2/tenScripting/default.aspx



                  http://tenholder.net/tenWare2/tenScriptAid/default.aspx



                  tenholde
                  tenholde

                  Comment


                    #10
                    THANK YOU!!! I can't wait to try this


                    Sent from my iPhone using Tapatalk

                    Comment

                    Working...
                    X