Announcement

Collapse
No announcement yet.

Problem with a count line

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

  • Problem with a count line

    Hi all

    this is a piece of a script , and i dont know why he doesnt speak the last value from this line: If error_count = 0 Then

    there is no error , so normal he would need to trigger...



    PHP Code:
    pirdisabled_count 
                pirenabled_count 

                error_count 
    0
                pir_name 
    "" 
                
    pstr "" 
                
    For Each devp As String In array_pir 
                   dv 
    hs.GetDeviceByRef(devp)
                   
    location dv.location(hs)
                   
    pir_name dv.Name(hs)
                              
                   
    Select Case hs.DeviceValue(devp
                        Case 

                            pirenabled_count 
    pirenabled_count 
                            hs
    .speak(pir_name "  at the  " &   location "  is standby"
                        Case 

                            hs
    .speak("person detected in the " location
                        Case 
    11 
                            pirdisabled_count 
    pirdisabled_count 
                            hs
    .speak(pir_name "  at the  " &   location "  is Disabled"
                        Case 
    15 
                            hs
    .speak("P I R in the ** is Enabled"
                        Case 
    9
                            pirdisabled_count 
    pirdisabled_count 
                            hs
    .speak(" battery ")    
                            
                        Case Else  
                            
    error_count error_count 1
                            hs
    .speak (pir_name "  at the" location " has an error")
                    
    End Select 
                Next 
                hs
    .speak ("There are  " pirenabled_count " Sensors Enabled ")
                
    hs.speak ("And " pirdisabled_count " Sensors Disabled ")
                If 
    pirEnabled_count 0 Then 
                    hs
    .writelog("Array""enabled pir's: " pirenabled_count)
                If 
    pirdisabled_count 0 Then 
                    hs
    .writelog("Array""disabled pir's: " pirdisabled_count)
                If 
    error_count 0 Then 
                    hs
    .writelog("Array""Errors: " error_count)
                    
    hs.speak ("no Errors found")

                    
                
                Else 
                
                
                
    End If 
                
    End If
                
    End if 

    regards
    Last edited by Malosa; August 2nd, 2016, 12:36 PM. Reason: SOLVED :D
    Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
    Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




    HS3Pro 3.0.0.531 on windows 7 ultimate X64 on hp quadcore laptop 8 GB.

  • #2
    Originally posted by Malosa View Post
    Hi all

    this is a piece of a script , and i dont know why he doesnt speak the last value from this line: If error_count = 0 Then

    there is no error , so normal he would need to trigger...



    PHP Code:
    pirdisabled_count 
                pirenabled_count 

                error_count 
    0
                pir_name 
    "" 
                
    pstr "" 
                
    For Each devp As String In array_pir 
                   dv 
    hs.GetDeviceByRef(devp)
                   
    location dv.location(hs)
                   
    pir_name dv.Name(hs)
                              
                   
    Select Case hs.DeviceValue(devp
                        Case 

                            pirenabled_count 
    pirenabled_count 
                            hs
    .speak(pir_name "  at the  " &   location "  is standby"
                        Case 

                            hs
    .speak("person detected in the " location
                        Case 
    11 
                            pirdisabled_count 
    pirdisabled_count 
                            hs
    .speak(pir_name "  at the  " &   location "  is Disabled"
                        Case 
    15 
                            hs
    .speak("P I R in the ** is Enabled"
                        Case 
    9
                            pirdisabled_count 
    pirdisabled_count 
                            hs
    .speak(" battery ")    
                            
                        Case Else 
    'Optional 
                            error_count = error_count + 1
                            hs.speak (pir_name & "  at the" & location & " has an error")
                    End Select 
                Next 
                hs.speak ("There are  " & pirenabled_count & " Sensors Enabled ")
                hs.speak ("And " & pirdisabled_count & " Sensors Disabled ")
                If pirEnabled_count > 0 Then 
                    hs.writelog("Array", "enabled pir'
    s" & pirenabled_count)
                If pirdisabled_count > 0 Then 
                    hs.writelog("
    Array", "disabled pir's: " & pirdisabled_count)
                If error_count = 0 Then 
                    hs.writelog("Array", "Errors: " & error_count)
                    hs.speak ("no Errors found")

                    
                
                Else 
                
                
                End If 
                End If
                End if 

    regards
    You're missing a single quote on the line:
    Case Else 'Optional

    Should be 'Optional'

    Look at the color coding. You can see it's trying to show you were it's incorrect.

    Z

    Comment


    • #3
      Case Else needs to be there , if the device is a different state as the case ,
      the red color is because i use the ' i deleted it , check now again , because your quote is not valid anymore





      Originally posted by vasrc View Post
      You're missing a single quote on the line:
      'Optional

      Should be 'Optional'

      Look at the color coding. You can see it's trying to show you were it's incorrect.

      Z
      Last edited by Malosa; August 2nd, 2016, 07:55 AM.
      Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
      Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




      HS3Pro 3.0.0.531 on windows 7 ultimate X64 on hp quadcore laptop 8 GB.

      Comment


      • #4
        Sorry wasn't clear:

        Case Else 'Optional'

        Z

        Comment


        • #5
          hi vasrc

          i think you understand me wrong
          that is not the problem 'Optional' is just a text

          Case Else just works normal , and all the events under it , except this one : If error_count = 0 Then

          Originally posted by vasrc View Post
          Sorry wasn't clear:

          Case Else 'Optional'

          Z
          Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
          Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




          HS3Pro 3.0.0.531 on windows 7 ultimate X64 on hp quadcore laptop 8 GB.

          Comment


          • #6
            Originally posted by Malosa View Post
            hi vasrc

            i think you understand me wrong
            that is not the problem 'Optional' is just a text

            Case Else just works normal , and all the events under it , except this one : If error_count = 0 Then
            Then the listing you posted had a typo on the "Case Else 'Optional " line

            Check to make sure error_count IS equal to zero before your If check by putting some hs.writelog statements to see where it's changing.

            I'm guessing in the Case Else statement

            Z

            Comment


            • #7
              ok i changed the error_count to 1 and let it make an error

              still not speaking , but i declared it before the IF

              looks like it can't count


              look it doesnt even trigger the writelog events....


              Code:
              Aug-02 15:57:04	 	TTS	Speak ():And 2 Sensors Disabled
              Aug-02 15:57:04	 	TTS	Speak ():There are 0 Sensors Enabled
              Aug-02 15:57:04	 	TTS	Speak ():Motion sensor 3 at the Livingroom is Disabled
              Aug-02 15:57:04	 	TTS	Speak ():Motion sensor 1 Battery at the Garden has an error
              Aug-02 15:57:04	 	TTS	Speak ():Motion sensor 1 at the Garden is Disabled

              Originally posted by vasrc View Post
              Then the listing you posted had a typo on the "Case Else 'Optional " line

              Check to make sure error_count IS equal to zero before your If check by putting some hs.writelog statements to see where it's changing.

              I'm guessing in the Case Else statement

              Z
              Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
              Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




              HS3Pro 3.0.0.531 on windows 7 ultimate X64 on hp quadcore laptop 8 GB.

              Comment


              • #8
                Like now i got it working when there is nor error , it says no error and triggers also the logs ..

                but when there is an error (from case else ) , he doesnt speak anymore and no logs...

                Like if a device value has something else than 0,1,11,15,9 than it goes to Case else , after that nothing triggers anymore ,

                here the new code
                PHP Code:
                Sub pir(ByVal Parms As Object
                        Try 
                            
                pirdisabled_count 
                            pirenabled_count 

                            error_count 
                0
                            pir_name 
                "" 
                            
                pstr "" 
                            
                For Each devp As String In array_pir 
                               dv 
                hs.GetDeviceByRef(devp)
                               
                location dv.location(hs)
                               
                pir_name dv.Name(hs)
                                          
                               
                Select Case hs.DeviceValue(devp
                                    Case 

                                        pirenabled_count 
                pirenabled_count 
                                        hs
                .speak(pir_name "  at the  " &   location "  is standby"
                                    Case 

                                        hs
                .speak("person detected in the " location
                                    Case 
                11 
                                        pirdisabled_count 
                pirdisabled_count 
                                        hs
                .speak(pir_name "  at the  " &   location "  is Disabled"
                                    Case 
                15 
                                        hs
                .speak("P I R in the ** is Enabled"
                                    Case 
                9
                                        hs
                .speak(" battery ")    
                                        
                                    Case Else 
                                        
                error_count error_count 1
                                        hs
                .speak (pir_name "  at the" location " has an error")
                                
                End Select 
                            Next 
                            
                If pirEnabled_count 0 Then 
                                hs
                .writelog("Array""enabled pir's: " pirenabled_count)
                            If 
                pirdisabled_count 0 Then 
                                hs
                .writelog("Array""disabled pir's: " pirdisabled_count)
                            If 
                error_count 0 Then 
                                hs
                .writelog("Array""Errors: " error_count)
                            Else 
                              
                            
                End If 
                            
                End If
                            
                End if
                             
                '=======================================LOG COUNTS============================================================            
                            '
                hs.writelog("Array""enabled pir's: " pirenabled_count)
                            
                'hs.writelog("Array", "disabled pir's" & pirdisabled_count)
                            'hs.writelog("
                Array", "Errors" & error_count)
                '======================================SPEECH COUNTS==========================================================
                            If pirEnabled_count > 0 Then 
                            hs.speak ("
                There are  " & pirenabled_count & " Sensors Enabled ")
                            If pirdisabled_count > 0 Then 
                            hs.speak ("
                And " & pirdisabled_count & " Sensors Disabled ")
                            If error_count = 0 Then 
                            hs.speak ("
                no Errors found")
                            If error_count > 0 Then
                            hs.speak (error_count & " 
                errors found ")
                '===================================SPEECH CLIENT SELECT======================================================            
                            'speak trough selected speaker client string     
                            'hs.speak(pirdisabled_count & " 
                lol", True, "$SONOS$TTS") 
                '=============================================================================================================            
                            end if 
                            end if
                            end if 
                            end if
                        Catch ex As Exception 
                            hs.WriteLog("
                Array", "Error" & ex.Message) 
                        End Try 
                    End Sub 


                output without error in a device just all in case and it counts the errors , there are 0 :

                Code:
                Aug-02 16:23:19	 	TTS	Speak ():no Errors found
                Aug-02 16:23:19	 	TTS	Speak ():And 2 Sensors Disabled
                Aug-02 16:23:19	 	TTS	Speak ():There are 1 Sensors Enabled
                Aug-02 16:23:19	 	Array	Errors: 0
                Aug-02 16:23:19	 	Array	disabled pir's: 2
                Aug-02 16:23:19	 	Array	enabled pir's: 1
                Aug-02 16:23:19	 	TTS	Speak ():Motion sensor 3 at the Livingroom is Disabled
                Aug-02 16:23:19	 	TTS	Speak ():Motion sensor 2 at the Garage is standby
                Aug-02 16:23:19	 	TTS	Speak ():Motion sensor 1 at the Garden is Disabled

                output with an error in a device , using Case else :

                Code:
                Aug-02 16:22:22	 	TTS	Speak ():Motion sensor 3 at the Livingroom is Disabled
                Aug-02 16:22:22	 	TTS	Speak ():Motion sensor 1 Battery at the Garden has an error
                Aug-02 16:22:22	 	TTS	Speak ():Motion sensor 1 at the Garden is Disabled
                Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
                Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




                HS3Pro 3.0.0.531 on windows 7 ultimate X64 on hp quadcore laptop 8 GB.

                Comment


                • #9
                  Not sure I understand. What you listed for:
                  Output Case Else
                  Looks correct? It shows that an error occurred (Motion Sensor 1 Battery at the Garden) and it logged it. You're saying it's not speaking is all?

                  Z

                  Comment


                  • #10
                    yes look at the output of the error it only have the speak line for what device is enabled or disabled or an error ,

                    everything what comes next to it doesnt work...
                    but if it doesnt use the else (so no error) everything works


                    this line is from the case else
                    Aug-02 16:22:22 TTS Speak ():Motion sensor 1 Battery at the Garden has an error



                    Originally posted by vasrc View Post
                    Not sure I understand. What you listed for:
                    Output Case Else
                    Looks correct? It shows that an error occurred (Motion Sensor 1 Battery at the Garden) and it logged it. You're saying it's not speaking is all?

                    Z
                    Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
                    Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




                    HS3Pro 3.0.0.531 on windows 7 ultimate X64 on hp quadcore laptop 8 GB.

                    Comment


                    • #11
                      Is it getting past the Next statement or exiting before that?
                      Uncomment the duplicate Array logging and see if you can tell where it's exiting the script.
                      No other errors listed in the HS3 log?

                      Z

                      Comment


                      • #12
                        check my post at 8 , there is the detailed log

                        Its getting the statement after the next , but if an device has no error it works also and its after the next

                        no errors in my log , just not triggering behind this

                        PHP Code:
                        Sub pir(ByVal Parms As Object
                                Try 
                                    
                        pirdisabled_count 
                                    pirenabled_count 

                                    error_count 
                        0
                                    pir_name 
                        "" 
                                    
                        pstr "" 
                                    
                        For Each devp As String In array_pir 
                                       dv 
                        hs.GetDeviceByRef(devp)
                                       
                        location dv.location(hs)
                                       
                        pir_name dv.Name(hs)
                                                  
                                       
                        Select Case hs.DeviceValue(devp
                                            Case 

                                                pirenabled_count 
                        pirenabled_count 
                                                hs
                        .speak(pir_name "  at the  " &   location "  is standby"
                                            Case 

                                                hs
                        .speak("person detected in the " location
                                            Case 
                        11 
                                                pirdisabled_count 
                        pirdisabled_count 
                                                hs
                        .speak(pir_name "  at the  " &   location "  is Disabled"
                                            Case 
                        15 
                                                hs
                        .speak("P I R in the ** is Enabled"
                                            Case 
                        9
                                                hs
                        .speak(" battery ")    
                                                
                                            Case Else 
                                                
                        error_count error_count 1
                                                hs
                        .speak (pir_name "  at the" location " has an error")
                                        
                        End Select 
                        Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
                        Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




                        HS3Pro 3.0.0.531 on windows 7 ultimate X64 on hp quadcore laptop 8 GB.

                        Comment


                        • #13
                          Originally posted by Malosa View Post
                          yes look at the output of the error it only have the speak line for what device is enabled or disabled or an error ,

                          everything what comes next to it doesnt work...
                          but if it doesnt use the else (so no error) everything works


                          this line is from the case else
                          Aug-02 16:22:22 TTS Speak ():Motion sensor 1 Battery at the Garden has an error
                          Originally posted by Malosa View Post
                          check my post at 8 , there is the detailed log

                          Its getting the statement after the next , but if an device has no error it works also and its after the next

                          no errors in my log , just not triggering behind this
                          It's getting past the NEXT when it has an Error, but it may not for the NO error condition (I don't see any Array logs shown for NO error? It should have an Array No Errors at least). Try uncommenting the LOG COUNTS to see what they are.
                          Just checking to make sure it's actually executing the code and not exiting silently.

                          Z

                          Comment


                          • #14
                            here at post 8:

                            this is with no error


                            Code:
                            Aug-02 16:23:19	 	TTS	Speak ():no Errors found
                            Aug-02 16:23:19	 	TTS	Speak ():And 2 Sensors Disabled
                            Aug-02 16:23:19	 	TTS	Speak ():There are 1 Sensors Enabled
                            Aug-02 16:23:19	 	Array	Errors: 0
                            Aug-02 16:23:19	 	Array	disabled pir's: 2
                            Aug-02 16:23:19	 	Array	enabled pir's: 1
                            Aug-02 16:23:19	 	TTS	Speak ():Motion sensor 3 at the Livingroom is Disabled
                            Aug-02 16:23:19	 	TTS	Speak ():Motion sensor 2 at the Garage is standby
                            Aug-02 16:23:19	 	TTS	Speak ():Motion sensor 1 at the Garden is Disabled

                            The error is an device with value 75 just for testing
                            Speak ():Motion sensor 1 Battery at the Garden has an error

                            Originally posted by vasrc View Post
                            It's getting past the NEXT when it has an Error, but it may not for the NO error condition (I don't see any Array logs shown for NO error? It should have an Array No Errors at least). Try uncommenting the LOG COUNTS to see what they are.
                            Just checking to make sure it's actually executing the code and not exiting silently.

                            Z

                            Z
                            Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
                            Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




                            HS3Pro 3.0.0.531 on windows 7 ultimate X64 on hp quadcore laptop 8 GB.

                            Comment


                            • #15
                              Right, problem is WITH an error
                              Too many phone calls here....

                              Your log shows you get a Speak when you have an Error:
                              Aug-02 16:22:22 TTS Speak ():Motion sensor 1 Battery at the Garden has an error
                              Is that not working or it's logging but not actually saying anything? You're using what to Speak (ie TTS?)

                              Or is the logging in the IF statements that's not working?

                              Z

                              Comment

                              Working...
                              X