Announcement

Collapse
No announcement yet.

Previous State

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

    Previous State

    Hi

    I have a door unlock event which turns on multiple lights and then turn them off after 5 mins. How can I keep the lights which were on before the event to stay on . If I create virtual device for status for every light then it makes a mess of virtual devices. Any good advice ?

    Thanks



    Sent from my Nexus 6P using Tapatalk

    #2
    I personally would use a script to write the current states to an ini file and then a different script (or a different subroutine in the same script) to read back those values and set the lights accordingly.


    Sent from my Phone using Tapatalk
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      I don't understand scripting. But scene master plugin does exactly that for me.

      Comment


        #4
        Originally posted by sparkman View Post
        I personally would use a script to write the current states to an ini file and then a different script (or a different subroutine in the same script) to read back those values and set the lights accordingly.


        Sent from my Phone using Tapatalk
        Is it possible to get some sample script. I am not sure what kind of scripting homeseer uses

        Sent from my Nexus 6P using Tapatalk

        Comment


          #5
          Originally posted by mmoud View Post
          Is it possible to get some sample script. I am not sure what kind of scripting homeseer uses

          Sent from my Nexus 6P using Tapatalk


          I can post some vb.net samples later tonight or tomorrow.


          Sent from my Phone using Tapatalk
          HS 4.2.8.0: 2134 Devices 1252 Events
          Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

          Comment


            #6
            I am on Linux so I don't think VB will work

            Sent from my Nexus 6P using Tapatalk

            Comment


              #7
              It will. Mono, which is what HS runs on, provides the .net framework.


              Sent from my Phone using Tapatalk
              HS 4.2.8.0: 2134 Devices 1252 Events
              Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

              Comment


                #8
                Here's a script with a couple of subroutines that should get you started. You could either call the script multiple times, once for each device, or use the script as a starting point to do multiple devices within it.

                Code:
                Sub Main(ByVal Parms as String)
                
                	Dim ParmArray() as String
                	ParmArray = Parms.tostring.split(",")
                	dim targetDev1 as Double = CInt(ParmArray(0))		'reference ID of the device
                	Dim Action as String = ParmArray(1).ToLower		
                
                	If Action = "save" Then 
                		SaveToINI(targetDev1)
                	ElseIf Action = "read" Then
                		ReadFromINI(targetDev1)
                	End If
                	
                End Sub
                
                Sub SaveToINI(targetDev1 As Integer)
                	Dim dev1Value As Double
                	dev1Value = hs.DeviceValue(targetDev1)
                	hs.SaveINISetting("DeviceValues", "Device" & CStr(targetDev1), CStr(dev1Value), "devicevalues.ini")
                End Sub
                
                
                Sub ReadFromINI(targetDev1 As Integer)
                
                	Dim dev1Value,dev2Value As Double
                
                	dev1Value = CDbl(hs.GetINISetting("DeviceValues", "Device" & CStr(targetDev1), "0", "devicevalues.ini"))
                	dev2Value = hs.DeviceValue(targetDev1)
                
                	If dev1Value <> dev2Value Then
                		Select Case dev1Value
                			Case 1 to 98
                				' Device DIM, set its current dim level
                				hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev1, false, CStr(dev1Value), false, true))
                			Case 99
                				' Device ON, set it to on
                				hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev1, false, "On", false, false))
                			Case 255
                				' Device ON, set it to on
                				hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev1, false, "On", false, false))
                			Case 0
                				' Device OFF, set it to off
                				hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev1, false, "Off", false, true))
                		End Select
                	End If
                
                End Sub
                Save the script with the filename as shown in the sample events in the Scripts sub-folder on your system and call it with two parameters separated by a comma. The first parameter is the reference ID of the device and the second is whether you want to save it or read it and set the device back to that.

                Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	48.1 KB
ID:	1188652


                Cheers
                Al
                HS 4.2.8.0: 2134 Devices 1252 Events
                Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                Comment


                  #9
                  Originally posted by sparkman View Post
                  Here's a script with a couple of subroutines that should get you started. You could either call the script multiple times, once for each device, or use the script as a starting point to do multiple devices within it.

                  Cheers
                  Al
                  Well, even though mmcloud didn't thank you, I will.

                  Thanks very much for this useful post.

                  Comment


                    #10
                    Originally posted by warrenmr View Post
                    Well, even though mmcloud didn't thank you, I will.

                    Thanks very much for this useful post.
                    You're welcome Warren. Let me know if it's working for you and if you need any assistance with it.

                    Cheers
                    Al
                    HS 4.2.8.0: 2134 Devices 1252 Events
                    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                    Comment

                    Working...
                    X