Announcement

Collapse
No announcement yet.

Sending Message via script fails

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

    Sending Message via script fails

    Hi!

    Firstly great plugin! I've got this working nicely in terms of receiving messages and performing actions.

    I can send reply's using the send message action ok but can't send messages from scripts. I've tried both from within a script and from an event.

    Please see output below from logs. From what I could see from debugging the script it was failing on this line: plugin.PluginFunction("SendMessage", {s1(0), s1(1)})

    Any help would be much appreciated.

    Thanks
    Chris

    Sep-07 6:11:59 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: http://mono-project.com/Bugs)
    Sep-07 6:11:59 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Variable declaration without an 'As' clause; Object type assumed.
    Sep-07 6:11:59 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: The import 'System.Core' could not be found.
    Sep-07 6:11:51 PM Event Running script in background: /HomeSeer/scripts/BBMessenger.vb("Main","example@public.talk.google.com|Testin g")

    #2
    What operating system are you running?

    Originally posted by djmilez View Post
    Hi!

    Firstly great plugin! I've got this working nicely in terms of receiving messages and performing actions.

    I can send reply's using the send message action ok but can't send messages from scripts. I've tried both from within a script and from an event.

    Please see output below from logs. From what I could see from debugging the script it was failing on this line: plugin.PluginFunction("SendMessage", {s1(0), s1(1)})

    Any help would be much appreciated.

    Thanks
    Chris

    Sep-07 6:11:59 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: http://mono-project.com/Bugs)
    Sep-07 6:11:59 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Variable declaration without an 'As' clause; Object type assumed.
    Sep-07 6:11:59 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: The import 'System.Core' could not be found.
    Sep-07 6:11:51 PM Event Running script in background: /HomeSeer/scripts/BBMessenger.vb("Main","example@public.talk.google.com|Testin g")

    Comment


      #3
      Reading this thread https://forums.homeseer.com/showthread.php?t=175822

      Try this, add Imports System.Core to the beginning of BBMessenger.vb file

      -----new script file----


      Imports System.Core
      'BBMessenger example script on how to send a message via script
      Public Sub Main(ByVal Parms As Object)
      Dim logto As String = "BBMessenger-Script"
      hs.WriteLog(logto, "Running script")
      hs.WriteLog(logto, "Sending Message: " + Parms.ToString())
      Dim plugin = New HomeSeerAPI.PluginAccess(hs, "BBMessenger", "")
      Dim s1 As String() = Parms.ToString().Split("|".ToCharArray())
      If (s1.Length >= 2) Then
      If plugin IsNot Nothing Then
      plugin.PluginFunction("SendMessage", {s1(0), s1(1)})
      Else
      hs.WriteLog(logto, "Error sending message. Not able to locate the plug-in.")
      End If
      End If
      hs.WriteLog(logto, "Exiting script")
      End Sub



      -----end new script file----



      Originally posted by djmilez View Post
      Hi!

      Firstly great plugin! I've got this working nicely in terms of receiving messages and performing actions.

      I can send reply's using the send message action ok but can't send messages from scripts. I've tried both from within a script and from an event.

      Please see output below from logs. From what I could see from debugging the script it was failing on this line: plugin.PluginFunction("SendMessage", {s1(0), s1(1)})

      Any help would be much appreciated.

      Thanks
      Chris

      Sep-07 6:11:59 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: http://mono-project.com/Bugs)
      Sep-07 6:11:59 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Variable declaration without an 'As' clause; Object type assumed.
      Sep-07 6:11:59 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: The import 'System.Core' could not be found.
      Sep-07 6:11:51 PM Event Running script in background: /HomeSeer/scripts/BBMessenger.vb("Main","example@public.talk.google.com|Testin g")
      Attached Files

      Comment


        #4
        I did try that before and also came across that thread. But same still unfortunately. Running on Rasp Pi details below.

        HomeSeer Version: HS3 Standard Edition 3.0.0.313
        Linux version: Linux raspberrypi 4.4.48-v7+ #964 SMP Mon Feb 13 16:57:51 GMT 2017 armv7l GNU/Linux System

        Comment


          #5
          Seems New Object is required on Linux.

          https://forums.homeseer.com/showthread.php?t=188645

          I tried:

          plugin.PluginFunction("SendMessage", New Object {s1(0), s1(1)})

          But getting other errors now.

          Compiling script /HomeSeer/scripts/BBMessenger.vb: 'End Namespace' must be preceded by a matching 'Namespace'.
          Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Identifier expected.
          Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Identifier expected.
          Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Identifier expected.
          Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Identifier expected.
          Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Identifier expected.
          Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Identifier expected.
          Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Expected 'End'.
          Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Expected 'End'.
          Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Expected 'End'.
          Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Expected 'End'.
          Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Expected ')'.

          Comment


            #6
            My raspberry pi died. I am trying with QEMU windows emulation. I will try to pick up a raspberry pi 3 tomorrow.

            Bruce

            Originally posted by djmilez View Post
            Seems New Object is required on Linux.

            https://forums.homeseer.com/showthread.php?t=188645

            I tried:

            plugin.PluginFunction("SendMessage", New Object {s1(0), s1(1)})

            But getting other errors now.

            Compiling script /HomeSeer/scripts/BBMessenger.vb: 'End Namespace' must be preceded by a matching 'Namespace'.
            Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Identifier expected.
            Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Identifier expected.
            Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Identifier expected.
            Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Identifier expected.
            Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Identifier expected.
            Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Identifier expected.
            Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Expected 'End'.
            Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Expected 'End'.
            Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Expected 'End'.
            Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Expected 'End'.
            Sep-08 1:47:53 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Expected ')'.

            Comment


              #7
              I am able to replicate the issue on Debian 9. I think it is a HomeSeer issue, I am going to log a support case with HomeSeer.


              Updated script below to fix the object compile error. With this fix now I am getting Error: Compiling script /home/brbjr/HomeSeer/scripts/BBMessenger.vb: http://mono-project.com/Bugs)
              Sep-09 5:20:30 PM Error Compiling script /home/brbjr/HomeSeer/scripts/BBMessenger.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

              --script--

              Public Sub Main(ByVal Parms As Object)
              Dim logto As String = "BBMessenger-Script"
              hs.WriteLog(logto, "Running script")
              hs.WriteLog(logto, "Sending Message: " + Parms.ToString())
              Dim plugin As HomeSeerAPI.PluginAccess = New HomeSeerAPI.PluginAccess(hs, "BBMessenger", "")
              Dim s1 As String() = Parms.ToString().Split("|".ToCharArray())
              If (s1.Length >= 2) Then
              If plugin IsNot Nothing Then
              plugin.PluginFunction("SendMessage", {s1(0), s1(1)})
              Else
              hs.WriteLog(logto, "Error sending message. Not able to locate the plug-in.")
              End If
              End If
              hs.WriteLog(logto, "Exiting script")
              End Sub

              --end script ---


              Originally posted by djmilez View Post
              Hi!

              Firstly great plugin! I've got this working nicely in terms of receiving messages and performing actions.

              I can send reply's using the send message action ok but can't send messages from scripts. I've tried both from within a script and from an event.

              Please see output below from logs. From what I could see from debugging the script it was failing on this line: plugin.PluginFunction("SendMessage", {s1(0), s1(1)})

              Any help would be much appreciated.

              Thanks
              Chris

              Sep-07 6:11:59 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: http://mono-project.com/Bugs)
              Sep-07 6:11:59 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: Variable declaration without an 'As' clause; Object type assumed.
              Sep-07 6:11:59 PM Error Compiling script /HomeSeer/scripts/BBMessenger.vb: The import 'System.Core' could not be found.
              Sep-07 6:11:51 PM Event Running script in background: /HomeSeer/scripts/BBMessenger.vb("Main","example@public.talk.google.com|Testin g")

              Comment


                #8
                Thanks Bruce, i've tried with the changes to see if any different on Rasp Pi and it gives The import 'System.Core' could not be found, same still if I try and import this at the top.

                Will definitely be purchasing this plugin if I can get this resolved, got it working nicely in a script to receive messages and control devices and events, just need to be able to reply with a status.

                Cheers
                Chris

                Comment


                  #9
                  Chris,

                  I found a fix in the script syntax, mono is very picky . I pushed a update to the HS Store but it will not overwrite the BBMessenger.vb file, you need to manually update the file with the script below.

                  '---BBmessenger.vb script-----------

                  'BBMessenger example script on how to send a message via script
                  Public Sub Main(ByVal Parms As Object)
                  Dim logto As String = "BBMessenger-Script"
                  hs.WriteLog(logto, "Running script")
                  hs.WriteLog(logto, "Sending Message: " + Parms.ToString())
                  Dim plugin As HomeSeerAPI.PluginAccess = New HomeSeerAPI.PluginAccess(hs, "BBMessenger", "")
                  Dim s1 As String() = Parms.ToString().Split("|".ToCharArray())
                  If (s1.Length >= 2) Then
                  If plugin IsNot Nothing Then
                  Dim message(1) As Object
                  message(0) = s1(0)
                  message(1) = s1(1)
                  plugin.PluginFunction("SendMessage", message)
                  Else
                  hs.WriteLog(logto, "Error sending message. Not able to locate the plug-in.")
                  End If
                  End If
                  hs.WriteLog(logto, "Exiting script")
                  End Sub
                  '---End BBmessenger.vb script-----------

                  Bruce

                  Originally posted by djmilez View Post
                  Thanks Bruce, i've tried with the changes to see if any different on Rasp Pi and it gives The import 'System.Core' could not be found, same still if I try and import this at the top.

                  Will definitely be purchasing this plugin if I can get this resolved, got it working nicely in a script to receive messages and control devices and events, just need to be able to reply with a status.

                  Cheers
                  Chris

                  Comment


                    #10
                    Excellent that's sorted, thanks for resolving so quickly.

                    Is there any way to send images in messages? No worries if not just would be nice addition. But can always send a link to image instead.

                    Comment


                      #11
                      I researched sending pictures/files via XMPP messages in the past and determined that you have to reference a hosted url in the message.

                      Bruce

                      Originally posted by djmilez View Post
                      Excellent that's sorted, thanks for resolving so quickly.

                      Is there any way to send images in messages? No worries if not just would be nice addition. But can always send a link to image instead.

                      Comment

                      Working...
                      X