本帖最后由 gujiys 于 2019-6-24 23:48 编辑
我是搬运工, 我是搬运工, 我是搬运工! 这是Huex大佬的杰作,我只是个抄作业的。
一直以来,红外遥控被吐槽,无论是你买的博联还是其它红外,多数只能单向,接收器也只是拿来学习,市面唯一知道的也就是小米的空调可以做到接收发送同步,但是今天IRremoteMQTT也做到了!虽然目前支持不是很多,但实际上这是一项复杂的工程,没有各位的参与是不可能完成的!
如何确定空调是否支持?首先,你必须准备好一块ESP8266,mini D1是个好选择,一枚红外接收管,最好的办法就是借拆一枚,分别接好线,将OUT脚接入到esp8266 gpio14 [D5] VCC接5V供电Gnd接Gnd。将以下bin文件刷入,刷入完成后,使用TTL串口工具查看串口信息,(可以用putty,)
IRrecvDumpV2.ino.generic (1).zip
(235.01 KB, 下载次数: 175)
接下来是你展示你遥控器的时候了,按下你的遥控器,TTL显示类似如下信息:
Timestamp : 006910.551
Encoding : PANASONIC_AC
Code : 0220E004000000060220E00400313680A100000660000085000079 (216 bits)
Mesg Desc.: Model: 4 (JKE), Power: On, Mode: 3 (COOL), Temp: 27C, Fan: 7 (AUTO), Swing (Vertical): 1 (Full Up), Quiet: Off, Powerful: Off, Clock: 0:00, On Timer: Off, Off Timer: Off
Library : v2.6.0
Raw Timing[439]:
+ 3548, - 1702, + 480, - 398, + 426, - 1304, + 508, - 400,
+ 478, - 404, + 480, - 400, + 480, - 404, + 480, - 400,
+ 428, - 462, + 428, - 452, + 428, - 454, + 428, - 454,
+ 428, - 454, + 428, - 454, + 428, - 1302, + 428, - 454,
+ 428, - 462, + 428, - 452, + 426, - 454, + 426, - 454,
+ 428, - 454, + 428, - 454, + 426, - 1306, + 478, - 1252,
+ 428, - 1312, + 480, - 402, + 428, - 454, + 426, - 1304,
+ 428, - 454, + 428, - 454, + 426, - 454, + 428, - 454,
+ 426, - 462, + 428, - 452, + 426, - 454, + 480, - 402,
+ 428, - 456, + 428, - 454, + 426, - 454, + 428, - 456,
+ 426, - 464, + 428, - 452, + 428, - 454, + 428, - 454,
+ 426, - 456, + 426, - 454, + 428, - 454, + 426, - 456,
+ 452, - 438, + 454, - 448, + 428, - 454, + 426, - 456,
+ 428, - 456, + 426, - 454, + 426, - 454, + 428, - 454,
+ 428, - 464, + 426, - 454, + 426, - 1304, + 428, - 1302,
+ 426, - 456, + 426, - 454, + 428, - 454, + 428, - 454,
+ 428, - 462, + 436, - 10992, + 3548, - 1700, + 428, - 452,
+ 478, - 1252, + 428, - 454, + 480, - 402, + 428, - 454,
+ 480, - 402, + 480, - 402, + 480, - 410, + 428, - 450,
+ 480, - 402, + 430, - 452, + 426, - 456, + 480, - 402,
+ 478, - 1250, + 428, - 454, + 428, - 464, + 478, - 400,
+ 480, - 402, + 428, - 454, + 480, - 402, + 428, - 454,
+ 480, - 1250, + 480, - 1250, + 428, - 1310, + 480, - 400,
+ 480, - 400, + 428, - 1304, + 478, - 404, + 480, - 402,
+ 426, - 456, + 478, - 402, + 480, - 410, + 482, - 398,
+ 480, - 402, + 428, - 454, + 480, - 402, + 428, - 454,
+ 478, - 404, + 426, - 456, + 478, - 410, + 478, - 1250,
+ 426, - 454, + 428, - 456, + 426, - 454, + 480, - 1250,
+ 428, - 1304, + 478, - 404, + 426, - 462, + 482, - 398,
+ 428, - 1302, + 428, - 1304, + 426, - 456, + 478, - 1252,
+ 428, - 1302, + 426, - 454, + 428, - 462, + 428, - 452,
+ 428, - 454, + 478, - 404, + 478, - 404, + 426, - 454,
+ 478, - 402, + 480, - 402, + 428, - 1312, + 434, - 1292,
+ 480, - 402, + 426, - 454, + 480, - 402, + 478, - 402,
+ 482, - 1250, + 478, - 404, + 480, - 1258, + 480, - 400,
+ 480, - 402, + 478, - 406, + 428, - 454, + 482, - 400,
+ 482, - 400, + 480, - 402, + 482, - 408, + 480, - 400,
+ 480, - 400, + 480, - 400, + 480, - 402, + 482, - 400,
+ 480, - 402, + 480, - 402, + 482, - 408, + 482, - 396,
+ 482, - 1250, + 482, - 1250, + 480, - 402, + 482, - 400,
+ 480, - 402, + 480, - 402, + 480, - 412, + 480, - 398,
+ 480, - 400, + 480, - 400, + 482, - 400, + 482, - 400,
+ 480, - 1250, + 482, - 1250, + 480, - 408, + 480, - 400,
+ 478, - 402, + 482, - 400, + 452, - 430, + 480, - 400,
+ 480, - 402, + 480, - 402, + 480, - 410, + 482, - 398,
+ 480, - 402, + 480, - 402, + 428, - 456, + 428, - 452,
+ 482, - 402, + 428, - 454, + 482, - 408, + 482, - 1244,
+ 482, - 400, + 480, - 1250, + 508, - 376, + 480, - 400,
+ 482, - 400, + 480, - 400, + 428, - 1310, + 482, - 398,
+ 428, - 452, + 482, - 400, + 482, - 402, + 482, - 400,
+ 482, - 400, + 482, - 400, + 480, - 410, + 480, - 398,
+ 480, - 400, + 480, - 400, + 482, - 400, + 482, - 400,
+ 482, - 400, + 482, - 402, + 480, - 416, + 480, - 1246,
+ 484, - 400, + 480, - 400, + 480, - 1250, + 482, - 1248,
+ 480, - 1250, + 482, - 1250, + 482, - 408, + 482
uint16_t rawData[439] = {3548, 1702, 480, 398, 426, 1304, 508, 400, 478, 404, 480, 400, 480, 404, 480, 400, 428, 462, 428, 452, 428, 454, 428, 454, 428, 454, 428, 454, 428, 1302, 428, 454, 428, 462, 428, 452, 426, 454, 426, 454, 428, 454, 428, 454, 426, 1306, 478, 1252, 428, 1312, 480, 402, 428, 454, 426, 1304, 428, 454, 428, 454, 426, 454, 428, 454, 426, 462, 428, 452, 426, 454, 480, 402, 428, 456, 428, 454, 426, 454, 428, 456, 426, 464, 428, 452, 428, 454, 428, 454, 426, 456, 426, 454, 428, 454, 426, 456, 452, 438, 454, 448, 428, 454, 426, 456, 428, 456, 426, 454, 426, 454, 428, 454, 428, 464, 426, 454, 426, 1304, 428, 1302, 426, 456, 426, 454, 428, 454, 428, 454, 428, 462, 436, 10992, 3548, 1700, 428, 452, 478, 1252, 428, 454, 480, 402, 428, 454, 480, 402, 480, 402, 480, 410, 428, 450, 480, 402, 430, 452, 426, 456, 480, 402, 478, 1250, 428, 454, 428, 464, 478, 400, 480, 402, 428, 454, 480, 402, 428, 454, 480, 1250, 480, 1250, 428, 1310, 480, 400, 480, 400, 428, 1304, 478, 404, 480, 402, 426, 456, 478, 402, 480, 410, 482, 398, 480, 402, 428, 454, 480, 402, 428, 454, 478, 404, 426, 456, 478, 410, 478, 1250, 426, 454, 428, 456, 426, 454, 480, 1250, 428, 1304, 478, 404, 426, 462, 482, 398, 428, 1302, 428, 1304, 426, 456, 478, 1252, 428, 1302, 426, 454, 428, 462, 428, 452, 428, 454, 478, 404, 478, 404, 426, 454, 478, 402, 480, 402, 428, 1312, 434, 1292, 480, 402, 426, 454, 480, 402, 478, 402, 482, 1250, 478, 404, 480, 1258, 480, 400, 480, 402, 478, 406, 428, 454, 482, 400, 482, 400, 480, 402, 482, 408, 480, 400, 480, 400, 480, 400, 480, 402, 482, 400, 480, 402, 480, 402, 482, 408, 482, 396, 482, 1250, 482, 1250, 480, 402, 482, 400, 480, 402, 480, 402, 480, 412, 480, 398, 480, 400, 480, 400, 482, 400, 482, 400, 480, 1250, 482, 1250, 480, 408, 480, 400, 478, 402, 482, 400, 452, 430, 480, 400, 480, 402, 480, 402, 480, 410, 482, 398, 480, 402, 480, 402, 428, 456, 428, 452, 482, 402, 428, 454, 482, 408, 482, 1244, 482, 400, 480, 1250, 508, 376, 480, 400, 482, 400, 480, 400, 428, 1310, 482, 398, 428, 452, 482, 400, 482, 402, 482, 400, 482, 400, 482, 400, 480, 410, 480, 398, 480, 400, 480, 400, 482, 400, 482, 400, 482, 400, 482, 402, 480, 416, 480, 1246, 484, 400, 480, 400, 480, 1250, 482, 1248, 480, 1250, 482, 1250, 482, 408, 482}; // PANASONIC_AC
uint8_t state[27] = {0x02, 0x20, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x06, 0x02, 0x20, 0xE0, 0x04, 0x00, 0x31, 0x36, 0x80, 0xA1, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x85, 0x00, 0x00, 0x79};
在以上信息中,我们可以看到decode Mesg Desc.: 信息,展示了目前遥控的代码和结构,如果你的遥控器按下后生成类似消息 ,那么恭喜你,你的空调代码无损支持,并且使用此源码将可以使用MQTT来同步显示和操作空调,所有遥控操作将同步到MQTT消息中。 然而如果你的是这样的:
Timestamp : 007100.353
Encoding : UNKNOWN
Code : 9BBD013B (106 bits)
Library : v2.6.0
Raw Timing[211]:
+ 9010, - 4648, + 456, - 1854, + 428, - 1854, + 430, - 698,
+ 402, - 648, + 454, - 700, + 426, - 674, + 426, - 1780,
+ 456, - 1798, + 456, - 730, + 402, - 644, + 426, - 730,
+ 220, - 2010, + 296, - 776, + 430, - 700, + 374, - 728,
+ 404, - 1852, + 430, - 620, + 454, - 648, + 454, - 674,
+ 456, - 618, + 458, - 672, + 428, - 1828, + 430, - 1804,
+ 452, - 1828, + 428, - 700, + 324, - 750, + 428, - 652,
+ 454, - 694, + 402, - 700, + 418, - 684, + 430, - 672,
+ 430, - 648, + 426, - 648, + 452, - 766, + 364, - 726,
+ 296, - 698, + 456, - 700, + 350, - 1878, + 432, - 674,
+ 380, - 1872, + 430, - 644, + 454, - 702, + 402, - 674,
+ 454, - 672, + 406, - 644, + 482, - 646, + 428, - 700,
+ 404, - 698, + 402, - 644, + 456, - 754, + 348, - 672,
+ 458, - 616, + 458, - 670, + 404, - 726, + 402, - 726,
+ 376, - 1828, + 430, - 698, + 404, - 750, + 380, - 616,
+ 432, - 724, + 400, - 702, + 426, - 674, + 406, - 644,
+ 456, - 776, + 402, - 726, + 402, - 674, + 376, - 674,
+ 454, - 724, + 378, - 700, + 378, - 766, + 360, - 670,
+ 432, - 670, + 430, - 674, + 406, - 692, + 432, - 674,
+ 452, - 726, + 326, - 724, + 428, - 1776, + 478, - 678,
+ 402, - 698, + 428, - 620, + 458, - 724, + 376, - 674,
+ 376, - 698, + 456, - 698, + 376, - 728, + 402, - 700,
+ 378, - 790, + 336, - 644, + 454, - 1828, + 430, - 1802,
+ 454, - 674, + 454, - 672, + 402, - 674, + 428, - 700,
+ 424, - 676, + 404, - 1800, + 430, - 698, + 430, - 672,
+ 458, - 644, + 428, - 1856, + 402, - 1802, + 458, - 1800,
+ 456, - 644, + 456
uint16_t rawData[211] = {9010, 4648, 456, 1854, 428, 1854, 430, 698, 402, 648, 454, 700, 426, 674, 426, 1780, 456, 1798, 456, 730, 402, 644, 426, 730, 220, 2010, 296, 776, 430, 700, 374, 728, 404, 1852, 430, 620, 454, 648, 454, 674, 456, 618, 458, 672, 428, 1828, 430, 1804, 452, 1828, 428, 700, 324, 750, 428, 652, 454, 694, 402, 700, 418, 684, 430, 672, 430, 648, 426, 648, 452, 766, 364, 726, 296, 698, 456, 700, 350, 1878, 432, 674, 380, 1872, 430, 644, 454, 702, 402, 674, 454, 672, 406, 644, 482, 646, 428, 700, 404, 698, 402, 644, 456, 754, 348, 672, 458, 616, 458, 670, 404, 726, 402, 726, 376, 1828, 430, 698, 404, 750, 380, 616, 432, 724, 400, 702, 426, 674, 406, 644, 456, 776, 402, 726, 402, 674, 376, 674, 454, 724, 378, 700, 378, 766, 360, 670, 432, 670, 430, 674, 406, 692, 432, 674, 452, 726, 326, 724, 428, 1776, 478, 678, 402, 698, 428, 620, 458, 724, 376, 674, 376, 698, 456, 698, 376, 728, 402, 700, 378, 790, 336, 644, 454, 1828, 430, 1802, 454, 674, 454, 672, 402, 674, 428, 700, 424, 676, 404, 1800, 430, 698, 430, 672, 458, 644, 428, 1856, 402, 1802, 458, 1800, 456, 644, 456}; // UNKNOWN 9BBD013B
很遗憾,两种情况,一种库不包含这种空调代码,另外一种情况,源码包含了这个品牌,但解码长度和值不对,针对这种情况你可以 收集一操作 然后把操作注明,提交issue给作者,他可以根据你的操作和原始值分析码长和值的一些情况
需要指出的是,由于空调厂家变动一些代码阀值,部分显示也会unknow,但是刷完IRMQTTSERVER固件后,仍然可以控制空调,却不能Decode解析,此类情况请参考上面的分析完所有的操作原始值,提交给作者修改码长和阀值等信息
喜普大奔,支持了怎么用? 下载到arduino库,示例IRMQTTSERVER,对应编译即可。使用编译请修改IRMQTTSERVER.h文件中的IR_LED 和IR_RX ,其对应的是发射脚IO和接收IO
不会操作,请下载:
IRMQTTServer.ino.generic.zip
(329.15 KB, 下载次数: 110)
下载已经编译的固件请: 红外发射管请 GND接GPIO16 [短脚] Vcc接 电源3V[长脚] ,接收管out脚接 GPIO14 Vcc Gnd 各自对应 刷入完成后,上电默认AP模式,手机连入后配网操作,务必配置MQTT,配置完成后,可使用IP进入IRMQTTSERVER ,操作如下图 请务必确认你的测试是可以发码的,使用手机摄像头对着红外管,操作后有灯闪表示发码成功,所有操作均无灯闪请检查自己的GPIO接线及发射管,目前已发现有部分发射管不发射成功。 使用AIRCON操作的时候,如果你的空调不支持swing v&H 扫风模式,请不要开启,所有功能空调没有的,均不要开启,否则发码不成功!
操作时model可以默认,没有反应可以再选择1、2、3、4、5、6,均无反应则PASS,不支持
MQTT至于接入方面,通过上图,大概你们也清楚,设备网页info里也已经展示。调用接口均匀 已经出现,不明白可以参考
climate:
platform: mqtt
name: Living Room Aircon
modes:
- "off"
- "auto"
- "cool"
- "heat"
- "dry"
- "fan_only"
fan_modes:
- "auto"
- "min"
- "low"
- "medium"
- "high"
- "max"
swing_modes:
- "off"
- "auto"
- "highest"
- "high"
- "middle"
- "low"
- "lowest"
power_command_topic: "ir_server/ac/cmnd/power"
mode_command_topic: "ir_server/ac/cmnd/mode"
mode_state_topic: "ir_server/ac/stat/mode"
temperature_command_topic: "ir_server/ac/cmnd/temp"
temperature_state_topic: "ir_server/ac/stat/temp"
fan_mode_command_topic: "ir_server/ac/cmnd/fanspeed"
fan_mode_state_topic: "ir_server/ac/stat/fanspeed"
# swing_mode_command_topic: "ir_server/ac/cmnd/swingv"
# swing_mode_state_topic: "ir_server/ac/stat/swingv"
min_temp: 16
max_temp: 32
temp_step: 1
retain: false
有测试OK的基友,请贴出你的遥控器型号及图片,thanks,,,,
|