Announcement

Collapse
No announcement yet.

Can I create complex logic with HS ?

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

    Can I create complex logic with HS ?

    On my Vera system I have some complex logic, and if I move to HS I need to be able to recreate that. So the question is can I for example create a condition like this
    At a given time, turn on the AC if the temperature is above x, both windows are closed, both phones are at home. Once the temperature has dropped to y, or a window is being opened, turn off the AC.
    Temperature readings are from RFXcom compatible Oregon Scientific temperature sensors, the AC is controlled vis a Remotec ZXT120

    #2
    Originally posted by mikee123 View Post
    On my Vera system I have some complex logic, and if I move to HS I need to be able to recreate that. So the question is can I for example create a condition like this
    At a given time, turn on the AC if the temperature is above x, both windows are closed, both phones are at home. Once the temperature has dropped to y, or a window is being opened, turn off the AC.
    Temperature readings are from RFXcom compatible Oregon Scientific temperature sensors, the AC is controlled vis a Remotec ZXT120
    Absolutely. Take a look at the excellent Event Clinic, written by the HS3 guru on events (and most other HA and electronics) - "rprade".

    http://board.homeseer.com/forumdisplay.php?f=1250

    This is a definite must read.
    cheeryfool

    Comment


      #3
      Actually creating 'easy' logic seems straight forward. The more complex logic I have developed over years on my Vera might be a bit more complicated, but it all looks fairly logic, but I am sure I will be back for help at some point...

      Comment


        #4
        Originally posted by mikee123 View Post
        Actually creating 'easy' logic seems straight forward. The more complex logic I have developed over years on my Vera might be a bit more complicated, but it all looks fairly logic, but I am sure I will be back for help at some point...
        Randy has achieved with events more than many folks could imagine needing, let alone figuring out how to do themselves.

        Definitely post follow-ups in that sub-forum
        cheeryfool

        Comment


          #5
          Also Vb.net scripting... I am not a coder, but I have done some pretty complicated stuff that surpasses what PLEG could've accomplished.

          Also if you are wanting something specific, just ask... everyone here is good at helping. We can generally get you something that you want, or get you going in the right direction.

          And welcome! You will find Vera was only good at being a doorstop compared to HS.

          Comment


            #6
            The more I read the more I think the doorstop is going back to MCV. I loved PLEGs capabilities, but it is quite a steep learning curve and not necessarily easy to master. On a first glance HS might be easier to learn, at least in the beginning.

            Comment


              #7
              It's problem is it doesn't use standard coding practices, so the logic seems silly sometimes.

              Randy has done a great job in the Event Clinic section and has made it a personal goal to do everything in the event engine without using scripting. He does have some pretty advanced stuff going on and is a huge value to the community here.

              Scripting isn't too bad once you learn the basics, but babysteps. I have been using HS for 1 year now, and just started getting into scripts in the past few months, and even that I am still very green with.

              Comment


                #8
                Originally posted by mikee123 View Post
                On my Vera system I have some complex logic, and if I move to HS I need to be able to recreate that. So the question is can I for example create a condition like this. . .
                I think that it is safe to say that you can code any logical argument into HS events. In many cases, if the logic is convoluted or has multiple paths, it may be easier to use a script. (A script is definitely easier to document and troubleshoot if the logic is complex.)

                In the example you give, I think events, coupled with a few 'virtual' devices will work well. In fact, I have some event constructions that are logically similar to your example.
                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


                  #9
                  Mike, not sure what your script kungfu is like, but here is a script I use to do something similar, but 180 degrees from AC and what you do. I am sharing because it could be modified to give the what you are looking for.

                  What I have setup is based off outside temp, and if windows are opened (and number of windows open), our whole house fan gets turned on, sped up, or shut off.

                  I am looking at all the windows, all the doors, and the outside temp. I am also using the script to display data in HSTouch for door and window status.

                  And lastly it's used to control turning the heater on/off if windows or doors are left open.

                  Take a look and if you understand it, we can modify it for your needs if you want to go the script route, if not, I am sure we can figure out an event for you too.

                  PHP Code:
                  'Define Windows/Doors Array

                  '
                  604 Master Bathroom Right Window
                  '600 Master Bathroom Left Window
                  '
                  502 Master Bedroom Right Window
                  '498 Master Bedroom Left Window
                  '
                  394 Loft Window
                  '55 Dining/Piano Windows
                  '
                  53 Laundry/TV Windows

                  '58 Garage Door from Laundry
                  '
                  54 Front Door
                  '57 Back Door

                  dim array_windows() as string = {"Master Bathroom Right Window","Master Bathroom Left Window","Master Bedroom Right Window","Master Bedroom Left Window","Loft Window","Dining/Piano Windows","Laundry/TV Windows"}
                  dim array_doors() as string = {"Garage Door","Front Door","Back Door"}
                  dim windows_count as integer = 0
                  dim doors_count as integer = 0
                  dim locked as integer = 0
                  dim door_name as String = ""
                  dim dstr as string = ""
                  dim window_name as string = ""
                  dim wstr as string = ""
                  dim outside_temp as integer = 0
                  dim temp_threshold as integer = 65 '
                  Set outside temperature for fan to turn on

                  sub windows
                  (ByVal Parms as Object)
                  Try
                  windows_count 0
                  window_name 
                  ""
                  wstr ""
                  outside_temp hs.DeviceValueEx(864)
                  'Counts thru array to check if any windows are opened
                  for each devw as string in array_windows
                      if hs.DeviceValueByName(devw) = 255 or hs.DeviceValueByName(devw) = 100 then
                          windows_count = windows_count + 1
                          window_name = devw
                          wstr = wstr & window_name & " Opened" & "<br>"
                      Else If hs.DeviceValueByName(devw) = 0 then '
                  No windows open
                      end 
                  if
                  next
                      
                  If windows_count 0 then 
                          hs
                  .SetDeviceValueByRef(171,100,true)
                          
                  hs.SetDeviceString(171wstr,true)
                      Else
                          
                  hs.SetDeviceValueByRef(171,0,true)
                          
                  hs.SetDeviceString(171"All Windows Closed",true)
                      
                  End If
                      
                      if (
                  outside_temp temp_threshold andalso windows_count 0 andalso windows_count 3then
                          hs
                  .CAPIControlHandler(hs.CAPIGetSingleControl(493,true ,"on",false,true))
                          
                  hs.CAPIControlHandler(hs.CAPIGetSingleControl(494,true ,"off",false,true))
                          ElseIf (
                  outside_temp temp_threshold andalso windows_count 2 andalso windows_count 4then
                              hs
                  .CAPIControlHandler(hs.CAPIGetSingleControl(493,true ,"off",false,true))
                              
                  hs.CAPIControlHandler(hs.CAPIGetSingleControl(494,true ,"on",false,true))
                              ElseIf (
                  outside_temp temp_threshold andalso windows_count 3then
                                  hs
                  .CAPIControlHandler(hs.CAPIGetSingleControl(493,true ,"on",false,true))
                                  
                  hs.CAPIControlHandler(hs.CAPIGetSingleControl(494,true ,"on",false,true))
                          ElseIf 
                  windows_count 0
                          hs
                  .CAPIControlHandler(hs.CAPIGetSingleControl(493,true ,"off",false,true))
                          
                  hs.CAPIControlHandler(hs.CAPIGetSingleControl(494,true ,"off",false,true))
                      
                  End If    
                      
                  hs.writelog("Array""Window Count: " windows_count)

                  Catch 
                  ex As Exception
                  hs
                  .WriteLog ("Array""Error: " ex.Message)
                  End Try
                  End Sub

                  sub doors
                  (ByVal Parms as Object)
                  Try
                  doors_count 0
                  locked 
                  hs.DeviceValueEx(1069)
                  door_name ""
                  dstr ""
                  for each devd as string in array_doors
                      
                  if hs.DeviceValueByName(devd) = 255 or hs.DeviceValueByName(devd) = 100 then
                          doors_count 
                  doors_count 1
                          door_name 
                  devd
                          dstr 
                  dstr door_name " Opened" "<br>"
                      
                  Else If hs.DeviceValueByName(devd) = 0 then 'No doors open
                      end if
                  next
                      If doors_count > 0 then 
                          hs.SetDeviceValueByRef(170,100,true)
                          hs.SetDeviceString(170, dstr,true)
                          ElseIf (doors_count = 0 and locked = 255) then
                                  hs.SetDeviceValueByRef(170,150,true)
                                  hs.SetDeviceString(170, "All Doors Closed and Locked",true)
                      Else
                          hs.SetDeviceValueByRef(170,0,true)
                          hs.SetDeviceString(170, "All Doors Closed",true)
                      End If
                  Catch ex As Exception
                  hs.WriteLog ("Array", "Error: " & ex.Message)
                  End Try
                  End Sub 
                  Last edited by waynehead99; May 20, 2016, 11:33 AM.

                  Comment


                    #10
                    PLEG is a nightmare. Creating events with HS3 is so vastly superior to anything Vera that I'm basically at a loss for words. Just about every event I have is more complicated than anything I could have ever done with Vera.

                    So in a word, Yes, You can create complex logic with HS; much more complex than with Vera.
                    Originally posted by rprade
                    There is no rhyme or reason to the anarchy a defective Z-Wave device can cause

                    Comment


                      #11
                      Originally posted by mikee123 View Post
                      The more I read the more I think the doorstop is going back to MCV...
                      I wasn't sure what you meant by this but then I did quick Google search and found it!
                      Attached Files
                      💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                      Comment


                        #12
                        Mark, that is priceless! That one is going into the comedy pictures folder.
                        Originally posted by rprade
                        There is no rhyme or reason to the anarchy a defective Z-Wave device can cause

                        Comment


                          #13
                          Originally posted by waynehead99 View Post
                          Mike, not sure what your script kungfu is like, but here is a script I use to do something similar, but 180 degrees from AC and what you do. I am sharing because it could be modified to give the what you are looking for.

                          What I have setup is based off outside temp, and if windows are opened (and number of windows open), our whole house fan gets turned on, sped up, or shut off.

                          I am looking at all the windows, all the doors, and the outside temp. I am also using the script to display data in HSTouch for door and window status.

                          And lastly it's used to control turning the heater on/off if windows or doors are left open.

                          Take a look and if you understand it, we can modify it for your needs if you want to go the script route, if not, I am sure we can figure out an event for you too.

                          PHP Code:
                          'Define Windows/Doors Array

                          '
                          604 Master Bathroom Right Window
                          '600 Master Bathroom Left Window
                          '
                          502 Master Bedroom Right Window
                          '498 Master Bedroom Left Window
                          '
                          394 Loft Window
                          '55 Dining/Piano Windows
                          '
                          53 Laundry/TV Windows

                          '58 Garage Door from Laundry
                          '
                          54 Front Door
                          '57 Back Door

                          dim array_windows() as string = {"Master Bathroom Right Window","Master Bathroom Left Window","Master Bedroom Right Window","Master Bedroom Left Window","Loft Window","Dining/Piano Windows","Laundry/TV Windows"}
                          dim array_doors() as string = {"Garage Door","Front Door","Back Door"}
                          dim windows_count as integer = 0
                          dim doors_count as integer = 0
                          dim locked as integer = 0
                          dim door_name as String = ""
                          dim dstr as string = ""
                          dim window_name as string = ""
                          dim wstr as string = ""
                          dim outside_temp as integer = 0
                          dim temp_threshold as integer = 65 '
                          Set outside temperature for fan to turn on

                          sub windows
                          (ByVal Parms as Object)
                          Try
                          windows_count 0
                          window_name 
                          ""
                          wstr ""
                          outside_temp hs.DeviceValueEx(864)
                          'Counts thru array to check if any windows are opened
                          for each devw as string in array_windows
                              if hs.DeviceValueByName(devw) = 255 or hs.DeviceValueByName(devw) = 100 then
                                  windows_count = windows_count + 1
                                  window_name = devw
                                  wstr = wstr & window_name & " Opened" & "<br>"
                              Else If hs.DeviceValueByName(devw) = 0 then '
                          No windows open
                              end 
                          if
                          next
                              
                          If windows_count 0 then 
                                  hs
                          .SetDeviceValueByRef(171,100,true)
                                  
                          hs.SetDeviceString(171wstr,true)
                              Else
                                  
                          hs.SetDeviceValueByRef(171,0,true)
                                  
                          hs.SetDeviceString(171"All Windows Closed",true)
                              
                          End If
                              
                              if (
                          outside_temp temp_threshold andalso windows_count 0 andalso windows_count 3then
                                  hs
                          .CAPIControlHandler(hs.CAPIGetSingleControl(493,true ,"on",false,true))
                                  
                          hs.CAPIControlHandler(hs.CAPIGetSingleControl(494,true ,"off",false,true))
                                  ElseIf (
                          outside_temp temp_threshold andalso windows_count 2 andalso windows_count 4then
                                      hs
                          .CAPIControlHandler(hs.CAPIGetSingleControl(493,true ,"off",false,true))
                                      
                          hs.CAPIControlHandler(hs.CAPIGetSingleControl(494,true ,"on",false,true))
                                      ElseIf (
                          outside_temp temp_threshold andalso windows_count 3then
                                          hs
                          .CAPIControlHandler(hs.CAPIGetSingleControl(493,true ,"on",false,true))
                                          
                          hs.CAPIControlHandler(hs.CAPIGetSingleControl(494,true ,"on",false,true))
                                  ElseIf 
                          windows_count 0
                                  hs
                          .CAPIControlHandler(hs.CAPIGetSingleControl(493,true ,"off",false,true))
                                  
                          hs.CAPIControlHandler(hs.CAPIGetSingleControl(494,true ,"off",false,true))
                              
                          End If    
                              
                          hs.writelog("Array""Window Count: " windows_count)

                          Catch 
                          ex As Exception
                          hs
                          .WriteLog ("Array""Error: " ex.Message)
                          End Try
                          End Sub

                          sub doors
                          (ByVal Parms as Object)
                          Try
                          doors_count 0
                          locked 
                          hs.DeviceValueEx(1069)
                          door_name ""
                          dstr ""
                          for each devd as string in array_doors
                              
                          if hs.DeviceValueByName(devd) = 255 or hs.DeviceValueByName(devd) = 100 then
                                  doors_count 
                          doors_count 1
                                  door_name 
                          devd
                                  dstr 
                          dstr door_name " Opened" "<br>"
                              
                          Else If hs.DeviceValueByName(devd) = 0 then 'No doors open
                              end if
                          next
                              If doors_count > 0 then 
                                  hs.SetDeviceValueByRef(170,100,true)
                                  hs.SetDeviceString(170, dstr,true)
                                  ElseIf (doors_count = 0 and locked = 255) then
                                          hs.SetDeviceValueByRef(170,150,true)
                                          hs.SetDeviceString(170, "All Doors Closed and Locked",true)
                              Else
                                  hs.SetDeviceValueByRef(170,0,true)
                                  hs.SetDeviceString(170, "All Doors Closed",true)
                              End If
                          Catch ex As Exception
                          hs.WriteLog ("Array", "Error: " & ex.Message)
                          End Try
                          End Sub 
                          On first glance I am not understanding a lot, but some parts remind me of the old 'Basic' programming language, and I managed that although looong time ago. I think Once I've moved over I'll first do the absolutely necessary things, like programming a timer for our hot water. That should be very easy. Then next step I need to override (stop) that when the solar panels have produced enough. Thats a step up. After that I might start looking into scripting and try to learn for the more complex stuff. I can see why it would be beneficial.

                          Comment


                            #14
                            Originally posted by mikee123 View Post
                            On my Vera system I have some complex logic, and if I move to HS I need to be able to recreate that. So the question is can I for example create a condition like this
                            At a given time, turn on the AC if the temperature is above x, both windows are closed, both phones are at home. Once the temperature has dropped to y, or a window is being opened, turn off the AC.
                            Temperature readings are from RFXcom compatible Oregon Scientific temperature sensors, the AC is controlled vis a Remotec ZXT120
                            Mike - you can do what you want to do without scripting. Our event engine is definitely powerful enough to handle this. Consider using doing this with a virtual device.

                            Create a virtual device called "AC Status". By default, it will have an "On" and "Off" state. This will assist with how the events trigger.

                            EVENT #1
                            IF Temperature was set and has a value that is greater than xxF
                            AND IF if the xxx door has a value equal to closed
                            AND IF the "AC Status" device has a value equal to OFF
                            THEN turn on the A/C
                            THEN set "AC Status" to ON (this will prevent this event from continuously triggering)

                            EVENT #2
                            IF Temperature was set and has a value that is less than xxF
                            AND IF the "AC Status" device has a value equal to ON
                            OR IF if the xxx door has a value equal to open
                            AND IF the "AC Status" device has a value equal to ON
                            THEN turn off the A/C
                            THEN set "AC Status" to OFF (this will prevent this event from continuously triggering)
                            💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                            Comment


                              #15
                              Originally posted by S-F View Post
                              Mark, that is priceless! That one is going into the comedy pictures folder.
                              Hmmm, I don't have such a folder... perhaps you can share some in the Off Topic forum?
                              💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                              Comment

                              Working...
                              X