I’m trying to pass infrared-commands to a user defined service on an esp32.
In general the service works, when I define static values for “address” and “command”.
api:
services:
- service: send_ir
then:
- remote_transmitter.transmit_nec:
address: 0x4040
command: 0x807F
But When I try to pass the values as parameters, there is always a problem with type conversion:
When I pass them as a string
api:
services:
- service: send_ir
variables:
address_str: string
command_str: string
then:
- remote_transmitter.transmit_nec:
address: !lambda 'return address_str;'
command: !lambda 'return command_str;'
during compile-time it’s this error:
/config/esphome/_common/component_remote_transmitter.yaml: In lambda function:
/config/esphome/_common/component_remote_transmitter.yaml:20:14: error: cannot convert 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'uint16_t {aka short unsigned int}' in return
address: !lambda 'return address_str;'
When I pass them as int
address_str: int
command_str: int
and enter them as int in dev-tools (0x4040 → 16448; 0x807F → 32895) nothing happens.
I guess, I would have to define and enter them as string and do some kind of conversion in the lambda, but how?
Is this even possible?