Announcement

Collapse
No announcement yet.

Passing a Parm via Actions, Script

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

    Passing a Parm via Actions, Script

    Hi, I'm new to the scripts. I would like to pass a device value to the script that will email me with the device value and log the device status. I'm sure there are many posts about it, but I could not find anything that looks like what I'm doing. Any help will be greatly appreciated.

    Thanks,
    Aldo

    Run script: TemperatureEmail.vb("Main", "hs.devicevalue("R2")")


    Script.
    Sub Main(ByVal parms() as Object)

    'Email codes

    'Log code
    hs.WriteLog "Test", parms
    End Sub

    #2
    Hows about;

    TemperatureEmail.vb("Main", "R2")

    Sub Main(ByVal parms() as String)

    Dim Temp = hs.devicevalue(parms)

    hs.WriteLog("Test", Temp)

    End Sub

    I think there are some parts of your code that are vbscript, others .net - with the object parameter you have to read each part of the parameter ie;

    Parms(0) = R
    Parms(1) = 2

    Or you can set the parameter as string and just read it in.

    Comment


      #3
      It gives me this error. Thanks for your help.

      5/26/2010 10:55:27 AM SCR Option Strict Offimports Schedulerimports SystemPublic Module scriptcode44#Region "Automatically generated code, do not modify"'Automatically generated code, do not modify'Event Sources Begin Public WithEvents hs As Scheduler.hsapplication Public WithEvents hsp As scheduler.hsp Public WithEvents hssystem As scheduler.phone0'Event Sources End'End of automatically generated code#End RegionSub Main(ByVal parms() as String)Dim Temp = hs.devicevalue(parms)hs.WriteLog("Test", Temp)End SubEnd Module
      5/26/2010 10:55:27 AM Error Script compile error: Value of type '1-dimensional array of String' cannot be converted to 'String'.on line 16
      5/26/2010 10:55:26 AM Event Running script in background: TemperatureEmail.vb("Main", "R2")

      Comment


        #4
        Change hs.WriteLog("Test", Temp) to hs.WriteLog("Test", Temp(0)) and see if that works
        -Rupp
        sigpic

        Comment


          #5
          Run script:TemperatureEmail.vb("Main", ""R2")

          Sub Main(ByVal parms() as Sring)
          Dim Temp as String
          Temp = hs.devicevalue(parms)
          hs.WriteLog("Test", Temp())


          5/26/2010 12:34:56 PM SCR Option Strict Offimports Schedulerimports SystemPublic Module scriptcode53#Region "Automatically generated code, do not modify"'Automatically generated code, do not modify'Event Sources Begin Public WithEvents hs As Scheduler.hsapplication Public WithEvents hsp As scheduler.hsp Public WithEvents hssystem As scheduler.phone0'Event Sources End'End of automatically generated code#End RegionSub Main(ByVal parms() as Sring)Dim Temp as StringTemp = hs.devicevalue(parms)hs.WriteLog("Test", Temp()) End SubEnd Module
          5/26/2010 12:34:56 PM Error Script compile error: Type 'Sring' is not defined.on line 14
          5/26/2010 12:34:56 PM Event Running script in background: TemperatureEmail.vb("Main", ""R2")

          Thanks

          Comment


            #6
            Originally posted by aldo View Post
            Run script:TemperatureEmail.vb("Main", ""R2")

            Sub Main(ByVal parms() as Sring)
            Dim Temp as String
            Temp = hs.devicevalue(parms)
            hs.WriteLog("Test", Temp())


            5/26/2010 12:34:56 PM SCR Option Strict Offimports Schedulerimports SystemPublic Module scriptcode53#Region "Automatically generated code, do not modify"'Automatically generated code, do not modify'Event Sources Begin Public WithEvents hs As Scheduler.hsapplication Public WithEvents hsp As scheduler.hsp Public WithEvents hssystem As scheduler.phone0'Event Sources End'End of automatically generated code#End RegionSub Main(ByVal parms() as Sring)Dim Temp as StringTemp = hs.devicevalue(parms)hs.WriteLog("Test", Temp()) End SubEnd Module
            5/26/2010 12:34:56 PM Error Script compile error: Type 'Sring' is not defined.on line 14
            5/26/2010 12:34:56 PM Event Running script in background: TemperatureEmail.vb("Main", ""R2")

            Thanks
            Did you include the zero as shown? Also looks like there are an extra set of quotes in the prototype line.
            -Rupp
            sigpic

            Comment


              #7
              Parms() as Sring probably isn't a happy thing. VB.NET knows what a "String" is, but not a "Sring"....

              Comment


                #8
                Also, you have spelt string incorrectly:

                Sub Main(ByVal parms() as Sring)

                Something like this should work:

                Run script:TemperatureEmail.vb("Main", "R2")

                Sub Main(ByVal parms as String)
                Dim Temp as String
                Temp = hs.devicevalue(parms)
                hs.WriteLog("Test", Temp)
                Jon

                Comment


                  #9
                  Thank you all, Rupp, the extra quote fixed the issue.

                  Aldo

                  Comment


                    #10
                    If I replace the Device R2 with \41 the results are 0. Do you know if I need to use something special for this type \41/
                    <TABLE border=0 cellSpacing=1 cellPadding=0 width="100%"><TBODY><TR><TD id=dv2035 class=tablecellcustom><TABLE><TBODY><TR><TD></TD><TD vAlign=center align=left>69%</TD></TR></TBODY></TABLE></TD><TD class=tablerowodd>Basement</TD><TD class=tablerowodd>Humidity</TD><TD class=tablerowodd>Family Basement </TD><TD class=tablerowodd>\41</TD><TD class=tablerowodd noWrap>Humidity</TD><TD class=tablerowodd noWrap>Today 1:49:00 PM </TD></TR></TBODY></TABLE>
                    Thanks,
                    Aldo

                    Comment


                      #11
                      It maybe that the plugin has not set the device value for the \41 virtual device.
                      Jon

                      Comment


                        #12
                        Sorry I'm confuse, what do you mean by "It maybe that the plugin has not set the device value for the \41 virtual device. " Can it be fixed?
                        The R2 seems to be the same type
                        <TABLE border=0 cellSpacing=1 cellPadding=0 width="100%"><TBODY><TR><TD id=dv7854 class=tablecellcustom><TABLE><TBODY><TR><TD></TD><TD vAlign=center align=left>45%</TD></TR></TBODY></TABLE></TD><TD class=tableroweven>Outside</TD><TD class=tableroweven>Temperature</TD><TD class=tableroweven>Forecast Humidity </TD><TD class=tableroweven>R2</TD><TD class=tableroweven noWrap>Humidity</TD><TD class=tableroweven noWrap>Today 12:44:06 PM </TD></TR></TBODY></TABLE>
                        Thank you for your patience.

                        Comment


                          #13
                          What plugin are you using for the weather?
                          Jon

                          Comment


                            #14
                            Nothing it is easy in Life :-) Michael McSharry mcsTemperature

                            Comment


                              #15
                              I don't use mcstemperature, however I would have thought he would set the device value.

                              Just to explain about virtual devices - you can set 3 parameters on a device:

                              DeviceString - this is what you normally see on the web page.
                              DeviceValue - this is a storage area and must be a Integer.
                              DeviceStatus - This provides a method to see if the device is on or off for example.

                              You are seeing the device string on the web page which is showing you the humidity value of 45% etc. Unfortunately, you cannot just read this instead of the device value as you would need to filter out the HTML code contained within.

                              You may need to post in Michaels forum to see if the device value is set or wait until someone else who uses the plugin appears.
                              Jon

                              Comment

                              Working...
                              X