Announcement

Collapse
No announcement yet.

Can I catch a error in a case statement ?

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

  • Can I catch a error in a case statement ?

    This is my heating logic, but I would like to add a safeguard just in case TempOutside has for example a communication error, then I would like to ignore anything relating to TempOutside

    Code:
    Sub Main(ByVal Parms As Object)
    
            Dim TempHall As Double
            Temperature = hs.DeviceValueEx(308)
            Dim TempKitchen As Double
            Temperature = hs.DeviceValueEx(17)
            Dim TempOutside As Double
            Temperature = hs.DeviceValueEx(14)
    
            Select Case TempHall
    
                Case > 19.3
                    hs.TriggerEvent("Load Heating off")
    
                Case 19 To 19.3
                    hs.TriggerEvent("Load Heating mornings only")
    
                Case 18.7 To 19
                    hs.TriggerEvent("Load Heating mornings and evenings")
    
                Case 18.2 to 18.7
                    If TempOutside is < 1
                    hs.TriggerEvent("Load Heating very cold")
                    Else
                    hs.TriggerEvent("Load Heating cold")
                    EndIf
    
                Case < 18.2
                    hs.TriggerEvent("Load Heating very cold")
    
                
    
            End Select
    
        End Sub
    Last edited by mikee123; October 10th, 2016, 04:48 AM. Reason: changed question as I found a solution to original question

  • #2
    Is this a Oregon Scientific sensor with the RFXCom plugin? If so, then I would check to see if the DeviceString is not set to "Communication Failure" using an if statement.

    Cheers
    Al

    PS in your script you declare some variables, but you set "Temperature" to the device values over and over again, rather than the variables you declared.
    HS 3.0.0.548: 1965 Devices 1146 Events
    Z-Wave 3.0.1.262: 122 Nodes on one Z-Net

    Comment


    • #3
      It is a Oregon Scientific via RFXcom. I can therefore check for a comms failure as you suggested, but what do I do in that case so that the condition gets ignored when there is a comms failure ?

      I didn't see the temperature being declared over and over again, I have now corrected that.

      Comment


      • #4
        Something like:

        Code:
        Case 18.2 to 18.7
               If hs.DeviceString(14) <> "Communication Failure" Then
                        If TempOutside is < 1
                           hs.TriggerEvent("Load Heating very cold")
                        Else
                           hs.TriggerEvent("Load Heating cold")
                        End If
                End If
        HS 3.0.0.548: 1965 Devices 1146 Events
        Z-Wave 3.0.1.262: 122 Nodes on one Z-Net

        Comment

        Working...
        X