Announcement

Collapse
No announcement yet.

Help with this script please

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

    Help with this script please

    I would like to write a script that based on the light level of the motion sensor it will set the Hue level of brightness higher or lower based on the script example of JowiHue. I had similar script that was working in HS2. Unfortunately not really good at scripts. Can someone please help based on the prototype below. I'm open to suggestions to get the level of light more efficient instead of if statements.

    Syntax:
    Dim test As Boolean = hs.PluginFunction("JowiHue", "", "SetLightsHueSat", {True, "All Lights", Nothing, 65535, 255, 20})

    Sub Main(parm as object)

    ' LightlevelStatus is going to be a string value
    ' the theory is that if there is lot of sun you want to see the lights on the keypad while if dark you want to dim it for eye pleasure
    ' Motion sensor Dining Room

    LightlevelStatus = hs.plugin("Insteon").getdevicesetting("14.1A.AF","Current Light Level")

    'hs.WriteLog "LightLevelDining", LightlevelStatus
    'so you need to convert it to an integer here


    If cint(LightlevelStatus) >= 100 Then
    Dim test As Boolean = hs.PluginFunction("JowiHue", "", "SetLightsHueSat", {True, "All Lights", Nothing, 65535, 255, 20})

    ElseIf cint(LightlevelStatus) >= 80 Then

    Dim test As Boolean = hs.PluginFunction("JowiHue", "", "SetLightsHueSat", {True, "All Lights", Nothing, 65535, 255, 20})

    ElseIf cint(LightlevelStatus) >= 60 Then

    Dim test As Boolean = hs.PluginFunction("JowiHue", "", "SetLightsHueSat", {True, "All Lights", Nothing, 65535, 255, 20})

    ElseIf cint(LightlevelStatus) >= 40 Then

    Dim test As Boolean = hs.PluginFunction("JowiHue", "", "SetLightsHueSat", {True, "All Lights", Nothing, 65535, 255, 20})

    Else

    Dim test As Boolean = hs.PluginFunction("JowiHue", "", "SetLightsHueSat", {True, "All Lights", Nothing, 65535, 255, 20})


    End If

    Dim test As Boolean = hs.PluginFunction("JowiHue", "", "SetLightsHueSat", {True, "All Lights", Nothing, 65535, 255, 20})

    End Sub

    #2
    for HS3, it should be something like

    LightlevelStatus = hs.plugin("Insteon","","getdevicesetting", new object(){14.1A.AF","Current Light Level"})

    i believe the new object() is required to designate a new array
    Mark

    HS3 Pro 3.0.0.534
    Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
    Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
    Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

    Comment


      #3
      Mark I'm getting this error, do you know what this mean

      Sub Main(parm as object)

      Dim LightlevelStatus As Integer
      LightlevelStatus = hs.pluginFunction("Insteon","","getdevicesetting", new object(){14.1A.AF","Current Light Level"})

      End Sub


      Mar-08 10:48:13 AM Error Compiling script C:\HomeSeer3\scripts\KeyPadLincBrightness.vb: '}' expected.
      Mar-08 10:48:13 AM Error Compiling script C:\HomeSeer3\scripts\KeyPadLincBrightness.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.

      Comment


        #4
        Originally posted by aldo View Post
        Mark I'm getting this error, do you know what this mean

        Sub Main(parm as object)

        Dim LightlevelStatus As Integer
        LightlevelStatus = hs.pluginFunction("Insteon","","getdevicesetting", new object(){14.1A.AF","Current Light Level"})

        End Sub


        Mar-08 10:48:13 AM Error Compiling script C:\HomeSeer3\scripts\KeyPadLincBrightness.vb: '}' expected.
        Mar-08 10:48:13 AM Error Compiling script C:\HomeSeer3\scripts\KeyPadLincBrightness.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.
        i think youre missing a quote

        "14.1A.AF"
        Mark

        HS3 Pro 3.0.0.534
        Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
        Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
        Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

        Comment


          #5
          this is tested:

          Sub Main(parm as object)

          Dim LightlevelStatus As string
          LightlevelStatus = hs.pluginFunction("Insteon","","GetDeviceSetting", new object(){"27.8E.79","Current Light Level"})
          hs.writelog ("test", lightlevelstatus)
          End Sub
          the call is case-sensitive and returns a string

          you can convert to an integer with
          level = cint(LightlevelStatus)
          Mark

          HS3 Pro 3.0.0.534
          Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
          Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
          Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

          Comment


            #6
            aldo,

            You can do this with scripts, which gives you the simplicity of having to use only one event. I have done the same as you did, but instead I did it with a group holding 6 events which trigger basesd on group conditions and light level.

            I have attached my event which is setting the brightness level of the Hue lights. it is taking the light level from a zwave multisensor, but I am sure you can check the value also from a insteon device.

            Not sayin one is better then the other, just adding a sample on how you could look at the same issue.

            Wim
            Attached Files
            -- Wim

            Plugins:RFXCOM, HSTouch Server, Squeezebox, BLGData, Restart, Jon00's Perfmon and Network monitor, WeatherXML, BLBackup, TenScripting, BC4, Pushover, PHLocation, JowiHue, Zwave, Sonos
            650 devices ---- 336 events ----- 40 scripts

            Comment


              #7
              You guys are the best, sorry for bothering you sooooooo much.

              Comment


                #8
                No problem. glad you got it working
                Mark

                HS3 Pro 3.0.0.534
                Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
                Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
                Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

                Comment

                Working...
                X