Announcement

Collapse
No announcement yet.

'Trigger' is a type and cannot be used as an expression

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

  • 'Trigger' is a type and cannot be used as an expression

    Hi All,

    I have a paging system I run on my HS setup which allows me to respond to calls and have the house turn on lights and so on. Initially I was running this through a serial port, however I came to the realization that I am using the data across a number of different applications (Homeseer, Web Server, Push Messaging and so on). With this in mind I have started the task of converting my program to work on websockets, so that I have one central 'processor' which handles all of the pager messages and extracts dates, addresses, geocodes and so on, and this is passed through a websocket connection to the listening clients (e.g. Homeseer).

    I have almost converted my program, but I am noticing on this code below, I am getting two Errors. This has be confused because I thought I had copied and pasted the cost so I am not sure what these errors mean, or how to fix them.

    The errors are

    1. 'trigger' is a type and cannot be used as an expression (relates to DeserialiseObject)
    2. reference to a non shared member requries an object reference (relates to trigger.keys)

    I am at a bit of a loss with this as I programmed the code so long ago I have no idea how I should be changing the error 1 (which i think should fix error 2), can anyone point me in the right direction as to what I have done wrong and how to fix it?

    Many Thanks!



    Code:
    Public Sub CheckTriggers(ByVal cPriority As String, ByVal cBrigade As String, ByVal cCallType As String, ByVal cCapcode As Integer, ByVal cMessage As String)
            Try
                Dim TrigsToCheck() As IAllRemoteAPI.strTrigActInfo = Nothing
                Dim TC As IAllRemoteAPI.strTrigActInfo = Nothing
    
                Dim sKey As String
                Dim Priority As String = ""
                Dim Brigade As String = ""
                Dim CallType As String = ""
                Dim UID As String
    
    
                Try
                    TrigsToCheck = callback.TriggerMatches(IFACE_NAME, 1, -1)
                Catch ex As Exception
                End Try
    
                If TrigsToCheck IsNot Nothing AndAlso TrigsToCheck.Count > 0 Then
                    For Each TC In TrigsToCheck
    
                        UID = TC.UID.ToString
    
                        If Not (TC.DataIn Is Nothing) Then
                            DeSerializeObject(TC.DataIn, trigger)
                        End If
    
                        For Each sKey In trigger.Keys
                            Select Case True
                                Case InStr(sKey, "Priority_" & UID) > 0
                                    Priority = Trim(trigger(sKey))
                                Case InStr(sKey, "Brigade_" & UID) > 0
                                    Brigade = Trim(trigger(sKey))
                                Case InStr(sKey, "CallType_" & UID) > 0
                                    CallType = Trim(trigger(sKey))
                            End Select
                        Next
    
                        If (Priority = cPriority Or Priority = "Any") And (Brigade = cBrigade Or Brigade = "Any") And (CallType = cCallType Or CallType = "Any") Then
                            Console.WriteLine(" the message that triggered this was " & cMessage)
                            callback.TriggerFire(IFACE_NAME, TC)
                        End If
                    Next
                End If
            Catch ex As Exception
                Console.WriteLine("##ERROR## " & ex.Message)
                Console.WriteLine("")
            End Try
    
        End Sub
    HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

    Facebook | Twitter | Flickr | Google+ | Website | YouTube

  • #2
    Have you got the trigger object declared for it to be deserialised into?

    You can also test the deserialise

    Code:
    For Each TrigValue As String In trigger.Values
    Log("trigger.Values: " & TrigValue, LogLevel.Debug)
    Next
    My Plugins:

    Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
    Yeelight 3P | Nanoleaf 3P

    Comment


    • #3
      Thanks for the tips, turns out by accident I had removed Dim trigger as new trigger
      HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

      Facebook | Twitter | Flickr | Google+ | Website | YouTube

      Comment

      Working...
      X