Announcement

Collapse
No announcement yet.

How do I turn OFF 20 devices but save each of their (ON/OFF) stage for later restore?

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

    How do I turn OFF 20 devices but save each of their (ON/OFF) stage for later restore?

    I need to be able to turn off more than 20 devices when my house is in Armed/Alarm on mode.
    When the mode changes back to "Home mode" I wish to return to the differen ON/OFF stage the devices had before I turned them all of.
    How do efficentily do that?

    #2
    Simply set up an event that controls all of your lights in one event that is triggered by your alarm conditions.
    -Rupp
    sigpic

    Comment


      #3
      how does it remeber the status of each device?

      But if the status of devices before the event was 10 devices were OFF and 10 were ON.
      How do I then after the event you suggest (setting all 20 devises to OFF) return to the above settings in another event?

      Comment


        #4
        Right or wrong, this is how I might do it in a nutshell.

        To save each device's status:

        If hs.IsOn("A1") then
        Status = "On"
        Else
        Status = "Off"
        End If
        SaveInisetting "DeviceStats","Device1",Status,"SavedDevices.ini"

        (repeat for each device... A2,Device2, A3,Device3...)

        To restore:

        Status = GetIniSetting("DeviceStats","Device1","","SavedDevices.ini")
        If Status = "On" then
        hs.ExecX10 "A1","On"
        Else
        hs.ExecX10 "A1","Off"
        End If

        (repeat for each device...)

        I'd probably do a For..Next loop for so many devices.

        For x=1 to 20
        DeviceString = "A"+CStr(x)
        next

        (just replace "Device1" with DeviceString above)
        Real courage is not securing your Wi-Fi network.

        Comment


          #5
          I think Rupp left out a little additional info

          You will likely have to do this with scripting. Create an event that runs a script to iterate through your list of 20 devices. Get the status using DeviceStatus(2=ON and 3=OFF) *or* just use isOn or IsOff. As you turn off your devices, you'll need to 'store' these values somewhere - either a text file, an INI file, etc.

          Next create an event that runs a script to read the 20 device status values, iterate through them, then turn them on/off using the scripting device control methods.

          Hope this helps - let us know if you need anything else.
          HS4Pro Running on a Raspberry Pi4
          68 Z-Wave Nodes, 175 Events, 359 Devices
          UPB modules via OMNI plugin/panel
          Plugins: Z-Wave, OMNI, HSTouch, weatherXML, EasyTrigger
          HSTouch Clients: 3 Android, 1 Joggler

          Comment


            #6
            I can not program :-)

            Thank you very much for your examples.

            Not being a programmer, is there no way to do this via HS' webinterface?

            Would it not be a good standard feature in the event attributes?

            If not: is there anybody who can help me creating the suggested pieces of code? (I will give back the code to the community here)

            I have created a virtual device called HomeStatus. When it changes to "Garden" (Triggered by 3 PIRs inside the house with no activitaion for 30 min. ie. we must be out.) I wish to set the house on standby.
            But when we come back into the house iI wish to restore it the way we left it hence the need for a "memory function".

            The same goes with my HomeStatus=Armed when we set the alarm and leave the house, for a later return and restore.

            Every single poweroutlet and ceiling is controlled by a wired controlsystem plugged into HS.
            Last edited by Jakob.Sand; October 12, 2008, 02:29 AM.

            Comment


              #7
              Yes I did leave out a bit. I overlooked the fact that he wanted to restore the exact state. Oddly enough this is the first time I believe I've ever seen this request. Wadenuts example should work just fine out of the box though.
              -Rupp
              sigpic

              Comment


                #8
                Could anybody do this?

                It suprices me that nobody have had the need to "restore" a house light settings after a "standby mode."

                Anyway is this as I said something that somebody would program for me at a fixed price?

                Comment


                  #9
                  In my case, I have most settings determined by time of day and other flags, so for instance, when we arrive home and disarm the alarm, the "Away" flag turns off, which triggers an event that sets selected devices to appropriate settings based on time of day, season of year, etc. I haven't seen a need to reset to the same condition they were in when I left. In fact, I make use of that fact so that I don't have to worry what is on or off when I leave. I know that arming my alarm system will turn them all to predetermined states appropriate for an unoccupied state and disarming it will activate the "we're home" state.

                  If resetting states is critical, I'm sure we can help you without a need for you to pay. For instance, I already have a script that checks the states of devices, so I think modifying it to store the info in a retrievable form and then resetting them would be relatively easy to do.
                  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


                    #10
                    To each his own preference I suppose.
                    My lights are all tied to individual room motion sensors. Why keep lights on in unoccupied rooms? When we go out, ie. the last motion sensor triggerred was at the door and no other is on, the house goes into standby, sets the security system, lights to 'unoccupied' mode where they simulate occupation at night, and turns off appliances. On return, the motion sensors take over again. I also do an 'anticipate' function where movement from one room to certain others turns on the next rooms light momentarily, then if still unoccupied, turns it off after a few seconds.
                    Real courage is not securing your Wi-Fi network.

                    Comment


                      #11
                      Why standby and restore.

                      An example of the kind of restore i would like to create is for our TV sets.
                      If they were on when we went to the garden, then turn them off while we are in the garden, but turn them on when we come back.
                      If the were off - turn them off and leave them off when we come back.

                      If there is a way to do this with the PIRs in that I also have in every room, I would love to do it with out the "restore function".

                      Comment


                        #12
                        Originally posted by Uncle Michael View Post

                        If resetting states is critical, I'm sure we can help you without a need for you to pay. For instance, I already have a script that checks the states of devices, so I think modifying it to store the info in a retrievable form and then resetting them would be relatively easy to do.
                        If you would be so nice and help me I would highly appreciate it.

                        Comment


                          #13
                          OK, here's a start. I'm certain there are others on the board who can improve these, but I think they will do what you want.

                          You will need to replace the example lists of device codes with your actual list and adjust the "For I = 0 to ___" to the correct number. (If you have 20 devices, then it should be "For I = 0 to 19".) Be sure the list of device codes in each of the pair of scripts is exactly the same as that in the other! You can open the file that is created in Notepad to confirm its contents. (Note: If you need to store more than just device status, then the scripts will need extra lines for other device properties. Also, if SetDeviceStatus does not turn some devices on, then it may require ExecX10 instead.)

                          To store the device states, create an event that runs the first script when you leave. Copy the text below to a new Notepad file and then save it to your HS Scripts folder with a meaningful name, like SaveState.vb.

                          Code:
                          Sub Main(ByVal Params As Object)
                          
                                  '                                                   List of the Device Codes for all devices to save (13 items as an example)
                                  Dim strSensor_addr() As String = {"A4", "A6", "A12", "A14", "B10", "B12", "B14", "B16", "C4", "D12", "F10", "K12", "K14"}
                                  Dim I As Integer
                                  Dim intDStatus As Integer
                                  Dim strAddr As String
                          
                                  Dim strFileName As String
                                  Dim strApPath As String
                          
                                 ' Find the path - this will store the file in the main HomeSeer directory
                                  strApPath = hs.GetAppPath() & "\"
                                  strFileName = strApPath & "SavedState.txt"
                                  
                                  ' Create an output ASCII text file.  If it already exists, overwrite current contents.
                                  Dim FS As New System.IO.FileStream(strFileName, System.IO.FileMode.Create, System.IO.FileAccess.Write)
                          
                                  Dim sWriter As New System.IO.StreamWriter(FS)
                          
                                  ' Time stamp the file - optional, but useful if states aren't returned properly
                                  sWriter.WriteLine("Saved states - " & Now)
                          
                                  ' Check each device
                                  For I = 0 To 12
                                      strAddr = strSensor_addr(I)    ' each item in the list above
                                      intDStatus = hs.DeviceStatus(strAddr)
                                      sWriter.WriteLine(intDStatus)
                                  Next 'I
                          
                                  ' Close the file
                                  sWriter.Close()
                                  FS = Nothing
                          
                              End Sub
                          Then, to restore the states, create another event that runs the second script when you return. Again, save this to the Scripts folder with a different name, like RetrieveState.vb.

                          Code:
                          Sub Main(ByVal Params As Object)
                          
                                  '                                                   List of the Device Codes for all devices to restore (identical to list in the Save script)
                                  Dim strSensor_addr() As String = {"A4", "A6", "A12", "A14", "B10", "B12", "B14", "B16", "C4", "D12", "F10", "K12", "K14"}
                                  Dim I As Integer
                                  Dim intDStatus As Integer
                                  Dim strAddr As String
                                  Dim strFileName As String
                                  Dim strApPath As String
                                  Dim strTemp As String
                          
                                 ' Find the file
                                  strApPath = hs.GetAppPath() & "\"
                                  strFileName = strApPath & "SavedState.txt"
                                  
                                  Dim FS As New System.IO.FileStream(strFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)
                                  Dim sReader As New System.IO.StreamReader(FS)
                          
                                  ' Read past time stamp
                                  sReader.ReadLine
                          
                                  ' Reset each device
                                  For I = 0 To 12
                                      strTemp = sReader.ReadLine
                                      intDStatus = CInt(strTemp)
                                      strAddr = strSensor_addr(I)
                                      hs.SetDeviceStatus(strAddr, intDStatus)
                                  Next 'I
                          
                                  ' Close the file
                                  sReader.Close()
                                  FS = Nothing
                          
                              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


                            #14
                            There is a script in the libray that might do what you're looking for. I've never used it but remembered it (for some reason) and a little searching found it.

                            Scene Stack

                            jim

                            Comment


                              #15
                              I tried the scrips without sucess.
                              Will spend more time on this and get back.
                              Thank you again for the feedback.

                              Comment

                              Working...
                              X