Home Assistant and IR gateway problems

And when pressing your remote control do you see a “datastring” on your mqtt broker?

That’s the thing. When using clients like MQTT.fx or MQTT Explorer I don’t see any topics pop up in auto discovery when I press buttons on the remote. I see led blinks indicating it got the message but that’s it. All I did with the default config was to disable gateways other than IR, disable wifi manager and put all my connection details (network/mqtt) in the user_config.h. I dunno, maybe I’ll reflash with defaults and change everything in WiFi Manager :?

Been a while. I redid my setup with Wemos D1 Mini with IR shield and still can’t get the gateway to work with my Haier UNIT.

IRdump works, decodes the key presses, but with OMG I get unknown and nothing is posted to the topics. I tried sending codes I got to IR_RAW, but it did not work. I know I’m being annoying, but is there anything I can do to debug this to make it work? Halp!? :slight_smile:

Hi,

Could you try this to receive the raw payload with OMG (it wasn’t the MQTT length in my case but the raw buffer; the payload from my AC split unit is also 112 bits and only the first part of the message was read)?

1 Like

Sorry for such late reply, but I had quite a week at work :frowning:
OMG! You are a genius! I just flashed the gateway with the suggested change and bam, I can see stuff in IRtoMQTT topic:

{“value”:14863526,“protocol”:44,“bits”:112,“raw”:}

This is great! Apparently Haier is also 112 bits like in your case! Ok, now I need to think how to make it work with HA and how to actually send anything :smiley:

Ok, now that I finally getting some progress, I got some questions.

The lack of “raw” value is because I need to enable raw forwarding in config_IR.h, correct? Do I need it if I have “value”?

When I try to publish to
home/OpenMQTTGateway/commands/MQTTtoIR
message
{"value":15903910,"protocol_name":"IR_HAIER_AC_YRW02"}
my gateway restarts and is unable to reconnect. I tried with the same message I got in IRtoMQTT topic but result is the same.

If I have Serial monitor open I see this:

Hey I got a callback
MQTTtoIR json
MQTTtoIR data || raw ok
value
15903910
raw

Exception (28):
epc1=0x402083b8 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

stack>>>

