text_sensor:
- platform: mqtt_subscribe
name: "nec to send"
id: sendnec
topic: epshome32/sendnec
on_value:
then:
remote_transmitter.transmit_nec:
address: !lambda |-
unsigned int addr;
unsigned int command;
sscanf(x.c_str(),"%x:%x",&addr,&command);
ESP_LOGI("main", "NEC:0x%x:0x%x", addr,command);
return addr;
command: !lambda |-
unsigned int addr;
unsigned int command;
sscanf(x.c_str(),"%x:%x",&addr,&command);
return command;
- platform: mqtt_subscribe
name: "pana to send"
id: sendpan
topic: epshome32/sendpan
on_value:
then:
remote_transmitter.transmit_panasonic:
address: !lambda |-
unsigned int addr;
unsigned long command;
sscanf(x.c_str(),"%x:%x",&addr,&command);
ESP_LOGI("main", "PANA:0x%x:0x%x", addr,command);
return addr;
command: !lambda |-
unsigned int addr;
unsigned long command;
sscanf(x.c_str(),"%x:%x",&addr,&command);
return command;
- platform: mqtt_subscribe
name: "sam to send"
id: sendsam
topic: epshome32/sendsam
on_value:
then:
remote_transmitter.transmit_samsung:
data: !lambda |-
unsigned long data;
sscanf(x.c_str(),"%x",&data);
ESP_LOGI("main", "SAM:0x%x", data);
return data;
remote_transmitter:
pin: GPIO21
carrier_duty_percent: 50%
id: remote_send
remote_receiver:
pin:
number: GPIO23
inverted: True
# mode: INPUT_PULLUP
dump: all
on_nec:
then:
- mqtt.publish:
topic: esphome32/senso/ir
payload: !lambda |-
char temp[20];
sprintf(temp, "%d:%d", x.address, x.command);
ESP_LOGI("main", "rcv nec: %s", temp);
return temp;
on_panasonic:
then:
- mqtt.publish:
topic: esphome32/senso/ir
payload: !lambda |-
char temp[20];
sprintf(temp, "%d:%d", x.address, x.command);
ESP_LOGI("main", "rcv pan: %s", temp);
return temp;
on_sony:
then:
- mqtt.publish:
topic: esphome32/senso/ir
payload: !lambda |-
char temp[20];
sprintf(temp, "%d:%d", x.data, x.nbits);
ESP_LOGI("main", "rcv sony: %s", temp);
return temp;
on_jvc:
then:
- mqtt.publish:
topic: esphome32/senso/ir
payload: !lambda |-
char temp[20];
sprintf(temp, "%d", x.data);
ESP_LOGI("main", "rcv jvc: %s", temp);
return temp;
on_rc5:
then:
- mqtt.publish:
topic: esphome32/senso/ir
payload: !lambda |-
char temp[20];
sprintf(temp, "%d:%d", x.address, x.command);
ESP_LOGI("main", "rcv rc5: %s", temp);
return temp;
硬件链接可以参考这个