Dusk to dawn dimmer with motion

I can't seem to find a simple way to do this without multiple apps/rules.

Outdoor flood light is on a dimmer. At sunset set dimmer to 5%. If motion detected, set brightness to 100. After motion stops set back to 5%. Turn off at sunrise.

I looked at this app, but think I'm still going to need to create a rule to turn the light on (dim) at sunset. I'm OCD. I rather do this all in one place. :slight_smile:
https://community.hubitat.com/t/release-lights-on-motion-plus-dim-before-off-remember-individual-bulb-states-etc

Why not do it as two rules?

Trigger for Rule 1 being sunset
Trigger for Rule 2 being motion detected. Rule 2 can have a predicate of times between sunset and sunrise

2 Likes

RM seems to work best like this - multiple rules vs putting logic all in one place. Easier to view and maintain. Of course if you get too many related rules then things can get complicated fast and you might end up with race conditions. A good naming scheme is helpful as well to keep things together. It's been a while since I messed around with RM though.. :wink:

1 Like

Actually, this can be done in a single rule. Here's an example .....

Screen Shot 2021-10-24 at 8.47.55 AM

2 Likes

I just spent the past 20 minutes trying to figure out how to replicate this in rule machine. I don't know if I'm just an idiot or what. :slight_smile: I swear every time I try to do anything with RM, it makes me want to throw the hub in the trash. I must be doing something wrong. :confused:

If you are using Rule Machine 5.1, then you can try importing my rule, and then editing it to match your devices. I have pasted it below:

Import This Rule

