Reading switch values in function blocks

Hi guys.

I have a need to use the state of a dummy switch from home assistant in a node red function block. I normally use a poll state node and set a global variable then read that value in the function block. This works fine but is there a way that I can simply call something from the function block or is what I am doing right?

Look in the info panel of the server config node for an example.

here’s another example

Thank you heaps