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: HS4 Pro Edition 4.2.19.0 (Windows - Running as a Service)
        Home Assistant 2024.3
        Operating System: Microsoft Windows 11 Pro - Desktop
        Z-Wave Devices via two Z-Net G3s
        Zigbee Devices via RaspBee on RPi 3b+
        WiFi Devices via Internal Router.

        Enabled Plug-Ins
        AK GoogleCalendar 4.0.4.16,AK HomeAssistant 4.0.1.23,AK SmartDevice 4.0.5.1,AK Weather 4.0.5.181,AmbientWeather 3.0.1.9,Big6 3.44.0.0,BLBackup 2.0.64.0,BLGData 3.0.55.0,BLLock 3.0.39.0,BLUPS 2.0.26.0,Device History 4.5.1.1,EasyTrigger 3.0.0.76,Harmony Hub 4.0.14.0,HSBuddy 4.51.303.0,JowiHue 4.1.4.0,LG ThinQ 4.0.26.0,ONVIF Events 1.0.0.5,SDJ-Health 3.1.1.9,TPLinkSmartHome4 2022.12.30.0,UltraCID3 3.0.6681.34300,Z-Wave 4.1.3.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:	885
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:	958
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:	976
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