Gate control by HA entity node

Hello, I want to control this function node through an entity node switched by Home Assistant. How do I configure the entity switch for an output with the msg.topic = "Gate" and boolean value true and false?

function node

if (msg.topic === "gate") {
context.pass = (msg.payload === true) ? true : false;
return null; // exit out early as it's just the control
}
if (context.pass) {
return msg; // if enabled pass msg
}
return null; // or drop it

Probably easier than making a function node act as a gate, have you considered node-red-contrib-simple-gate?

[{"id":"125062fd02dd4e5e","type":"gate","z":"a19719d3e57004eb","name":"","controlTopic":"gate","defaultState":"closed","openCmd":"true","closeCmd":"false","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"memory","x":490,"y":140,"wires":[["fc232abf7483ba90"]]},{"id":"fc232abf7483ba90","type":"debug","z":"a19719d3e57004eb","name":"debug 232","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":140,"wires":[]},{"id":"0e9939cfc16143e0","type":"inject","z":"a19719d3e57004eb","name":"Normal input","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":310,"y":200,"wires":[["125062fd02dd4e5e"]]},{"id":"023fc48a3c3c1bbd","type":"group","z":"a19719d3e57004eb","name":"Gate control - topic \"gate\" payload true/false","style":{"label":true},"nodes":["b6011414c26fe2b2","08ef1bdaaaf18432"],"x":114,"y":39,"w":282,"h":122},{"id":"b6011414c26fe2b2","type":"inject","z":"a19719d3e57004eb","g":"023fc48a3c3c1bbd","name":"Open the gate","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"gate","payload":"true","payloadType":"bool","x":230,"y":80,"wires":[["125062fd02dd4e5e"]]},{"id":"08ef1bdaaaf18432","type":"inject","z":"a19719d3e57004eb","g":"023fc48a3c3c1bbd","name":"Close the gate","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"gate","payload":"false","payloadType":"bool","x":230,"y":120,"wires":[["125062fd02dd4e5e"]]}]

If the outputs from your HA node are not topic:"gate", payload:true/false, use change nodes to tweek them or adjust the gate settings.

thx - This looks like a way to solve my "problem"...

...but a need a switch in home assistant and I prefer to reduce additionaly installed nodes.

Now I set the msg.topic by another change node. Not realy elegant but it works.
If anybody could make my way nicer I will be thankful.