ctx: cont
sp: 3fff00a0 end: 3fff0670 offset: 01a0
3fff0240: 4010040c 00000bb8 00000bb8 40100434
3fff0250: 00000208 00000208 00000672 00000208
3fff0260: 00000009 00000001 00000000 402080e5
3fff0270: 00000bb8 00000bb8 3ffee978 00000000
3fff0280: 00000009 00000bb8 3ffee978 4020a4c1
3fff0290: 0000028a 00000208 000249f0 00000000
3fff02a0: 00000009 00000026 00000001 00000000
3fff02b0: 00000032 00000001 30393531 3fff0330
3fff02c0: 00000000 00000003 3ffeefd4 40214ea0
3fff02d0: c024f147 00071e77 3ffef104 00000009
3fff02e0: 00f2aca6 3fff13f1 00000003 4020a4fa
3fff02f0: 00000000 00000003 3ffeefd4 40202258
3fff0300: 00000000 00000000 3fff03b0 3fff0330
3fff0310: 3ffe8a20 00000000 3fff03b0 3fff0330
3fff0320: 00000003 00000000 3fff03b0 40203df5
3fff0330: 00000000 00000000 ffc6a7f0 00000000
3fff0340: 00000000 3fff0370 00000001 402030b1
3fff0350: 00000000 00000000 00000001 40202a10
3fff0360: 00000000 00f2aca6 3fff13f1 00000000
3fff0370: 00000000 3fff13f1 3ffe9211 3ffef104
3fff0380: 00071ef9 00000001 3ffee990 3ffee9c6
3fff0390: 3ffee99f 3fff03b0 3fff13d4 40203f3e
3fff03a0: 40219310 3fff03b0 00000200 00000028
3fff03b0: 3fff03a0 3fff03b8 3fff03c8 3fff13d4
3fff03c0: 00000001 3fff13da 00000000 3fff13e3
3fff03d0: 00000002 3fff13f1 00000020 401012f2
3fff03e0: 00007fff 1bd0ff16 3ffed544 401021de
3fff03f0: 3ffe9970 00000000 00000000 00000100
3fff0400: 00007fff 1bd0ff16 4010261e 00000100
3fff0410: 7fffffff 3ffe9970 3ffe9970 00000001
3fff0420: 00000001 00004288 4010261e 00000100
3fff0430: 7fffffff 1bd0ff16 00000000 4000050c
3fff0440: 3fffc278 401023b8 3fffc200 00000022
3fff0450: 3ffe997c 401046eb 3ffecb00 4000050c
3fff0460: 4000dd17 00000030 00000010 ffffffff
3fff0470: 4000066d 00000000 4bc6a7f0 00000000
3fff0480: 00004bc6 00000000 00000000 fffffffe
3fff0490: 00000000 3fffc6fc 00000000 00000000
3fff04a0: 4bc6a7f0 ae978d4f 00000000 00000030
3fff04b0: 40102009 3ffecb00 7dc0f5f2 00000000
3fff04c0: 00000023 1bd0f64f 3ffed544 401021de
3fff04d0: 3ffe9964 00000000 00000000 00000022
3fff04e0: 00000023 1bd0f64f 4010261e 00000100
3fff04f0: 7fffffff 3ffe9964 3ffe9964 3ffef25c
3fff0500: 4024f44c 00000020 00000000 40218401
3fff0510: 3fff0520 40216188 00000000 4000050c
3fff0520: 3fffc278 401023b8 3fffc200 00000022
3fff0530: 00000000 4bc6a7f0 74fdf3b6 00000000
3fff0540: 3ffe8c83 00000000 3ffe8c82 40217a5a
3fff0550: 00000000 00000000 3fff1844 3ffee9c6
3fff0560: 00000036 00000015 3ffeefd4 40214ea0
3fff0570: c024f44b 4bc6a7f0 3fff180c 40215291
3fff0580: 3ffef25c 00000275 00000275 40218138
3fff0590: 00000036 3ffee99f 3fff05d0 40218560
3fff05a0: 00000036 00000001 0000002c 3ffee9c6
3fff05b0: 3fff03a0 3fff140a 3fff1403 4021830a
3fff05c0: 3fff140a 3ffee99f 3fff13d4 40203fe2
3fff05d0: 00000000 00000000 ffff1638 4010027b
3fff05e0: 3fff0610 00000001 3ffeed90 00000026
3fff05f0: 00071efa 3ffeed90 3ffee990 402187c4
3fff0600: 00071efa 3ffeed90 3ffee990 4020505c
3fff0610: 00000001 3ffeef40 3ffeee6c 40211cc6
3fff0620: 00000001 00000004 3ffee993 00000060
3fff0630: 402194f8 00000000 3ffee990 3ffef104
3fff0640: 00071efa 00000001 3ffee990 40204762
3fff0650: 3fffdad0 00000000 3ffef0d4 40216ca0
3fff0660: feefeffe feefeffe 3ffe85b0 4010098d
<<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld

Is this due lack of raw data?

Actually Florian figured it out in the first place (I just provided detailed info of the problem :slight_smile: ).

In order to publish the raw values for the unknown protocols such as those for AC units,
#define pubIRunknownPrtcl should be set to true in config_ir.h

To add support for the specific brand and not use the raw value, the payload should be decoded. Here’s what I managed to work on about two years ago when I’ve started using OMG (just a printscreen of the excel file, as it’s not advisable to open excel files from strangers on internet :slight_smile: ).

I started by writing down each command values from the remote and the code in hex. After splitting on individual blocks, several patterns emerge: first 10 chars are constant, field 11 is on/off indicator, 13 is for mode, etc.

