Announcement

Collapse
No announcement yet.

Hs.writeLog command errors

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

    Hs.writeLog command errors

    Hi All,

    I have been searching the forum pages and I cannot get any scripts to run without throwing errors. What I am looking to do is write a event log each time an event is triggered. I started off by trying:

    Command to execute immediately, but when I do, I get the following error.
    &hs.writelog("Title","Log Text!")

    Error -> 'Running script(2) &hs.writelog("Title","Log Text!")("Main"), init error: Class doesn't support Automation: 'hs.writelog'

    Any help here would be appreciated as I am at a loss as to why this simple command will not execute.

    aslo tried with same results.
    &nhs.writelog("Title","Log Text!")






    #2
    With HS4 the hs.writelog statement does not work anymore. Instead use &hs.writelogex ("Title","Log Text!", "")
    The extra parameter can be a hex color or empty string

    Wim
    -- Wim

    Plugins: JowiHue, RFXCOM, Sonos4, Jon00's Perfmon and Network monitor, EasyTrigger, Pushover 3P, rnbWeather, BLBackup, AK SmartDevice, Pushover, PHLocation, Zwave, GCalseer, SDJ-Health, Device History, BLGData

    1210 devices/features ---- 392 events ----- 40 scripts

    Comment


      #3
      Thanks Wim. Still getting an error with this change...

      I have a simple Event setup. Run manually and Initiate command immediately.

      Command: &hs.writelogex ("Title","Log Text!", "")

      Here is the error I am receiving in the log. What is strange to me is that this is a single line event and I see two (2) entries for the log followed by an error.
      1. Clearly the code worked (twice)
      2. Then it fails.

      Not sure what this can be as I am at a loss why it is running twice and presenting errors in the log. Not sure if this is a bug, but feel it might be me.
      8/18/2020 12:03:25 PM HomeSeer Error Running script(1) &hs.writelogex ("Title","Log Text!", "")("Main"), init error: Type mismatch
      8/18/2020 12:03:25 PM Legacy-Plugin/Script Title Log Text!
      8/18/2020 12:03:25 PM Legacy-Plugin/Script Title Log Text!
      8/18/2020 12:03:25 PM HomeSeer Event Running script statement immediately (Event Log): &hs.writelogex ("Title","Log Text!", "")("Main")
      8/18/2020 12:03:25 PM HomeSeer Event Event Trigger "Notifications Event Log"
      8/18/2020 12:03:25 PM HomeSeer Event Event Notifications Event Log triggered by the event page 'Run' button.


      Comment


        #4
        try: &nhs.writelogex ("Title","Log Text!", "")

        Second thought, you may have to:

        try: &nhs.writelogex ("Title","Log Text!", "#000000")
        HomeSeer Version: HS3 Pro Edition 4.2.6.0
        Operating System: Microsoft Windows 10 Pro - Desktop

        Enabled Plug-Ins
        AK Google Calendar 3.0.0.45,AK Smart Device 3.0.0.6,AK Weather 4.0.1.77,AmbientWeather 3.0.1.9,Big5 1.38.0.0,BLBackup 2.0.63.0,BLGData 3.0.55.0,BLLock 3.0.38.0,BLPlex 2.0.22.0,BLUPS 2.0.26.0,Device History 3.2.0.2,EasyTrigger 3.0.0.74,HSBuddy 3.25.614.1,mcsMQTT 5.21.4.1,MeiHarmonyHub 3.1.0.22,NetCAM 3.0.0.14,PHLocation 3.0.1.109,Restart 1.0.0.7,SDJ-Health 3.1.0.3,SDJ-VStat 3.1.0.7,TPLinkSmartHome 19.10.7.1,UltraCID3 3.0.6681.34300,UltraSighthoundVideo3 3.0.5960.36744,,Z-Wave 3.0.2.0

        Comment


          #5
          Also

          &nhs.writelog("Title","Log Text!") works as well.
          Jon

          Comment


            #6
            Thanks All. Making me think there is something messed up in my deployment as these commands should work. Here is why I am at a loss.

            Testing what ewkerans suggested:
            8/18/2020 12:55:12 PM HomeSeer Error Running script(1) &writelogex ("Title","Log Text!", "#000000")("Main"), init error: Type mismatch: 'writelogex'
            8/18/2020 12:55:12 PM HomeSeer Event Running script statement immediately (Event Log): &writelogex ("Title","Log Text!", "#000000")("Main")
            8/18/2020 12:55:12 PM HomeSeer Event Event Trigger "Notifications Event Log"

            Testing what jon00 suggested:

            8/18/2020 12:57:54 PM HomeSeer Error 3 Running script C:\Program Files (x86)\HomeSeer HS4\Temp\K16.vb :Exception has been thrown by the target of an invocation.->Does entry point Main exist in script? at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Obj ect obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Scheduler.clsRunVBNetScript.ExecuteScript()
            8/18/2020 12:57:54 PM Script Title Log Text!
            8/18/2020 12:57:54 PM HomeSeer Event Running script statement immediately (Event Log): &nhs.writelog("Title","Log Text!")("Main")
            8/18/2020 12:57:54 PM HomeSeer Event Event Trigger "Notifications Event Log"
            8/18/2020 12:57:54 PM HomeSeer Event Event Notifications Event Log triggered by the event page 'Run' button.

            Contents of K16.vb.

            Function Main(parm as object)
            dim result as object
            result=hs.writelog("Title","Log Text!")("Main")
            return(result)
            End Function

            And for a added test with writelogex
            8/18/2020 1:01:08 PM HomeSeer Error 3 Running script C:\Program Files (x86)\HomeSeer HS4\Temp\K17.vb :Exception has been thrown by the target of an invocation.->Does entry point Main exist in script? at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Obj ect obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Scheduler.clsRunVBNetScript.ExecuteScript()
            8/18/2020 1:01:08 PM HomeSeer Event Running script statement immediately (Event Log): &nhs.writelogex("Title","Log Text!")("Main")
            8/18/2020 1:01:08 PM HomeSeer Event Event Trigger "Notifications Event Log"
            8/18/2020 1:01:08 PM HomeSeer Event Event Notifications Event Log triggered by the event page 'Run' button.


            Comment


              #7
              Get rid of the ("Main") in the statement. Not sure why you have added that.
              Jon

              Comment


                #8
                I give up the Main that is added is done by Homeseer when it creates the temp script.

                Comment


                  #9
                  Please don't give up. Post how you are trying to execute this command.

                  To prove it works, Go to Tools, Script Commands and enter the following in the text field:

                  &nhs.writelog("Title","Log Text!")

                  Then press 'Run'

                  Jon

                  Comment


                    #10
                    Originally posted by Bmurph213 View Post
                    Thanks All. Making me think there is something messed up in my deployment as these commands should work. Here is why I am at a loss.

                    Testing what ewkerans suggested:
                    8/18/2020 12:55:12 PM HomeSeer Error Running script(1) &writelogex ("Title","Log Text!", "#000000")("Main"), init error: Type mismatch: 'writelogex'
                    I think you forgot the hs in front for the writelogex. Here is an image of an event action that is working for me, maybe this helps: Click image for larger version

