No announcement yet.

Need help with this script

  • Filter
  • Time
  • Show
Clear All
new posts

    Need help with this script

    Hi I wrote this code with someone else long time ago, unfortunately the old sensor was not reporting the right values.

    I have a Z-Wave sensor (See attached) that seems very accurate. I tried many times to learn scripts, unfortunately I do not get it. Can someone please help changing this script with the one that reads this z-wave sensor. I want to change the Jowihue light color based on the sunlight outside.

    P.S I think this was written in vbs, not sure if would be beneficial to change it to vb. Any other suggestion would be great as well.

    Sub Main
    rem LightlevelStatus is going to be a string value
    rem 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
    LightlevelStatus = hs.plugin("Insteon").getdevicesetting("14.1A.AF","Current Light Level") ' Motion sensor Dining Room
    hs.WriteLog "LightLevelDining", LightlevelStatus 
    rem so you need to convert it to an integer here
    'if cint(LightlevelStatus) > 100 then
    'hs.plugin("Insteon").setdevicesetting "13.C1.F2","LED Brightness","80" ' set keypad
    'hs.plugin("Insteon").setdevicesetting "13.C1.F2","LED Brightness","40" ' set keypad
    'end if
    If cint(LightlevelStatus) >= 100 Then
    hs.plugin("Insteon").setdevicesetting "13.C1.F2","LED Brightness","100" ' set keypad to 100
    'LightKeypadStatus = hs.plugin("Insteon").getdevicesetting("13.C1.F2","LED Brightness")
    'hs.WriteLog "Keypad Light", cint(LightKeypadStatus)
    ElseIf cint(LightlevelStatus) >= 80 Then
    hs.plugin("Insteon").setdevicesetting "13.C1.F2","LED Brightness","80" ' set keypad to 80
    ElseIf cint(LightlevelStatus) >= 60 Then
    hs.plugin("Insteon").setdevicesetting "13.C1.F2","LED Brightness","60" ' set keypad to 60
    ElseIf cint(LightlevelStatus) >= 40 Then
    hs.plugin("Insteon").setdevicesetting "13.C1.F2","LED Brightness","40" ' set keypad to 40
    hs.plugin("Insteon").setdevicesetting "13.C1.F2","LED Brightness","20" ' set keypad to 20
    End If
    LightKeypadStatus = hs.plugin("Insteon").getdevicesetting("13.C1.F2","LED Brightness")
    hs.WriteLog "Keypad Light", cint(LightKeypadStatus)
    End Sub
    Attached Files