Sensor State in switch

I have a sensor

    - platform: template
      sensors:
        mmjokesname:
          value_template: "module_11_MMM-icanhazdadjoke"

and a switch

    mmjokestest:
      command_off: 'curl "http://192.168.0.66:8080/remote?action=SHOW&module={{states.sensor.mmjokesname.state}}"'
      command_on: 'curl "http://192.168.0.66:8080/remote?action=HIDE&module={{states.sensor.mmjokesname.state}}"'

I want to reference the sensor value in the switch because the value can change if I add something to my Magic Mirror. I have multiple items like this and thought this would the the easiest way to accomplish this. But it does not work, it just sends a command like the above and does not replace the {{…}} with the actual sensor state.

Is this the best way to do this? What am I doing wrong?

What component is that switch?

Nevermind, its a comand line switch.

You can’t have a template in that location. command_on and command_off do not take templating of any kind. {{}} is templating.

Some while ago, this group helped me with using a second switch to combine the function “switch.master_bedroom_light” and the state of “binary_sensor.master_light_status”:

  - platform: template
    switches:
      master_room_lights:
        value_template: "{{ is_state('binary_sensor.master_light_status', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.master_bedroom_light
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.master_bedroom_light