I used node red for exactly that (except it is for my hallway, not toilet)
[{"id":"250d5853.dcd458","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"4a201612.4bf768","type":"mqtt in","z":"250d5853.dcd458","name":"Motion Hallway Upstairs","topic":"zigbee2mqtt/MotionHallwayUpstairs","qos":"2","datatype":"auto","broker":"f90cfe3b.a8bd7","x":160,"y":80,"wires":[["41b828c6.4777e8"]]},{"id":"b5a6b1b5.61ea3","type":"function","z":"250d5853.dcd458","name":"Turn on 1%","func":"if ( msg.payload.includes(\"\\\"occupancy\\\":true\"))\n{\n msg.payload = {\n domain: \"light\",\n service: \"turn_on\",\n data: {\n entity_id: \"light.light_hallway_upstairs\",\n \"brightness_pct\": 1\n }\n };\n}\nelse\n{\n msg.payload = \"do nothing\";\n}\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":470,"y":140,"wires":[["92816d41.91995","acb7a1f2.f664f"]]},{"id":"275f91b6.a6a3ae","type":"api-call-service","z":"250d5853.dcd458","name":"payload light","server":"37d68302.2aabcc","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1150,"y":180,"wires":[[]]},{"id":"f5741134.765c7","type":"delay","z":"250d5853.dcd458","name":"Delay massage","pauseType":"delayv","timeout":"10","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":960,"y":140,"wires":[["c767682a.d19b98"]]},{"id":"c767682a.d19b98","type":"function","z":"250d5853.dcd458","name":"Turn off","func":"msg.payload = {\n domain: \"light\",\n service: \"turn_off\",\n data: {\n entity_id: \"light.light_hallway_upstairs\"\n }\n};\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1140,"y":140,"wires":[["275f91b6.a6a3ae"]]},{"id":"92816d41.91995","type":"function","z":"250d5853.dcd458","name":"Reset 10m Delay","func":"msg.delay = 600000;\nvar m1 = {reset:true};\nreturn [[m1,msg]];","outputs":1,"noerr":0,"initialize":"","finalize":"","x":750,"y":140,"wires":[["f5741134.765c7"]]},{"id":"acb7a1f2.f664f","type":"switch","z":"250d5853.dcd458","name":"Only turn on","property":"payload.service","propertyType":"msg","rules":[{"t":"cont","v":"turn_on","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":730,"y":180,"wires":[["275f91b6.a6a3ae"]]},{"id":"c13c465.3e1bfb8","type":"server-state-changed","z":"250d5853.dcd458","name":"","server":"37d68302.2aabcc","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.light_hallway_upstairs","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":520,"y":80,"wires":[["92816d41.91995"],[]]},{"id":"2f6f6520.67324a","type":"function","z":"250d5853.dcd458","name":"Turn on 10%","func":"if ( msg.payload.includes(\"\\\"occupancy\\\":true\"))\n{\n msg.payload = {\n domain: \"light\",\n service: \"turn_on\",\n data: {\n entity_id: \"light.light_hallway_upstairs\",\n \"brightness_pct\": 10\n }\n };\n}\nelse\n{\n msg.payload = \"do nothing\";\n}\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":470,"y":180,"wires":[["acb7a1f2.f664f","92816d41.91995"]]},{"id":"41b828c6.4777e8","type":"time-range-switch","z":"250d5853.dcd458","name":"","lat":"51.83125","lon":"4.33552","startTime":"sunset","endTime":"sunrise","startOffset":"1","endOffset":0,"x":240,"y":160,"wires":[["b5a6b1b5.61ea3"],["2f6f6520.67324a"]]},{"id":"f90cfe3b.a8bd7","type":"mqtt-broker","z":"","name":"","broker":"hassio.aceindy.nl","port":"1883","clientid":"node-red","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"37d68302.2aabcc","type":"server","z":"","name":"Home Assistant"}]