Dim light increase every x minute

And yet another solution:

Easy to adjust the brightness steps, start/end value and duration per loop:
“step”:“5”,“lower”:“0”,“upper”:“100”
“duration”:“0.05”,“maxloops”:“20”

Hello there, I want to stop a transition mid way when someone click a switch. Is there a way a msg or something I can send to stop a service that is runing (light transition).

Basically I want a light to transition to OFF in 30 min. But if someone presses the ligth switch I want the transition to stop.

Thanks in advance!

I did something like this, Check after sleeping a bit check if the brightness is where it is supposed to be and if it isn’t stop the loop, someone must have been using a switch. Note I couldn’t check exact value for brightness, it seems that when I set it it didn’t always come back exact, but within a range of 5 or so from the set value.

Code for that brightness in set range function:

var set_brightness = msg.brightness
var light_brightness = msg.data.attributes.brightness
var brightness_max = set_brightness + 5
var brightness_min = set_brightness - 5

if (brightness_max > light_brightness) {
    if (brightness_min < light_brightness)  {
        return [ msg, null ];
    }
} 
return [ null, msg ];

Hy and thank you for your flow coen17st!

I took your flow and expanded by a function. This sets the timer to 0 and stops it :slight_smile:

[{"id":"7aadd669.33ee88","type":"function","z":"a1629472.776fd8","name":"","func":"myCount = msg.countUpperLimitReached;   \nvar newMsg = { payload: \"STOP\", reset: true}\n\nif (myCount == true) {\n     return [newMsg, null];\n     \n} else {\n   return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":160,"y":1640,"wires":[["637ed21c.c6444c","d73f9e10.c886"]]},{"id":"192df8.a212e208","type":"api-call-service","z":"a1629472.776fd8","name":"","server":"dc4a800c.88fbb","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.wohnzimmer","data":"{\"brightness\":\"{{count}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":950,"y":1580,"wires":[[]]},{"id":"637ed21c.c6444c","type":"debug","z":"a1629472.776fd8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":550,"y":1700,"wires":[]},{"id":"62a11774.061d58","type":"inject","z":"a1629472.776fd8","name":"Start Trigger","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":165,"y":1450,"wires":[["d73f9e10.c886"]]},{"id":"d73f9e10.c886","type":"counter","z":"a1629472.776fd8","name":"Step = % Brightness","init":"0","step":"5","lower":"0","upper":"255","mode":"increment","outputs":"1","x":390,"y":1465,"wires":[["8480134.09905f"]]},{"id":"46ff3be7.7cd1b4","type":"stoptimer","z":"a1629472.776fd8","duration":"2","units":"Second","payloadtype":"num","payloadval":"0","name":"Transition time also depends on the step value.","x":580,"y":1580,"wires":[["d73f9e10.c886","7aadd669.33ee88","192df8.a212e208"],[]]},{"id":"8480134.09905f","type":"switch","z":"a1629472.776fd8","name":"Brightess Maximum","property":"count","propertyType":"msg","rules":[{"t":"lte","v":"255","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":620,"y":1465,"wires":[["46ff3be7.7cd1b4"]]},{"id":"37f3baf3.515b36","type":"inject","z":"a1629472.776fd8","name":"Stop Trigger","props":[{"p":"payload"},{"p":"reset","v":"true","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"STOP","payloadType":"str","x":150,"y":1520,"wires":[["d73f9e10.c886"]]},{"id":"dc4a800c.88fbb","type":"server","name":"Home Assistant"}]
2 Likes

good flow, thank you)