Config couterflow

I have a sonof push button in HA. This should turn on a lamp when pressed once and when I press the push button twice the lamp should be turned off. I want to do this with a counter node in node red. I have tried a few things but I can’t do it. How do I make this flow

why using the counter node is an requirement? you need to measure time on top of presses.

But again, why hard way? there are ready to use nodes for this purpose

which one then, do you perhaps also have a code for this to create this flow?

For example, the Button Events node.
I suppose it’s not available in a default installation, so add it from the Hamburger menu / palette.

Full description: GitHub - bartbutenaers/node-red-contrib-button-events: A Node-RED node to send events based on button actions

Interesting how few people know that NR offers thousands of ready-to-use nodes.

you are right, there are a lot of nodes available, but you have to know where to find them. I have 2 pushbuttons in HA, but I can not fill in entities in this node. Do you also know how to solve this?

[{"id":"c9023625c8c030a2","type":"server-state-changed","z":"8e6ef4f6cbb13d83","name":"button pressed","server":"6b1110b5.183a4","version":6,"outputs":1,"exposeAsEntityConfig":"","entities":{"entity":[],"substring":[],"regex":[]},"outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":260,"y":100,"wires":[["8f16830338e63fd7"]]},{"id":"8f16830338e63fd7","type":"counter","z":"8e6ef4f6cbb13d83","name":"","init":"1","step":"1","lower":"","upper":"2","mode":"increment","outputs":"1","x":460,"y":100,"wires":[["c539080348c387c6","a8ef6c33747b4e34"]]},{"id":"c539080348c387c6","type":"switch","z":"8e6ef4f6cbb13d83","name":"","property":"count","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":770,"y":100,"wires":[["364b3afee7770924"],["fadc1c2a5162782a"]]},{"id":"a8ef6c33747b4e34","type":"delay","z":"8e6ef4f6cbb13d83","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":640,"y":160,"wires":[["65dbf7524ed41614"]]},{"id":"65dbf7524ed41614","type":"change","z":"8e6ef4f6cbb13d83","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":160,"wires":[["8f16830338e63fd7"]]},{"id":"364b3afee7770924","type":"api-call-service","z":"8e6ef4f6cbb13d83","name":"turn on","server":"6b1110b5.183a4","version":7,"debugenabled":false,"action":"","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":true,"domain":"","service":"","x":980,"y":60,"wires":[[]]},{"id":"fadc1c2a5162782a","type":"api-call-service","z":"8e6ef4f6cbb13d83","name":"turn off","server":"6b1110b5.183a4","version":7,"debugenabled":false,"action":"","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":true,"domain":"","service":"","x":970,"y":120,"wires":[[]]},{"id":"6b1110b5.183a4","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"id","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]