Name:	2020-08-19 14_29_20-Event.png
Views:	527
Size:	369.9 KB
ID:	1412377

                    -- Wim

                    Plugins: JowiHue, RFXCOM, Sonos4, Jon00's Perfmon and Network monitor, EasyTrigger, Pushover 3P, rnbWeather, BLBackup, AK SmartDevice, Pushover, PHLocation, Zwave, GCalseer, SDJ-Health, Device History, BLGData

                    1210 devices/features ---- 392 events ----- 40 scripts

                    Comment


                      #11
                      Thanks w.vuyk , that is exactly what I was trying to do.

                      here is what I ran under Tools -> Script commands:
                      &hs.writeLogEx("Title","Log Text!")
                      and it still does not work.

                      8/19/2020 2:21:48 PM HomeSeer Error Running script(2) &hs.writeLogEx("Title","Log Text!"), init error: Invalid procedure call or argument: 'hs.writeLogEx'
                      Click image for larger version

Name:	HomeSeer.jpg
Views:	562
Size:	37.8 KB
ID:	1412518

                      When I use &nhs.writeLogEx, it adds in the (main) at the end... Seems it might be something with my installation and less of a product issue.

                      Comment


                        #12
                        You are missing the last parameter!!!
                        use

                        &hs.writeLogEx("Title","Log Text!","" )

                        instead. The last parameter can be a color hex code like "#C0000"
                        -- Wim

                        Plugins: JowiHue, RFXCOM, Sonos4, Jon00's Perfmon and Network monitor, EasyTrigger, Pushover 3P, rnbWeather, BLBackup, AK SmartDevice, Pushover, PHLocation, Zwave, GCalseer, SDJ-Health, Device History, BLGData

                        1210 devices/features ---- 392 events ----- 40 scripts

                        Comment


                          #13
                          w.vuyk - Thank you so much. Yes, I must have dropped that at some point and your are right, I need it. I added it back and ran the same test from two points in the system

                          I am trying to RTM and not ask silly questions.

                          Still getting an error in Events, but not in Script Commands.


                          Click image for larger version

Name:	HomeSeer.jpg
Views:	567
Size:	27.2 KB
ID:	1412572

                          From the above event manually run
                          8/19/2020 4:40:28 PM HomeSeer Error Running script(2) &hs.writeLogEx("Title","Log Text!","" )("Main"), init error: Type mismatch: 'hs.writeLogEx(...)'
                          8/19/2020 4:40:28 PM HomeSeer Event Running script statement immediately (Event Log): &hs.writeLogEx("Title","Log Text!","" )("Main")

                          This is from Tools -> Scripts
                          8/19/2020 4:34:58 PM
                          HomeSeer System Control Panel Immediate Script: &hs.writeLogEx("Title","Log Text!","" )



                          Comment


                            #14
                            If you edit the event action, do you have "Main" in the Sub or Function field? If so, you need to delete that.
                            Jon

                            Comment


                              #15
                              There is no main function in the event. When you see the screenshot above, it is in edit mode to prove I am not adding (main) in my code. HS4 is doing that automatically and I cannot remove it. This is what is so frustrating and extremely annoying

                              Comment

                              Working...
                              X