Announcement

Collapse
No announcement yet.

Noobie Scripting help

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

  • Noobie Scripting help

    Trying to do a very simple script do do the following.

    1) compare the humidity from the Nest thermostat to the humidity of the bathroom.
    2) Record the Nest Humidity every hour to a virtual device

    I am completely new to scripting. here is what I started with but it does not change the value on the virtual device.

    Sub Main(params as object)

    ' sets value of ambient humidity Device
    hs.SetDeviceValue(421,hs.DeviceValueEx(419))

    End Sub

    3) after this I would like to compare the Master Bath humidity to the NEst value when the master bath value changes. If it is over a threshold value i would run an event.

    No idea how to do this. Want to learn. Any help would be appreciated.

    Jason

  • #2
    Originally posted by Kanker80538 View Post
    Trying to do a very simple script do do the following.

    1) compare the humidity from the Nest thermostat to the humidity of the bathroom.
    2) Record the Nest Humidity every hour to a virtual device

    I am completely new to scripting. here is what I started with but it does not change the value on the virtual device.

    Sub Main(params as object)

    ' sets value of ambient humidity Device
    hs.SetDeviceValue(421,hs.DeviceValueEx(419))

    End Sub

    3) after this I would like to compare the Master Bath humidity to the NEst value when the master bath value changes. If it is over a threshold value i would run an event.

    No idea how to do this. Want to learn. Any help would be appreciated.

    Jason
    Not as fun as writing a script, but the Easy Trigger plugin can do this in an event.


    Sent from my iPad using Tapatalk
    HS3 3.0.0.548 &HSTouch Designer 3.0.71 with 996 Devices, 547 Events
    Plugin's:
    BLBackup, BLOccupied, BLShutdown, EasyTrigger, Ecobee, Nest, AK Bond
    EnvisaLink DSC, PHLocation, Pushover, SONOS, Blue Iris, UltraRachio3,
    weatherXML, Jon00 Alexa Helper, Network Monitor, MyQ, Z-Wave 3.0.1.252

    Comment


    • #3
      Originally posted by Kanker80538 View Post

      Code:
      Sub Main(params as object)
      
      ' sets value of ambient humidity Device
      hs.SetDeviceValue(421,hs.DeviceValueEx(419))
      
      End Sub
      No idea how to do this. Want to learn. Any help would be appreciated.
      Are you seeing an error in the log? Try changing the function to:"
      hs.SetDeviceValueByRef(421, hs.DeviceValueEx(419), True)

      Mike____________________________________________________________ __________________
      HS3 Pro Edition 3.0.0.548

      HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

      Comment


      • #4
        Thanks Profit! I would like to see if I can get the script to work. Would allow me more freedom to mess things up in the future.

        Comment


        • #5
          It worked for a minute then i tinkered and tried to get two devices values from two other devices.

          Sub Main(params as object)

          hs.SetDeviceValueByRef(421, hs.DeviceValueEx(419) True)
          hs.SetDeviceValueByRef(423, hs.DeviceValueEx(369) True)

          End Sub

          Now i get these errors.
          Sep-28 4:51:31 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: 'End Namespace' must be preceded by a matching 'Namespace'.
          Sep-28 4:51:31 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Identifier expected.
          Sep-28 4:51:31 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Identifier expected.
          Sep-28 4:51:31 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Expected 'End'.
          Sep-28 4:51:31 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Expected 'End'.
          Sep-28 4:51:31 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Expected ')'.
          Sep-28 4:51:30 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: 'End Namespace' must be preceded by a matching 'Namespace'.
          Sep-28 4:51:30 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Identifier expected.
          Sep-28 4:51:30 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Identifier expected.
          Sep-28 4:51:30 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Expected 'End'.
          Sep-28 4:51:30 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Expected 'End'.
          Sep-28 4:51:30 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Expected ')'.
          Sep-28 4:51:29 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: 'End Namespace' must be preceded by a matching 'Namespace'.
          Sep-28 4:51:29 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Identifier expected.
          Sep-28 4:51:29 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Identifier expected.
          Sep-28 4:51:29 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Expected 'End'.
          Sep-28 4:51:29 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Expected 'End'.
          Sep-28 4:51:29 PM Error Compiling script /usr/local/HomeSeer/scripts/AmbientHumidity.vb: Expected ')'.

          Comment


          • #6
            Here is the new script:

            Sub Main(params as object)

            DIM HumidDiff as integer
            DIM HumidAmb as integer
            DIM HumidMB as integer

            'HumidDiff difference of the ambient and Master bath Humidity
            'HumidAmb Ambient Humidity
            'HumidMB Master bath Humidity

            HumidAmb = hs.DeviceValueEx(419)
            HumidMB = hs.DeviceValueEx(369)
            HumidDiff = HumidMB-HumidAmb

            hs.SetDeviceValueByRef(421, hs.DeviceValueEx(419), True)
            hs.SetDeviceValueByRef(423, hs.DeviceValueEx(369), True)
            hs.SetDeviceValueByRef(424, HumidDiff, True)

            End Sub

            Only error that i get is:

            In device utility postback: Conversion from string "424,424" to type 'Integer' is not valid.

            And when it runs it seems to run 5 times. Device 424 is a virtual device that just shows the humidity difference. Any help is appreciated.

            Jason

            Comment


            • #7
              Originally posted by Kanker80538 View Post
              Only error that i get is:

              In device utility postback: Conversion from string "424,424" to type 'Integer' is not valid.

              And when it runs it seems to run 5 times. Device 424 is a virtual device that just shows the humidity difference. Any help is appreciated.
              How are the humidity values reported?
              Try changing the declaration of your variables to Double rather than Integer.
              You could also try adding these lines just before the hs.Set commands:
              hs.WriteLog("HumidDiff", CStr(HumidDiff))
              hs.WriteLog("HumidAmb", CStr(HumidAmb))
              hs.WriteLog("HumidMB", CStr(HumidMB))

              Mike____________________________________________________________ __________________
              HS3 Pro Edition 3.0.0.548

              HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

              Comment

              Working...
              X