Currently “command_line” sensors have a template support for a “command” option.
There are some issues regarding using templates for the “command” option (thread in the Community, issue on GitHub) making using templates differently from conventional template sensors.
Let’s assume that one day the issue is solved & templates may be used for “command_line” sensors as they are for conventional template sensors.
Then I propose to add a support for the “this
” variable.
With this “this
” support we may do smth like:
sensor:
- platform: command_line
name: get_parameter_a123
command: >-
{% set CMD_SENSOR= this.entity_id -%}
... extract "a123" string from CMD_SENSOR ...
... compose a sensor's name depending on that "a123" string ...
... then call a command using settings for this "a123" object:
curl {{ state_attr("sensor.a123_device_settings","command") }}
i.e. name of the “command_line” sensor is used to compose a command.