I am looking to have an event that slowly Dims our kids likes. Say 1% ever 10 seconds. I could use a straight event starting at 100% but I want the event to start where the light was set to last and keep going down to zero. Ideas?
Announcement
Collapse
No announcement yet.
Slowly dim a light.
Collapse
X
-
Here is a starting point. I wrote this script to use an HS switch/dimmer to control another dimmable zwave device that wasn't directly connected to the switch/dimmer's load. Its meant to be called by an event when a switch/dimmer is pressed and held either up or down, I had one event for each. You'd probably want to strip out the logic that sets keyreleased to 1001 or 2001 and likely include both for your local switch escape/cancel. If you didn't want to have a way to cancel the event locally you could strip out quite a bit.
Code:Imports System.Threading, System.Convert Public Sub Main(ByVal Parms As Object) '' This script should be called when a central scene is set to "held down" '' it dims A dimmable device either up Or down until the central scene becomes "key released" or the load hits 99 or 0 '' Parameters '<device ref #>|<device ref central scene #>|up|<dimrate>' or '<device ref #>|<device ref central scene #>|down|<dimrate>' '' ie: 79|78|up|10 Dim ParmArray() As String ParmArray = Parms.ToString.Split(ToChar("|")) Dim DeviceRef As Integer = Integer.Parse(ParmArray(0)) Dim DeviceValue As Integer = hs.DeviceValue(DeviceRef) Dim DeviceRefCS As Integer = Integer.Parse(ParmArray(1)) Dim DeviceValueCS As Integer Dim Keyreleased As Integer = 1001 Dim UpDown As String = ParmArray(2) '' DimStep is the increment value for each dim setting Dim DimStep As Integer = 3 If UpDown = "down" Then DimStep = DimStep * -1 If UpDown = "down" Then Keyreleased = 2001 '' DimRate is how long to take between dim levels; ie the rate of dimming in milliseconds Dim DimRate As Integer = Integer.Parse(ParmArray(3)) For value As Integer = 0 To 100 '' increment the dim% value then set min and max values DeviceValue = DeviceValue + DimStep If DeviceValue > 99 Then DeviceValue = 99 If DeviceValue < 0 Then DeviceValue = 0 '' set the device to the current value Dim cc As HomeSeerAPI.CAPIControl = hs.CAPIGetSingleControl(DeviceRef, True, "Dim (value)%", False, False) cc.ControlValue = DeviceValue Dim cr As HomeSeerAPI.CAPIControlResponse = hs.CAPIControlHandler(cc) '' get current central scene value DeviceValueCS = hs.DeviceValue(DeviceRefCS) '' check to see if we should exit the loop If DeviceValue = 0 Or DeviceValue = 99 Or DeviceValueCS = Keyreleased Then Exit Sub Thread.Sleep(DimRate) Next End Sub
HS4 Pro on Shuttle NC10U, Win10; Z-NET
Number of Devices: 449
Number of Events: 210
Plug-Ins: Arduino, BLLock, DirecTv, EasyTrigger, Honeywell WiFi Thermostat, MeiHarmonyHub, PHLocation2, Pushover 3P, UltraM1G3, WeatherXML, Worx Landroid, Z-Wave
External applications: Homebridge-homeseer, Geofency, EgiGeoZone.
- 1 like
Comment
-
If scripting is not your thing, Just create a virtual device called something like "Dimming enabled" that is on/off.
Then just use an event that runs every 10 seconds and if Dimming enabled is on then set Light level at Light level-1 (using easy trigger)
Probably do another event to turn the Dimming enabled off once the light is off
Comment
-
Originally posted by jmaddox View PostHere is a starting point. I wrote this script to use an HS switch/dimmer to control another dimmable zwave device that wasn't directly connected to the switch/dimmer's load. Its meant to be called by an event when a switch/dimmer is pressed and held either up or down, I had one event for each. You'd probably want to strip out the logic that sets keyreleased to 1001 or 2001 and likely include both for your local switch escape/cancel. If you didn't want to have a way to cancel the event locally you could strip out quite a bit.
But when researching your script I can across tenscriptings interface with Visual Studio and LOVED it. Can insert break points, kill dead script: basically a real coding and debug environment. It took me 10 minutes to modify your script and a day to get the coding environment set up-- but I love it now.
Other than the fact I am running it on Windows and it doesn't support a VI mode I am pretty happy. If I can run it on my Mac I would be thrilled.HS3 Pro Edition 3.0.0.435 (Windows Server 8.1 on ESXi box)
Plug-Ins Enabled:
Z-Wave:,RaspberryIO:,AirplaySpeak:,Ecobee:,
weatherXML:,JowiHue:,APCUPSD:,PHLocation:,Chromecast:,EasyTr igger:
Comment
-
For Z-Wave dimmers, I think you *should* be able to do this simply by sending a new ramp rate configuration command at the start of the event and then resetting it at the end, as shown below. But for some reason, I can't get this to work - it seems the device isn't accepting the parameter change. Anybody see a fault in the method here?
Comment
-
Originally posted by jvm View PostFor Z-Wave dimmers, I think you *should* be able to do this simply by sending a new ramp rate configuration command at the start of the event and then resetting it at the end, as shown below. But for some reason, I can't get this to work - it seems the device isn't accepting the parameter change. Anybody see a fault in the method here?
-Wade
Comment
Comment