How to use a Sensor Value as part of a string in a command line switch

Currently I am using Curl as command_line Switches to control parts of my IP cameras functionality like so >

switch:
 - platform: command_line
   switches:
     ipcamera_ir:
        command_on: 'curl -k "http://username:[email protected]/param.cgi?cmd=setinfrared&-infraredstat=open"'
        command_off: 'curl -k "http://username:[email protected]/param.cgi?cmd=setinfrared&-infraredstat=close"'

This Works no problem, My next desire is to set the On Screen Name for the camera to the value of a sensor

switch:
 - platform: command_line
   switches:
     ipcamera_osd_control:
        command_on: 'curl -k "http://username:[email protected]/param.cgi?cmd=setoverlayattr&-name=**VARIABLE**"'`

Basically I want to use the sensor data from my weather station where VARIABLE is in the string with the goal of changing the generic IP cameras name , just add an automation to toggle this switch every 15 minutes and I could inject the weather data directly into the cameras RTSP Stream.

Is this possible?

According to the documentation, command_on only accepts a string, not a template. That means you cannot use a template to dynamically change the value of command_on.

image

Hmm, could I do this some other way?
This seams like a similar setup but i don’t understand how it works.

I suggest you create a Template Switch that calls Shell Commands which support templates therefore can be dynamic.