Announcement

Collapse
No announcement yet.

Problem with script errors

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

    Problem with script errors

    Hi,

    I'm trying to get some code working that @deloosem​ has created to send raw zwave commands to his radiator valve.
    But everytime I run it I get some errors:

    Script:
    Code:
    Public Sub Main(ByVal Parms As Object)
    
    Dim Bytes = New Byte() = {&H31, &H5, &H1, &H42, &H8, &HBE} ' transmits 22.38 c°
    
    hs.PluginFunction("Z-Wave", "", "SendZwaveRaw", New Object() {18, Bytes, Bytes.Length, False, "3dh76whs83"})
    
    End Sub


    Errors:
    Code:
    Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\simplescript.vb: 'Bytes' is not declared. It may be inaccessible due to its protection level.
    Jan-05 11:11:58         Error    Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\simplescript.vb: 'Bytes' is not declared. It may be inaccessible due to its protection level.
    Jan-05 11:11:58         Error    Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\simplescript.vb: '}' expected.
    Jan-05 11:11:58         Error    Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\simplescript.vb: Declaration expected.
    Jan-05 11:11:58         Error    Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\simplescript.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.
    ​
     ​
    If anyone can help?

    Thanks

    #2
    I think "Bytes" could be a reserved word. Try Dim B = New Byte().... (or some other name).

    Comment


      #3
      Originally posted by aa6vh View Post
      I think "Bytes" could be a reserved word. Try Dim B = New Byte().... (or some other name).
      Thanks, I tried that but the same errors persist.
      Not sure why it worked for the other chap.

      Comment


        #4
        I'm just beginning to learn this stuff, but I think "Dim Bytes = New Byte()" should be "Dim Bytes As New Byte()"
        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
          Originally posted by ewkearns View Post
          I'm just beginning to learn this stuff, but I think "Dim Bytes = New Byte()" should be "Dim Bytes As New Byte()"
          Just tried that, sadly the same error occurs.
          think I'm missing something obvious but not sure what.

          Comment


            #6
            That is my problem with working with multiple languages at the same time.

            The proper syntax is:

            Dim b as Byte
            Dim buffer(1024) As Byte

            https://learn.microsoft.com/en-us/do...byte-data-type

            Still suggest staying aware from using "bytes" as a variable name, too close to a reserve word (and can cause problems).

            Comment


              #7
              Try
              Code:
                      Dim bytes() As Byte = {&H31, &H5, &H1, &H42, &H8, &HBE}​

              Comment


                #8
                That appears to satisfy VS, but apparently, in the next line byte.Length is a no-no.
                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


                  #9
                  His next line is "Bytes.Length", (plural), which is correct.

                  Comment


                    #10
                    Originally posted by zwolfpack View Post
                    His next line is "Bytes.Length", (plural), which is correct.
                    Yeah, my bad, I forgot I had changed it to "b" so it wouldn't be so close to Byte.
                    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


                      #11
                      Originally posted by zwolfpack View Post
                      Try
                      Code:
                       Dim bytes() As Byte = {&H31, &H5, &H1, &H42, &H8, &HBE}​
                      Think I tried that, but not sure now.
                      This I think works, but not sure yet.
                      Does this look right?

                      Code:
                      Dim B As Byte() = New Byte() {0x71, 0x06, 0x01, 0xFF}

                      Comment


                        #12
                        No that generates a syntax error.

                        Comment


                          #13
                          Originally posted by zwolfpack View Post
                          No that generates a syntax error.
                          Strange because on my system that doesn't complain.

                          Nor does this:

                          Code:
                          Dim B() As Byte = {&H71, &H06, &H01, &HFF}

                          Comment


                            #14
                            Originally posted by SmartyPants View Post

                            Strange because on my system that doesn't complain.

                            Nor does this:

                            Code:
                            Dim B() As Byte = {&H71, &H06, &H01, &HFF}
                            That's the syntax I posted earlier. This declares an array of bytes and initializes it from the given list.

                            Comment


                              #15
                              Originally posted by zwolfpack View Post

                              That's the syntax I posted earlier.
                              Yes, sorry, that's what I meant.

                              Originally posted by zwolfpack View Post


                              This declares an array of bytes and initializes it from the given list.
                              Okay.

                              The original script which 'apparently' works has it has :

                              Code:
                              Dim Bytes = New Byte()
                              Is that doing the same thing?

                              Thanks

                              Comment

                              Working...
                              X