This in a template node gives following in debug:
{"_msgid":"7f95d0f1.a7512","topic":"","payload":"{ { state_attr('sensor.hue_motion_sensor_1_light_level', 'lightlevel') } };","template":"{ { state_attr('sensor.hue_motion_sensor_1_light_level', 'lightlevel') } };\n"}
With nodes as following:
[{"id":"d4513e27.2e925","type":"inject","z":"b5a4f9b1.de8f78","name":"Test","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":1720,"wires":[["76abf4e6.13464c"]]},{"id":"76abf4e6.13464c","type":"api-render-template","z":"b5a4f9b1.de8f78","name":"Kitchen Lux","server":"c07167d6.bc6238","template":"{ { state_attr('sensor.hue_motion_sensor_1_light_level', 'lightlevel') } };\n","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":350,"y":1720,"wires":[["ff943440.cd9d28"]]},{"id":"ff943440.cd9d28","type":"debug","z":"b5a4f9b1.de8f78","name":"Test","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":530,"y":1720,"wires":[]},{"id":"c07167d6.bc6238","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]
And when trying with
{ { states.sensor.hue_motion_sensor_1_light_level.attributes.lightlevel } };
Gives following
{"_msgid":"4bb44c23.7cfb34","topic":"","payload":"{ { states.sensor.hue_motion_sensor_1_light_level.attributes.lightlevel } };","template":"{ { states.sensor.hue_motion_sensor_1_light_level.attributes.lightlevel } };"}
By using
[{"id":"844971a0.a399f","type":"debug","z":"b5a4f9b1.de8f78","name":"Test","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":510,"y":1840,"wires":[]},{"id":"a541eb94.72c1d8","type":"api-render-template","z":"b5a4f9b1.de8f78","name":"Kitchen Lux","server":"c07167d6.bc6238","template":"{ { states.sensor.hue_motion_sensor_1_light_level.attributes.lightlevel } };","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":330,"y":1840,"wires":[["844971a0.a399f"]]},{"id":"db8a21f5.29ccb","type":"inject","z":"b5a4f9b1.de8f78","name":"Test","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1840,"wires":[["a541eb94.72c1d8"]]},{"id":"c07167d6.bc6238","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]