In regard of the temperature field (15), the function in cell AC5 is as following:
=BIN2HEX(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DEC2BIN(A5),0,8),1,0),8,1),LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DEC2BIN(A5),0,8),1,0),8,1)),1)&MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DEC2BIN(A5),0,8),1,0),8,1),LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DEC2BIN(A5),0,8),1,0),8,1))-1,1)&MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DEC2BIN(A5),0,8),1,0),8,1),LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DEC2BIN(A5),0,8),1,0),8,1))-2,1)&MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DEC2BIN(A5),0,8),1,0),8,1),LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DEC2BIN(A5),0,8),1,0),8,1))-3,1))

The problem is that fields 27 and 28 are the result of checksum validation. Although I applied the same steps as for temperature (conversion to bin, replacing 1 with 0 and reversing), I didn’t got to the same result so I didn’t continued and just used raw values which was much easier in HA.

You have two options to set it in HA: as a switch (recording only IR for on at say 16 degrees and off commands), then a thermostat that controls it (see below; the payloads are huge and have only included parts) or (much more complex but uses all functions of the remote) as HVAC (however, this one needs all button combinations to be recorded as raw, which are in the range of hundreds; I have both set but after HA 0.96 the HVAC component is broken so the simple thermostat is better :smile: )

- platform: mqtt
  name: "AC"
  command_topic: "home/GatewayOpenMQTT1/commands/IR_Raw"
  qos: 0
  retain: false
  availability_topic: "home/GatewayOpenMQTT1/LWT"
  payload_available: "Online"
  payload_not_available: "Offline"
  payload_on: "3106,1702,530....536,336,504"
  payload_off: "3112,1694,536,1022,536....1034,526,372,504"
climate:
- platform: generic_thermostat
  name: AC thermostat
  heater: switch.ac
  target_sensor: sensor.sn2_real_feel
  min_temp: 15
  max_temp: 24
  target_temp: 22
  cold_tolerance: 0.8
  hot_tolerance: 0.8
  ac_mode: true 
  min_cycle_duration:
    seconds: 7200
  initial_hvac_mode: "off"
  away_temp: 28

Thanks again! First I need to investigate the exception. Also I am getting sort-off proper value in the IRtoMQTT topic for my codes, just I was wandering about empty “raw:” part. Maybe despite getting the value I need to work with raws like you described, hm :thinking:

I flashed (not without issues) 0.9.2 today. I had troubles with changes to the libs (troubles like where are they :wink:), but managed in the end.

But to the point. It does not crash on send like before, so it seems the bug reported in other thread is fixed and that made it work for me as well.

Few notes though:

1.Gateway name changed (to home/OpenMQTTGateway_ESP8266_IR/IRtoMQTT in my case), got me confused at first but I found the correct one with MQTT.fx discovery
2.I am getting double messages.
One like:

{"value":14863526,"protocol":44,"bits":112,"hex":"A6CCE200526F062F060000000050","raw":}

The other just the value:

14863526

3.I don’t know why, but when I enable scan, instead of expected (I think :thinking:):

home/OpenMQTTGateway_ESP8266_IR/IRtoMQTT/LWT
home/OpenMQTTGateway_ESP8266_IR/IRtoMQTT/version

I am getting:

home/OpenMQTTGateway/IRtoMQTT/LWT
home/OpenMQTTGateway/IRtoMQTT/version
home/OpenMQTTGateway_ESP8266_IR/IRtoMQTT/LWT
home/OpenMQTTGateway_ESP8266_IR/IRtoMQTT/version

So the old gateway (it even reports as 0.9.1 in Version topic) and the new one. I have only one OMG so this does not make sense. All the subsequent topics found are from the correct version/base topic.

4.Still can’t send :frowning: But at least it does not crash.
When I publish to
home/OpenMQTTGateway_ESP8266_IR/commands/MQTTtoIR
I am getting:

