Hello
I’m a bit unsure of what you mean, but in the automations in home assistant, the code "{{ (states('sensor.limited_power') | int(0) | abs)}}" works good.
The original value is - so that’s why I include abs in the code.
Home Assistant uses templates in YAML and in automations.
Templates, things in {{ }} are executed using the Jinja templating engine.
Node-RED is not Home Assistant. When you are in Node-RED, some nodes can use Jinja templating in the {} JSON option, but this does not work well when trying to construct the complex data object for calling a service.
When you are in Node-RED, and you are using J: you are using JSONata.
JSONata is a different language. It is not templating. It does not work like templating.
In Node-RED, in JSONata, the code {{ (states('sensor.limited_power') | int(0) | abs)}} will generate an error.
The correct (assuming I have typed it correctly) JSONata code you want is
This is much the same as if I go into a coffee shop in my home town in Bristol (Bristle me babber) and ask “Kan jag ha en stor latte-lampa att gå?” - there would be a blank look as the processing engine does not speak that language.
Some HA services accept jinja2 templates but it varies by service. I recommend letting NR handle the dynamic values in a service call.
By default, NR tries to parse the data field using JSONata which can conflict with the structure of jinja2 templates. If you switch the data field type to “JSON” and check “Use alternate template tags for the data field” what you have should work.