Using a sensor value as a command for remote service?

Hi everyone,

I have a Broadlink RM4 Pro and I want to use the values of an input number as the command for the remote.send_command. But it’s not working. The sensor ‘sensor.airco_waarde_instellen’ outputs the value ‘21’ on the template screen. When I fill in ‘21’ at the ‘command:’ line, the action works. But when I use “{{ states(‘sensor.airco_waarde_instellen’) }}”, the action doesn’t work.

Any clues? Thank you in advance. :slight_smile:

  action:
  - service: remote.send_command
    data_template:
      device: airco
      command: "{{ states('sensor.airco_waarde_instellen') }}"
    target:
      entity_id: remote.infrarood
  mode: single

Try this:

action:
  - service: remote.send_command
    data_template:
      device: airco
      command: "{{ states('sensor.airco_waarde_instellen') | int(0) }}"
    target:
      entity_id: remote.infrarood
  mode: single

This is basically converting the result of that sensor from a string '21' to a number 21.
If that could have decimals, then use float(0) instead.