Data Template for Remote Transmitter

Is there a way we could specify the Data_template for the Remote Transmitter component?
What I want to achieve is a dynamic input of the raw codes to be passed through the remote transmitter. Currently I see that the “code” is hard-coded. I was trying to check if there is data_template option to pass “code” dynamically

Working Version

  - platform: template
    name: daikinpoweron
    turn_on_action: 
       - remote_transmitter.transmit_raw:
           code: [414,-494,368,-496,368,-496,370,-494,368,-498,368,-25192,3540,-1678,450,-1282,424,-442,396,-468,424,-440,420,-1284,398,-466,424,-442,422,-442,422,-442,422,-1284,422,-442,424,-1282,424,-1282,422,-444,398,-1308,424,-1282,422,-1284,398,-1308,420,-1284,424,-442,422,-442,422,-1284,424,-440,424,-440,398,-466,424,-442,422,-442,424,-440,400,-464,424,-442,422,-442,424,-442,424,-1282,422,-446,420,-1284,424,-440,424,-442,422,-442,422,-1282,398,-1308,424,-442,424,-440,422,-444,424,-442,422,-442,422,-444,422,-440,400,-464,424,-442,398,-466,424,-442,422,-442,424,-442,420,-444,424,-442,422,-440,424,-1284,424,-1280,424,-1284,424,-440,422,-1284,424,-442,422,-1282,422,-1282,422,-34626,3486,-1758,368,-1340,366,-496,370,-496,368,-496,370,-1336,368,-496,368,-496,370,-496,366,-496,368,-1338,370,-496,366,-1338,366,-1340,368,-496,368,-1338,366,-1338,368,-1336,370,-1338,370,-1336,368,-496,368,-496,370,-1338,368,-496,366,-498,370,-496,368,-496,370,-496,366,-498,368,-496,368,-496,370,-496,368,-496,368,-498,368,-1338,368,-496,368,-498,368,-496,366,-496,370,-1336,368,-496,368,-496,370,-494,368,-496,370,-496,368,-496,368,-496,368,-496,366,-498,370,-496,368,-496,370,-496,366,-496,368,-496,368,-496,370,-496,368,-496,366,-496,370,-496,366,-1338,366,-498,368,-1336,368,-496,368,-1336,370,-496,368,-34680,3534,-1708,370,-1338,416,-448,416,-448,418,-448,366,-1338,418,-446,368,-496,368,-496,368,-496,366,-1340,366,-498,368,-1336,418,-1288,366,-496,418,-1290,416,-1288,416,-1290,368,-1338,418,-1288,418,-448,368,-496,418,-1288,368,-498,416,-452,364,-496,418,-446,366,-498,368,-498,366,-496,370,-496,414,-448,370,-494,368,-496,418,-448,418,-446,368,-496,418,-448,368,-496,368,-496,366,-498,420,-1286,370,-496,366,-498,418,-1286,418,-448,368,-1338,416,-1288,420,-446,416,-450,416,-1246,458,-448,366,-496,418,-1286,370,-1338,418,-446,368,-496,422,-446,366,-496,418,-448,416,-448,370,-496,368,-496,366,-498,418,-446,412,-452,418,-448,366,-498,418,-448,368,-1338,368,-1338,366,-1338,370,-496,416,-448,418,-446,368,-496,416,-448,418,-450,366,-496,420,-448,414,-448,420,-446,418,-446,368,-498,368,-498,366,-496,370,-496,368,-496,370,-496,418,-448,420,-1286,418,-1288,370,-496,366,-498,370,-496,414,-448,418,-448,368,-496,370,-496,368,-496,366,-496,370,-496,366,-1340,414,-1290,370,-496,416,-448,418,-446,368,-496,368,-496,368,-496,368,-496,368,-498,416,-446,418,-448,368,-496,366,-498,416,-448,416,-446,370,-498,366,-502,414,-446,368,-1338,368,-496,368,-498,366,-498,416,-448,416,-448,366,-1340,368,-1336,370,-496,366,-498,418,-448,366,-498,418,-446,418,-446,368,-496,370,-1336,368,-496,418,-446,368,-496,366,-498,368,-498,414,-448,418,-448,366,-500,366,-496,368,-498,366,-1338,368,-498,368,-496,418,-448,368,-1338,366,-1338,366]
           carrier_frequency: 38kHz

Desired option

  - platform: template
    name: daikinpoweron
    turn_on_action: 
      data_template:
       - remote_transmitter.transmit_raw:
           code: {{ variable }}
           carrier_frequency: 38kHz

The variable option could be fed from anywhere, either through the Remote receiving component or through a MQTT from other sources

well. so far I have proceed something like this to test whether the codes actually work.

globals:
   - id: remote_code
     type: int[2]
     restore_value: no
     initial_value: "{111, -111}"

  - platform: template
    name: daikinfanmode
    turn_on_action: 
       - remote_transmitter.transmit_raw:
           code: !lambda |-
              std::vector<int> vec;
              int *i = remote_code->value();
              for (int j=0; j <2; j++)
              {
                ESP_LOGD("Test", "Print %d", *(i+j));
                vec.push_back(*(i+j));
              }
              return id (vec);
           carrier_frequency: 38kHz

However, I cannot see that exact code being received (I have used another ESP with Remote Receiver component ). Why is it that the “code” that I hard coded in Remote Transmitter not received the same as that of the Remote Receiver. I tried with various hard coding numbers, but the receiver never shows the exact value. I have tested this receiver with other “proper” remotes and they seem to work correctly, indicating that the remote received is working properly, so something must be wrong here with the code. Can help check and possibly point out?

[15:13:01][D][switch:021]: ‘daikinfanmode’ Turning ON.
[15:13:01][D][Test:3261]: Print 111
[15:13:01][D][Test:3261]: Print -111
[15:13:01][D][remote_transmitter:066]: Sending remote code…
[15:13:01][D][remote.raw:041]: Received Raw: 126

1 Like