Its actually simple… like everything when you know
[{"id":"5a33b7b5.76fc8","type":"template","z":"5be0e0fd.37e1f","name":"Generate HA template","field":"template","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{=<% %>=}}\n{{state_attr(\"<% topic %>\",'brightness')|int}}","output":"str","x":1120,"y":160,"wires":[["3d1ddd94.82c6f2"]]},{"id":"3d1ddd94.82c6f2","type":"api-render-template","z":"5be0e0fd.37e1f","name":"Get last brightness","server":"70d02634.d2ffd","template":"","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":1130,"y":220,"wires":[["4ce89664.c5a388"]]},{"id":"70d02634.d2ffd","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]