Hey I got a callback
MQTTtoIR json
MQTTtoIR value || raw || datasring ok
value
14728358
MQTTtoIR OK
Pub json into:
home/OpenMQTTGateway_ESP8266_IR/IRtoMQTT
{"value":14728358,"protocol_name":"IR_HAIER_AC_YRW02"}
Pub data per topic
value
14728358
protocol_name
IR_HAIER_AC_YRW02
Hey I got a callback
Store str
Hey I got a callback
Store str
Min ind:
1
store code :
14728358/485883
Col: val/timestamp
0:14728358/469962
1:14728358/485883
2:14859430/22267
3:14859430/22289
4:14863526/28114
5:14863526/28362
6:14859430/28856
7:14859430/28899
8:14855334/438797
9:14855334/438832
10:14859430/442376
11:14859430/442405
JSON str
14728358

I feel like I’m beating a dead horse with this one…

I’m not doing anything fancy…

  1. Downloaded CODE from releases
  2. Unpacked somewhere and opened it in PIO
  3. Build the project
  4. Uncommented default_envs = nodemcuv2-ir
  5. Made changes to IRrecv.h (kRawBuf up to 300 from 100)
  6. Put in my MQTT and WiFi settings and uploaded.

This Haier is really not playing nice with OMG…

Hello

For the point 1, yes there is an overload of the gateway name for each env. In your case with IR I put this name but feel free to change it.
For 2 this is due to the activation of simple publishing, since your post I removed it for all the env except the ones with all the modules that are for tests purposes.
For 3 you should delete the old messages with mqtt explorer or equivalent. Indeed they are retained by the broker.
For 4 I need to think on it more

And sorry if the last changes introduced with pio was disturbing.

For 1. Cool, I will take a look. I assume I change this line in platformio.ini

build_flags = 
  ${com-esp.build_flags}
  '-DZgatewayIR="IR"'
  '-DGateway_Name="OpenMQTTGateway_ESP8266_IR"' <---

For 2. So User_config.h values are overwritten by platformio.ini? Because I have it disabled in code, but I see this:

[com-esp]
lib_deps =
  ${env.lib_deps}
  ${libraries.wifimanager}
build_flags =
  ${env.build_flags}
  -DMQTT_MAX_PACKET_SIZE=1024
  '-DsimpleReceiving=true'
  '-DsimplePublishing=true'
  '-DZmqttDiscovery="HADiscovery"'
  '-DTRACE=1'

So I assume I change DsimplePublishing to false and we’re good?

For 3. Got it! Thanks, indeed I was able to remove the old topics from MQTT server using the explorer tool.

For 4. Ah, no rush. Sorry I’m causing so much trouble :wink:

PIO is great, but I think the change should be a bit more documented. I still managed to run it, it got all the libraries and all, but for someone that VS Code is not a daily editor this is a bit more complicated than Arduino Studio :wink: I still don’t know for example if I should update libraries like PIO is asking me all the time, I assume not, so I’m disregarding those notifications.

Still…great work :+1:

@1technophile
Good Sir, did you, by any chance, had time to take a look at the problem I reported?

Yes exactly

Not all but at least the ones in the example given (platformio.ini), I’m enabling step by step this overload capacity, if you have special request don’t hesitate to ask me.

Yes

I’m thinking on adding to docs.openmqttgateway.com a chapter on uploading with Arduino IDE

Thanks for answers but I mainly wanted to know if you had the chance to look at what I reported in earlier posts - Home Assistant and IR gateway problems

I’ve just made a big update (library and code) for irremote esp8266

Note that the protocol_name should be directly the protocol itself in capital letters like here

If you can test with it, I corrected some issues

Perfect, thank you! I will as soon as I get my hass.io back online. It decided to eat my memory card and I’m toasted at the moment. I will be moving it to Docker on the server I’m in the process of setting up. I’ll report back as soon as I can, thanks again for all your hard work @1technophile :vulcan_salute:

Actually…I now that I think about it I’m a dummy, I don’t need HA for that :slight_smile: I’ll try to test it by the end of the week cause I curious about the improvements I saw on Github :slight_smile: