Node Red - dim light to 50%, then after light was off and on go to 100%

Hi, I have a bathroom lights which I want to go to 50% dim directly after turning on. Then if turned off and on within 15 secs I want them to go to 100%.

And when turned off if should be ready for the next round. (later I will add to only act like this during night times).

I have the following code with some help elsewhere but I am staring blind. Anyone able to help a little?

Might be I am totally starting the wrong way :slight_smile:

[{"id":"f40ed57a.2d18d8","type":"server-state-changed","z":"fa5d903e.753e1","name":"Monitor Light State","server":"c6b350c5.b8b3c","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"light.badkamer_alle_spots","entityIdType":"exact","outputInitially":false,"stateType":"habool","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":610,"y":2540,"wires":[["8b88e9b8.0e0368","d98de194.b6d998"]]},{"id":"8b88e9b8.0e0368","type":"change","z":"fa5d903e.753e1","name":"Set InitialOn","rules":[{"t":"set","p":"payload.initialOn","pt":"msg","to":"$eq(trigger.payload.state,\"on\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":2520,"wires":[["f32e2b6f.8a2c88"]]},{"id":"d98de194.b6d998","type":"change","z":"fa5d903e.753e1","name":"Set InitialOff and Timestamp","rules":[{"t":"set","p":"payload.initialOff","pt":"msg","to":"$eq(trigger.payload.state,\"off\")","tot":"jsonata"},{"t":"set","p":"payload.timestamp","pt":"msg","to":"$millis()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":2560,"wires":[["f32e2b6f.8a2c88"]]},{"id":"f32e2b6f.8a2c88","type":"switch","z":"fa5d903e.753e1","name":"Check Conditions","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"eq","v":"true","vt":"str","v2":"true","v2t":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":1290,"y":2540,"wires":[["8c91bb55.1d0c28"],["3e652f5c.c660b6"],["3e652f5c.c660b6"]]},{"id":"8c91bb55.1d0c28","type":"api-call-service","z":"fa5d903e.753e1","name":"Set to 50% Brightness","server":"c6b350c5.b8b3c","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.badkamer_alle_spots"],"data":"{\"brightness\":50}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1530,"y":2500,"wires":[[]]},{"id":"3e652f5c.c660b6","type":"api-current-state","z":"fa5d903e.753e1","name":"Check Time Difference","server":"c6b350c5.b8b3c","version":3,"outputs":2,"halt_if":"15","halt_if_type":"num","halt_if_compare":"gt","entity_id":"light.badkamer_alle_spots","state_type":"num","blockInputOverrides":false,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload.timeDiff","override_payload":"msg","entity_location":"data","override_data":"msg","x":1540,"y":2560,"wires":[["4a4d1819.f60ab8"],[]]},{"id":"4a4d1819.f60ab8","type":"api-call-service","z":"fa5d903e.753e1","name":"Set to 100% Brightness","server":"c6b350c5.b8b3c","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.badkamer_alle_spots"],"data":"{\"brightness\":100}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1760,"y":2560,"wires":[[]]},{"id":"c892014cd5425127","type":"inject","z":"fa5d903e.753e1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":2480,"wires":[["8c91bb55.1d0c28"]]},{"id":"c6b350c5.b8b3c","type":"server","name":"Home Assistant","version":5,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

Your check conditions switch has 2 true outputs.