|
一个固件写了esphome的万能红外遥控
我想实现在万能接收到红外信号时触发ha的自动化
论坛有大佬写了mqtt方式的教程
https://bbs.hassbian.com/thread-13759-1-4.html
不过我的环境使用mqtt老是出问题
搜索到下面的代码
# Read codes from IR remote
remote_receiver:
pin:
number: GPIO22
inverted: True
mode: INPUT_PULLUP
dump: all
on_nec:
- homeassistant.service:
service: script.my_ir_remote
data:
address: "0x0FF"
data_template:
command: "{{ cmd_hex_string }}"
variables:
cmd_hex_string: !lambda |-
char buf[12];
buf[11] = 0;
sprintf(buf,"0x%X",x.command);
ESP_LOGI("main", "Sending IR remote command to hass: %s", buf);
return std::string(buf);
刷入固件后接收到红外信号时在esphome的log里可以看到下面内容
[12:52:55][I][main:105]: Sending IR remote command to hass: 0xDD22
[12:52:58][I][main:105]: Sending IR remote command to hass: 0xDD22
[12:53:01][I][main:105]: Sending IR remote command to hass: 0xDD22
[12:53:04][I][main:105]: Sending IR remote command to hass: 0xDC23
=============================================================
向 hass 发送 IR 遥控命令:0xDC23
看翻译是信号传到了ha 不知道是不是这么理解
可是我在ha里找不到相关的服务
大佬们指点下是怎么回事
或者有其他方式的也请大佬一起发出来
感激不尽
|
|