Dynamically call Get Entities based off injected payload value

I’m looking for a way to dynamically send data to the “Get Entities” node depending on what is injected into the node.

For Example:
if “GoodNight” is sent I want it to pull a listing of every single light that is on.
When “30M” is sent, I want to pull any light that is on EXCEPT my office lights.
When “All_Lights” is sent I want it to pull all lights that were on except exterior or decorative lights.
etc.

I can do this with multiple “Get Entities” nodes but I’m trying to slim it down some. I’d like to have one “Get Entities” node that behaves differently depending on what data is injected into it.

The below example works as far as injecting something into “Get Entities” however, I’m not sure how to make this dynamic based off the initial payload - I don’t believe you can do If/Else statements with expressions - can you?

I feel like a function node would be better suited but I wasn’t able to figure it out.

[{"id":"5ad07fd4696667bb","type":"change","z":"310a01bc9a62ebe9","name":"RegEx as Payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t   \"rules\": [\t       {\t           \"property\": \"entity_id\",\t           \"logic\": \"is\",\t           \"valueType\": \"re\",\t           \"value\": \"^^light.(?!browser_)\"\t       },\t       {\t           \"property\": \"state\",\t           \"logic\": \"is\",\t           \"valueType\": \"str\",\t           \"value\": \"on\"\t       }\t   ]\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":670,"wires":[["1ec8e9b61d074d94"]]},{"id":"76a3cae6699acb5c","type":"debug","z":"310a01bc9a62ebe9","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":670,"wires":[]},{"id":"b36fa1adc36de153","type":"inject","z":"310a01bc9a62ebe9","name":"Payload A","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"GoodNight","payloadType":"str","x":220,"y":630,"wires":[["5ad07fd4696667bb"]]},{"id":"d8c89c1fbe92c810","type":"inject","z":"310a01bc9a62ebe9","name":"Payload B","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"30M","payloadType":"str","x":220,"y":670,"wires":[["5ad07fd4696667bb"]]},{"id":"c34d674695ec71fe","type":"inject","z":"310a01bc9a62ebe9","name":"Payload C","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"All_Lights","payloadType":"str","x":220,"y":710,"wires":[["5ad07fd4696667bb"]]},{"id":"1ec8e9b61d074d94","type":"ha-get-entities","z":"310a01bc9a62ebe9","name":"Entities","server":"df9a019b.0518b","version":0,"rules":[],"output_type":"array","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":"10","x":610,"y":670,"wires":[["76a3cae6699acb5c"]]},{"id":"df9a019b.0518b","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":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

I know this is not what you are after but this would simplify things a little bit

[{"id":"b36fa1adc36de153","type":"inject","z":"86eb055c.ed8918","name":"Payload A","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"GoodNight","payloadType":"str","x":160,"y":1240,"wires":[["f054fdd9d699498d"]]},{"id":"d8c89c1fbe92c810","type":"inject","z":"86eb055c.ed8918","name":"Payload B","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"30M","payloadType":"str","x":160,"y":1280,"wires":[["f054fdd9d699498d"]]},{"id":"c34d674695ec71fe","type":"inject","z":"86eb055c.ed8918","name":"Payload C","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"All_Lights","payloadType":"str","x":160,"y":1320,"wires":[["f054fdd9d699498d"]]},{"id":"1ec8e9b61d074d94","type":"ha-get-entities","z":"86eb055c.ed8918","name":"Entities","server":"df9a019b.0518b","version":0,"rules":[],"output_type":"array","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":"10","x":580,"y":1280,"wires":[["76a3cae6699acb5c"]]},{"id":"f054fdd9d699498d","type":"change","z":"86eb055c.ed8918","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t   \"rules\":[\t       {\t           \"property\":\"entity_id\",\t           \"logic\":\"starts_with\",\t           \"valueType\":\"str\",\t           \"value\":\"light.\"\t       },\t       {\t           \"property\":\"entity_id\",\t           \"logic\":\"is_not\",\t           \"valueType\":\"str\",\t           \"value\": payload = \"30M\" ? \"OFFICE LIGHTS\" : payload = \"All_Lights\" ? \"EXTERIOR OR DECORATIVE LIGHTS\" : \" \"\t       },\t       {\t           \"property\":\"state\",\t           \"logic\":\"is\",\t           \"valueType\":\"str\",\t           \"value\":\"on\"\t       }\t   ]\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":1280,"wires":[["1ec8e9b61d074d94"]]},{"id":"df9a019b.0518b","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":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

Thanks for the help!
I may be able to work with this!