Dimming light

Hello,
Hope this is the right sport for this.
I have a few Govee lights in my Daughters room. I’m trying to get the bulbs to dim up slowly and down slowly when turned on. I have been trying to use Node-red for this. Here is what I have now.
{“transition”:“3”,“rgb_color”:[0,0,255],“brightness_pct”:“100”}

I want them to dim up when the motion sensor detects motion.

I took a different appraoch:


It transistions from 100>75 at sunset and from 75>100 at sunrise.
Might be usefull (just change the timing and use something else to trigger it)

Note that it does use the depreciated loop timer, but I put it back…


[{"id":"2c7b0b2f0fe45ff7","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"3c41c684b0f0b497","type":"bigtimer","z":"2c7b0b2f0fe45ff7","outtopic":"","outpayload1":"turn_on","outpayload2":"turn_off","name":"Every day from Sunset until Sunrise","comment":"","lat":"51.831092","lon":"4.335460","starttime":"5004","endtime":"5003","starttime2":0,"endtime2":0,"startoff":"1","endoff":"-2","startoff2":0,"endoff2":0,"offs":0,"outtext1":"on","outtext2":"off","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"day7":"","month7":"","day8":"","month8":"","day9":"","month9":"","day10":"","month10":"","day11":"","month11":"","day12":"","month12":"","d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xday7":"","xmonth7":"","xday8":"","xmonth8":"","xday9":"","xmonth9":"","xday10":"","xmonth10":"","xday11":"","xmonth11":"","xday12":"","xmonth12":"","xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"randon1":false,"randoff1":false,"randon2":false,"randoff2":false,"repeat":false,"atstart":false,"odd":false,"even":false,"x":540,"y":260,"wires":[["95abdda12a50da81"],[],[]]},{"id":"7ab8c33eb536d77f","type":"function","z":"2c7b0b2f0fe45ff7","name":"light.outside_front","func":"if ( msg.reset != true ) \n{\n    if ( msg.payload.includes( \"turn_on\"))\n    {\n        msg.payload = {\n            domain: \"light\",\n            service: \"turn_on\",\n            data: {\n                entity_id: \"light.outside_front\",\n                \"brightness_pct\": (msg.count)\n            }\n        };\n    }\n    else\n    {\n        if ( msg.countLowerLimitReached != true )\n        {\n            msg.payload = {\n                domain: \"light\",\n                service: \"turn_on\",\n                data: {\n                    entity_id: \"light.outside_front\",\n                    \"brightness_pct\": ((100-msg.count) + 75)\n                }\n            };\n        }\n        else\n        {\n            msg.payload = {\n                domain: \"light\",\n                service: \"turn_off\",\n                data: {\n                    entity_id: \"light.outside_front\"\n                }\n            };\n        }\n    }\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1190,"y":240,"wires":[["7826c8dc93bc799e"]]},{"id":"95abdda12a50da81","type":"looptimer","z":"2c7b0b2f0fe45ff7","duration":"1","units":"Minute","maxloops":"25","maxtimeout":"1","maxtimeoutunits":"Hour","name":"","x":800,"y":260,"wires":[["6c244f9d1c0999cc"],["29187217db5be9f1"]]},{"id":"6c244f9d1c0999cc","type":"counter","z":"2c7b0b2f0fe45ff7","name":"100>75","init":"100","step":"1","lower":"75","upper":null,"mode":"decrement","outputs":1,"x":1000,"y":240,"wires":[["7ab8c33eb536d77f"]]},{"id":"29187217db5be9f1","type":"function","z":"2c7b0b2f0fe45ff7","name":"reset counter","func":"msg.reset = true;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1010,"y":280,"wires":[["6c244f9d1c0999cc"]]},{"id":"7826c8dc93bc799e","type":"api-call-service","z":"2c7b0b2f0fe45ff7","name":"Light.outside front","server":"37d68302.2aabcc","version":5,"debugenabled":false,"domain":"light","service":"","areaId":[],"deviceId":[],"entityId":["light.outside_front"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1390,"y":240,"wires":[[]]},{"id":"8fb8d9c014277333","type":"comment","z":"2c7b0b2f0fe45ff7","name":"Softstart outdoor lamp from 100-25 % in 25 minutes","info":"","x":890,"y":160,"wires":[]},{"id":"37d68302.2aabcc","type":"server","name":"Home Assistant","version":2,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

How long is slowly? 30 seconds? a minute? 5? How bright will the lights be at the start of the transition?

1 Like

Thanks for the reply
30-sec lights will start at 0%

Lights all react differently so you may need to adjust the delay and the brightness_step_pct.

[{"id":"ea59732efa7454ea","type":"inject","z":"f80b6c338afd5483","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":930,"y":1180,"wires":[["1304ed27487fd7cd"]]},{"id":"1304ed27487fd7cd","type":"api-call-service","z":"f80b6c338afd5483","name":"","server":"6b1110b5.183a4","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.lefty"],"data":"{    \"brightness\": 6,    \"color_name\": \"blue\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1150,"y":1180,"wires":[["f875c6dee756f794"]]},{"id":"f630d1c1ffba39c4","type":"api-call-service","z":"f80b6c338afd5483","name":"","server":"6b1110b5.183a4","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.lefty"],"data":"{    \"brightness_step_pct\": 3 }","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1730,"y":1180,"wires":[["006bb7276fb745cf"]]},{"id":"f875c6dee756f794","type":"trigger","z":"f80b6c338afd5483","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-500","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1520,"y":1180,"wires":[["f630d1c1ffba39c4"]]},{"id":"3603dd169d8f71b2","type":"trigger-state","z":"f80b6c338afd5483","name":"","server":"6b1110b5.183a4","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"light.lefty","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"property","propertyValue":"new_state.attributes.brightness","comparatorType":">=","comparatorValueDatatype":"num","comparatorValue":"255"}],"inputs":0,"outputs":3,"customoutputs":[{"messageType":"custom","messageValue":"{\"reset\":\"true\"}","messageValueType":"json","comparatorPropertyType":"always","comparatorPropertyValue":"","comparatorType":"<=","comparatorValue":"100","comparatorValueDataType":"num"}],"outputinitially":false,"state_type":"str","enableInput":false,"x":1000,"y":1260,"wires":[[],[],["f875c6dee756f794"]]},{"id":"6b1110b5.183a4","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"30"}]

Hmm…isn’t this just turn on, but not turning off?
I thought he wanted slowly increase when turning on and then slowly decrease when turning it off.

1 Like

it would be the same flow, just add a minus sign - to the brightness step.

Actually @aceindy you’re correct it’s unique enough that it should be posted

[{"id":"ea59732efa7454ea","type":"inject","z":"f80b6c338afd5483","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":1130,"y":1180,"wires":[["f875c6dee756f794"]]},{"id":"f630d1c1ffba39c4","type":"api-call-service","z":"f80b6c338afd5483","name":"","server":"6b1110b5.183a4","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.lefty"],"data":"{    \"brightness_step_pct\": -3 }","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1730,"y":1180,"wires":[[]]},{"id":"f875c6dee756f794","type":"trigger","z":"f80b6c338afd5483","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-500","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1460,"y":1180,"wires":[["f630d1c1ffba39c4"]]},{"id":"9e552fa81a2560c0","type":"trigger-state","z":"f80b6c338afd5483","name":"","server":"6b1110b5.183a4","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"light.lefty","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"property","propertyValue":"new_state.attributes.brightness","comparatorType":"<=","comparatorValueDatatype":"num","comparatorValue":"28"}],"inputs":0,"outputs":3,"customoutputs":[{"messageType":"custom","messageValue":"{\"reset\":\"true\"}","messageValueType":"json","comparatorPropertyType":"always","comparatorPropertyValue":"","comparatorType":"is","comparatorValue":"","comparatorValueDataType":"str"}],"outputinitially":false,"state_type":"str","enableInput":false,"x":1040,"y":1280,"wires":[[],[],["f875c6dee756f794","41a7887e690bc7e1"]]},{"id":"41a7887e690bc7e1","type":"api-call-service","z":"f80b6c338afd5483","name":"","server":"6b1110b5.183a4","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.lefty"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1730,"y":1280,"wires":[[]]},{"id":"6b1110b5.183a4","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"30"}]