{"deviceReplacements":{"9":{"deviceName":"7","deviceLabel":"Bar Light","deviceTypeName":"Lutron Dimmer","deviceTypeNamespace":"hubitat"},"36":{"deviceName":"Dome Motion Sensor","deviceLabel":"Motion - Kitchen","deviceTypeName":"Dome Motion Sensor","deviceTypeNamespace":"hubitat"}},"appReplacements":{"5078":{"appTypeName":"Rule-5.1","appTypeNamespace":"hubitat","appType":"sys","appName":"Rule-5.1","appLabel":"Test <span style='color:red'>(Predicate false)</span","parentAppInstalledAppId":"5077","parentAppTypeName":"Rule Machine","parentAppTypeNamespace":"hubitat","parentAppName":"Rule Machine","parentAppLabel":"Rule Machine","childApps":{},"singleInstance":false}},"appData":{"5078":{"state":{"parens":{"0":0,"1":0,"2":0},"actionDone":true,"paused":false,"ndx":11,"selectActionsParams":{"label":"Test"},"editCondIf":null,"waitDone":{".3":{"1":true},".7":{"2":true}},"usesTime":false,"inIf":null,"trigCustoms":[],"repeating":null,"capabDone":true,"predCapabs":[1],"locationBlocked":[],"inRepIf":null,"ruleNdx":3,"firstR":{"0":false,"1":false,"2":false},"actionList":["1","2","3","4","5","9","6","7","8","10"],"timeTriggers":[],"locVars":{},"actLabelIndent":"","certainTimes":[],"prevState":{"PB":"true","36":"inactive"},"eval":{"0":[1],"1":[5],"2":[8]},"capabstrue":{"3":"When time is Sunset<span style='color:black'>(18:21)</span>","4":"Motion - Kitchen active","-1":{},"5":{},"-2":{}},"lastEvtDate":"24-Oct-2021","nestedInIf":[],"actions":{"1":{"wait":null,"delay":"","modes":{},"method":"getIfThen","indent":"","rule":1,"label":"IF (Motion - Kitchen active<span style='color:orange'>(F)</span><span style='color:orange'> [FALSE]</span>) THEN\\n","cond":0},"2":{"wait":null,"delay":"","modes":{},"method":"getSetDimmer","indent":"\\t","rule":null,"label":"\\tDim: Bar Light: 100\\n","cond":0},"3":{"wait":[1],"delay":"","modes":{},"method":"getWaitEvents","indent":"\\t","rule":null,"label":"\\tWait for event: Motion - Kitchen inactive\\n","cond":0},"4":{"wait":null,"delay":"","modes":{},"method":"getSetDimmer","indent":"\\t","rule":null,"label":"\\tDim: Bar Light: 5\\n","cond":0},"5":{"wait":null,"delay":"","modes":{},"method":"getEndIf","indent":"","rule":null,"label":"END-IF\\n","cond":0},"6":{"wait":null,"delay":"","modes":{},"method":"getSetDimmer","indent":"\\t","rule":null,"label":"\\tDim: Bar Light: 5\\n","cond":0},"7":{"wait":[2],"delay":"","modes":{},"method":"getWaitEvents","indent":"\\t","rule":null,"label":"\\tWait for event: When time is Sunrise<span style='color:black'>(07:08)</span>\\n","cond":0},"8":{"wait":null,"delay":"","modes":{},"method":"getOnOffSwitch","indent":"\\t","rule":null,"label":"\\tOff: Bar Light\\n","cond":0},"9":{"wait":null,"delay":"","modes":{},"method":"getIfThen","indent":"","rule":2,"label":"IF (Time is Sunset<span style='color:black'>(18:21)</span><span style='color:orange'>(F)</span><span style='color:orange'> [FALSE]</span>) THEN\\n","cond":0},"10":{"wait":null,"delay":"","modes":{},"method":"getEndIf","indent":"","rule":null,"label":"END-IF\\n","cond":0}},"actNdx":11,"lastEvtValue":0,"allVarsGT":[],"installed":true,"waitEvents":[],"private":"true","waitNdx":{".3":[1],".7":[2]},"allVars":{},"changedValues":true,"simpleCond":false,"nestedRepIf":[],"lastEvtTime":"09:25","condOper":"cond","hasPredicate":true,"nestedElse":[null,null],"needWaitCancel":false,"cutAction":[],"stopped":false,"wasRepeating":null,"nestedLabel":[],"oldInputAct":null,"token":1,"waitCondNdx":3,"capabsfalse":{"1":"Time between Sunset-1 minute<span style='color:black'>(18:20)</span> and Sunrise<span style='color:black'>(07:08)</span>","5":"Motion - Kitchen active","8":"Time is Sunset<span style='color:black'>(18:21)</span>"},"timeTriggersW":{},"stPrimed":false,"todn":{"tod":true,"n":8},"allLocalVars":{},"timeFormat":"HH:mm","olddValues":true,"needWaitDone":false},"appSettings":[{"deviceList":null,"multiple":false,"name":"actSubType.6","type":"enum","value":"getSetDimmer"},{"deviceList":null,"multiple":false,"name":"butEndIf","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"actSubType.7","type":"enum","value":"getWaitEvents"},{"deviceList":null,"multiple":false,"name":"pausRule","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"actSubType.8","type":"enum","value":"getOnOffSwitch"},{"deviceList":null,"multiple":false,"name":"actSubType.9","type":"enum","value":"getIfThen"},{"deviceList":null,"multiple":false,"name":"cond","type":"enum","value":null},{"deviceList":null,"multiple":false,"name":"insertAct","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"atSunriseOffset-2","type":"number","value":""},{"deviceList":null,"multiple":false,"name":"actSubType.1","type":"enum","value":"getIfThen"},{"deviceList":null,"multiple":false,"name":"endingA1","type":"time","value":""},{"deviceList":null,"multiple":false,"name":"actSubType.2","type":"enum","value":"getSetDimmer"},{"deviceList":null,"multiple":false,"name":"actSubType.3","type":"enum","value":"getWaitEvents"},{"deviceList":null,"multiple":false,"name":"actSubType.4","type":"enum","value":"getSetDimmer"},{"deviceList":null,"multiple":false,"name":"tstate4","type":"enum","value":"active"},{"deviceList":null,"multiple":false,"name":"butElse","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"actSubType.5","type":"enum","value":"getEndIf"},{"deviceList":null,"multiple":false,"name":"atOrBetween1","type":"bool","value":"false"},{"deviceList":null,"multiple":false,"name":"anotherWait","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"editToken","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"actType.1","type":"enum","value":"condActs"},{"deviceList":null,"multiple":false,"name":"uVar.2","type":"bool","value":""},{"deviceList":null,"multiple":false,"name":"uVar.4","type":"bool","value":""},{"deviceList":null,"multiple":false,"name":"uVar.6","type":"bool","value":""},{"deviceList":{"9":null},"multiple":true,"name":"onOffSwitch.8","type":"capability.switch","value":null},{"deviceList":null,"multiple":false,"name":"stopRule","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"delayAct.7","type":"enum","value":"none"},{"deviceList":null,"multiple":false,"name":"delayAct.8","type":"enum","value":"none"},{"deviceList":null,"multiple":false,"name":"actType.3","type":"enum","value":"delayActs"},{"deviceList":null,"multiple":true,"name":"logging","type":"enum","value":null},{"deviceList":null,"multiple":false,"name":"editCond","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"actType.2","type":"enum","value":"dimmerActs"},{"deviceList":null,"multiple":false,"name":"actType.5","type":"enum","value":"condActs"},{"deviceList":null,"multiple":false,"name":"delayAct.2","type":"enum","value":"none"},{"deviceList":null,"multiple":false,"name":"actType.4","type":"enum","value":"dimmerActs"},{"deviceList":null,"multiple":false,"name":"delayAct.3","type":"enum","value":"none"},{"deviceList":null,"multiple":false,"name":"actType.7","type":"enum","value":"delayActs"},{"deviceList":null,"multiple":false,"name":"delayAct.4","type":"enum","value":"none"},{"deviceList":null,"multiple":false,"name":"actType.6","type":"enum","value":"dimmerActs"},{"deviceList":null,"multiple":false,"name":"updateRule","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"actType.9","type":"enum","value":"condActs"},{"deviceList":null,"multiple":false,"name":"hasRule","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"delayAct.6","type":"enum","value":"none"},{"deviceList":null,"multiple":false,"name":"actType.8","type":"enum","value":"switchActs"},{"deviceList":null,"multiple":false,"name":"uVar2.2","type":"bool","value":""},{"deviceList":null,"multiple":false,"name":"uVar2.4","type":"bool","value":""},{"deviceList":null,"multiple":false,"name":"runAction","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"uVar2.6","type":"bool","value":""},{"deviceList":{"36":null},"multiple":true,"name":"rDev_5","type":"capability.motionSensor","value":null},{"deviceList":null,"multiple":false,"name":"editAct","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"tCapab-2","type":"enum","value":"Certain Time"},{"deviceList":null,"multiple":false,"name":"atOrBetween8","type":"bool","value":"true"},{"deviceList":null,"multiple":false,"name":"tCapab-1","type":"enum","value":"Motion"},{"deviceList":null,"multiple":false,"name":"cutAct","type":"enum","value":""},{"deviceList":null,"multiple":true,"name":"deleteAct","type":"enum","value":null},{"deviceList":null,"multiple":false,"name":"oper","type":"enum","value":null},{"deviceList":null,"multiple":false,"name":"actionDone","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"tCapab5","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"actSubType.10","type":"enum","value":"getEndIf"},{"deviceList":{"36":null},"multiple":true,"name":"tDev-1","type":"capability.motionSensor","value":null},{"deviceList":null,"multiple":false,"name":"tCapab3","type":"enum","value":"Certain Time"},{"deviceList":null,"multiple":false,"name":"tCapab4","type":"enum","value":"Motion"},{"deviceList":null,"multiple":false,"name":"not1","type":"bool","value":""},{"deviceList":null,"multiple":false,"name":"useST","type":"bool","value":"true"},{"deviceList":null,"multiple":false,"name":"dimTrack.6","type":"bool","value":""},{"deviceList":null,"multiple":false,"name":"atSunsetOffset3","type":"number","value":""},{"deviceList":null,"multiple":false,"name":"time3","type":"enum","value":"Sunset"},{"deviceList":null,"multiple":false,"name":"dimTrack.4","type":"bool","value":""},{"deviceList":null,"multiple":false,"name":"startingA8","type":"time","value":""},{"deviceList":null,"multiple":false,"name":"startSunsetOffset8","type":"number","value":""},{"deviceList":null,"multiple":false,"name":"startingA1","type":"time","value":""},{"deviceList":null,"multiple":false,"name":"doneST","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"startSunsetOffset1","type":"number","value":"-1"},{"deviceList":null,"multiple":false,"name":"dimTrack.2","type":"bool","value":""},{"deviceList":null,"multiple":false,"name":"refreshActions","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"dValues","type":"bool","value":"true"},{"deviceList":null,"multiple":false,"name":"doneWaits","type":"button","value":""},{"deviceList":{"9":null},"multiple":true,"name":"dimA.4","type":"capability.switchLevel","value":null},{"deviceList":null,"multiple":false,"name":"hasAll","type":"button","value":""},{"deviceList":{"9":null},"multiple":true,"name":"dimA.2","type":"capability.switchLevel","value":null},{"deviceList":null,"multiple":false,"name":"cancelCapab","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"origLabel","type":"text","value":"Test"},{"deviceList":null,"multiple":false,"name":"eraseRule","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"dimLA.6","type":"number","value":"5"},{"deviceList":null,"multiple":false,"name":"dimLA.4","type":"number","value":"5"},{"deviceList":null,"multiple":false,"name":"dimLA.2","type":"number","value":"100"},{"deviceList":null,"multiple":false,"name":"onOff.8","type":"bool","value":"false"},{"deviceList":null,"multiple":false,"name":"ending8","type":"enum","value":"atTime"},{"deviceList":null,"multiple":false,"name":"delete","type":"enum","value":null},{"deviceList":{"36":null},"multiple":true,"name":"tDev4","type":"capability.motionSensor","value":null},{"deviceList":null,"multiple":false,"name":"actType.10","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"actType.11","type":"enum","value":""},{"deviceList":null,"multiple":false,"name":"ending1","type":"enum","value":"Sunrise"},{"deviceList":null,"multiple":false,"name":"actionCancel","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"time-2","type":"enum","value":"Sunrise"},{"deviceList":{"9":null},"multiple":true,"name":"dimA.6","type":"capability.switchLevel","value":null},{"deviceList":null,"multiple":false,"name":"comments","type":"textarea","value":""},{"deviceList":null,"multiple":false,"name":"endSunriseOffset1","type":"number","value":""},{"deviceList":null,"multiple":false,"name":"editST","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"starting8","type":"enum","value":"Sunset"},{"deviceList":null,"multiple":false,"name":"state_5","type":"enum","value":"active"},{"deviceList":null,"multiple":false,"name":"starting1","type":"enum","value":"Sunset"},{"deviceList":null,"multiple":false,"name":"not5","type":"bool","value":""},{"deviceList":null,"multiple":false,"name":"rCapab_5","type":"enum","value":"Motion"},{"deviceList":null,"multiple":false,"name":"cancelST","type":"button","value":""},{"deviceList":null,"multiple":false,"name":"tstate-1","type":"enum","value":"inactive"},{"deviceList":null,"multiple":false,"name":"rCapab_1","type":"enum","value":"Between two times"},{"deviceList":null,"multiple":false,"name":"not8","type":"bool","value":""},{"deviceList":null,"multiple":false,"name":"dimRA.2","type":"number","value":""},{"deviceList":null,"multiple":false,"name":"dimRA.6","type":"number","value":""},{"deviceList":null,"multiple":false,"name":"dimRA.4","type":"number","value":""},{"deviceList":null,"multiple":false,"name":"rCapab_8","type":"enum","value":"Time of day"}],"subscriptions":[{"handler":"beforeSunsetHandlerST","name":"sunsetTime","type":"LOCATION","typeId":1,"typeName":"HubitatS","filter":"false"},{"handler":"sunrisesetHandlerST","name":"sunrise","type":"LOCATION","typeId":1,"typeName":"HubitatS","filter":"false"}]}}}

3 Likes

Thanks. I'll give it a whirl. I'm trying something I cobbled together in webcore for now. I'm really not any good with it, but it's easier to visualize for me the flow of things.

I'll update this thread with my findings both ways.

[edit] No dice on the import. Was I supposed to edit the text with my devices before importing? The import actually added two new devices for me (7 - luton dimmer, and a dome motion sensor). I tried editing the rule and I could change the light device, but couldn't figure out how to edit the motion sensor in the rule. When using "Edit if statement", I can't actually change anything.

I did get a webcore piston to do what I wanted but I would still like to understand rule machine and why I struggle so bad with it. I think it's just the in and out of different screens screw me up.

Thanks!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.