Have a nice day
[{"id":"b800f482.f9644","type":"api-current-state","z":"416aa994.4ed0a8","name":"","server":"3c4e982f.072f98","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.desk","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1030,"y":4120,"wires":[["2bf5f354.a399b4","9b91ce09.fea9a8","aa52a5dd.b757e8"]]},{"id":"7d327404.504334","type":"switch","z":"416aa994.4ed0a8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":830,"y":4140,"wires":[["b800f482.f9644"],["7ffbc569.c584d4"]]},{"id":"b9649304.617668","type":"server-state-changed","z":"416aa994.4ed0a8","name":"","server":"3c4e982f.072f98","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.2min","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":640,"y":4140,"wires":[["7d327404.504334"]]},{"id":"2bf5f354.a399b4","type":"change","z":"416aa994.4ed0a8","name":"","rules":[{"t":"set","p":"oldstate1","pt":"flow","to":"data.attributes","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1310,"y":4120,"wires":[[]]},{"id":"9b91ce09.fea9a8","type":"change","z":"416aa994.4ed0a8","name":"","rules":[{"t":"set","p":"oldstate","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1300,"y":4080,"wires":[[]]},{"id":"7ffbc569.c584d4","type":"switch","z":"416aa994.4ed0a8","name":"","property":"oldstate","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":970,"y":4180,"wires":[["879839d8.6c415"],["a2c36dcf.43ffc"]]},{"id":"a2c36dcf.43ffc","type":"api-call-service","z":"416aa994.4ed0a8","name":"","server":"3c4e982f.072f98","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.desk","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1150,"y":4240,"wires":[[]]},{"id":"283af034.72a898","type":"api-call-service","z":"416aa994.4ed0a8","name":"","server":"3c4e982f.072f98","version":1,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"light.desk","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":true,"x":1310,"y":4180,"wires":[[]]},{"id":"6b004e52.aab6c","type":"api-call-service","z":"416aa994.4ed0a8","name":"","server":"3c4e982f.072f98","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.desk","data":"{\"brightness\":255,\"transition\":5,\"rgb_color\":[255,0,0]}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1490,"y":4040,"wires":[[]]},{"id":"aa52a5dd.b757e8","type":"delay","z":"416aa994.4ed0a8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1290,"y":4040,"wires":[["6b004e52.aab6c"]]},{"id":"879839d8.6c415","type":"function","z":"416aa994.4ed0a8","name":"","func":"var a = flow.get(\"oldstate1\");\nmsg.payload={\n \"data\":{\n \"rgb_color\":a.rgb_color,\n \"brightness\":a.brightness\n }\n}\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":4180,"wires":[["283af034.72a898"]]},{"id":"3c4e982f.072f98","type":"server","z":"","name":"Home Assistant1111","legacy":true}]