Take look at this. The first one turns on the toilet light only after certain dark hours using the xiaomi motion sensor at full brightness until 21:00, after that it goes to minimum brightness, and warm light until end of night.
The second one takes care of turning off the light, in case someone forgets to turn it off the light via the xiaomi wall switch.
Don’t forget to change your ha url and password.
Hope it helps
[{"id":"761b8f45.ef05d","type":"server-state-changed","z":"d6bc1d0b.a1a34","name":"ToiletMotionSensor","server":"d5ce5cec.92bc8","entityidfilter":"binary_sensor.motion_sensor_158d0001e55241","entityidfiltertype":"substring","haltifstate":"off","x":130,"y":260,"wires":[["15469816.653ff8"]]},{"id":"e8cd416a.5f2f6","type":"api-call-service","z":"d6bc1d0b.a1a34","name":"LateNight","server":"d5ce5cec.92bc8","service_domain":"light","service":"turn_on","data":"{ \"entity_id\":\"light.bathroom\", \"brightness\": 2,\"rgb_color\": [255, 120, 0]}","mergecontext":"","x":1260,"y":300,"wires":[[]]},{"id":"10038ad8.9bfd35","type":"time-range-switch","z":"d6bc1d0b.a1a34","name":"LateOrEarlyNight","lat":"-26.7880988","lon":"153.1214329","startTime":"sunset","endTime":"21:00","startOffset":"-45","endOffset":"","x":1050,"y":260,"wires":[["eeb4eeb4.8a10c"],["e8cd416a.5f2f6"]]},{"id":"eeb4eeb4.8a10c","type":"api-call-service","z":"d6bc1d0b.a1a34","name":"EarlyNight","server":"d5ce5cec.92bc8","service_domain":"light","service":"turn_on","data":"{ \"entity_id\":\"light.bathroom\", \"brightness\": 255, \"rgb_color\": [255,236,221]}","mergecontext":"","x":1270,"y":220,"wires":[[]]},{"id":"15469816.653ff8","type":"time-range-switch","z":"d6bc1d0b.a1a34","name":"CheckTime","lat":"-26.7880988","lon":"153.1214329","startTime":"sunrise","endTime":"sunset","startOffset":"30","endOffset":"-45","x":670,"y":260,"wires":[[],["10038ad8.9bfd35"]]},{"id":"f4a97312.ebd6b","type":"comment","z":"d6bc1d0b.a1a34","name":"Turn on toilet light at night","info":"","x":200,"y":200,"wires":[]},{"id":"8db0789c.0e1788","type":"comment","z":"d6bc1d0b.a1a34","name":"Turn off toilet light ","info":"","x":190,"y":500,"wires":[]},{"id":"38c1ff40.d18bc","type":"server-state-changed","z":"d6bc1d0b.a1a34","name":"ToiletLight","server":"d5ce5cec.92bc8","entityidfilter":"light.bathroom","entityidfiltertype":"substring","haltifstate":"","x":180,"y":580,"wires":[["76e1bc21.87ea14"]]},{"id":"76e1bc21.87ea14","type":"switch","z":"d6bc1d0b.a1a34","name":"LightOn","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":360,"y":580,"wires":[["6e47b359.1532ec"]]},{"id":"6e47b359.1532ec","type":"delay","z":"d6bc1d0b.a1a34","name":"5Minutes","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":500,"y":580,"wires":[["d1c1080a.440d78"]]},{"id":"d1c1080a.440d78","type":"api-current-state","z":"d6bc1d0b.a1a34","name":"CheckSensor","server":"d5ce5cec.92bc8","halt_if":"","override_topic":true,"override_payload":true,"entity_id":"binary_sensor.motion_sensor_158d0001e55241","x":720,"y":720,"wires":[["1719bd4f.d48593"]]},{"id":"1719bd4f.d48593","type":"switch","z":"d6bc1d0b.a1a34","name":"checkForDelay","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":760,"y":580,"wires":[["db4e432c.f803c"],[]]},{"id":"db4e432c.f803c","type":"delay","z":"d6bc1d0b.a1a34","name":"3Minutes","pauseType":"delay","timeout":"3","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1000,"y":500,"wires":[["a3a0a7c5.74a248"]]},{"id":"a3a0a7c5.74a248","type":"api-current-state","z":"d6bc1d0b.a1a34","name":"CheckSensor","server":"d5ce5cec.92bc8","halt_if":"","override_topic":true,"override_payload":true,"entity_id":"binary_sensor.motion_sensor_158d0001e55241","x":1200,"y":500,"wires":[["ef3ff256.8ba43"]]},{"id":"ef3ff256.8ba43","type":"switch","z":"d6bc1d0b.a1a34","name":"presenceDetected","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1390,"y":500,"wires":[["24d665bd.8a183a"],["6f90347b.24537c"]]},{"id":"24d665bd.8a183a","type":"api-call-service","z":"d6bc1d0b.a1a34","name":"TurnOff","server":"d5ce5cec.92bc8","service_domain":"light","service":"turn_off","data":"{ \"entity_id\":\"light.bathroom\"}","mergecontext":"","x":1580,"y":460,"wires":[["502efc34.9f81b4"]]},{"id":"502efc34.9f81b4","type":"debug","z":"d6bc1d0b.a1a34","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1510,"y":820,"wires":[]},{"id":"6f90347b.24537c","type":"delay","z":"d6bc1d0b.a1a34","name":"30Seconds","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1230,"y":640,"wires":[["a3a0a7c5.74a248"]]},{"id":"d5ce5cec.92bc8","type":"server","z":"","name":"Home Assistant","url":"https://HA:8123","pass":"password"}]