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})
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
' 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
Comment