IRSEND / IRHVAC command using MQTT

Hi all,

I’ve setup a nodemcu with IR receiver and transmitter and flashed it using tasmota-ir, primarily so that I can control my Mitsubishi air conditioner. The device has been linked with my mqtt broker and I can now receive IR command from any remote and send IR commands using the Tasmota device console.

I’ve now tried to integrate it with Openhab (using PaperUI) but I’m now struggling to send commands using mqtt using the MQTT Command topic. It gives me the following error in the console:

MQT: stat/ircontrol/RESULT = {“IRHVAC”:“Invalid JSON”}

As mentioned, I can turn on the air conditioner using the Tasmota device console, but it looks quite complex:

IRHVAC {“Vendor”:“MITSUBISHI_AC”,“Model”:-1,“Power”:“On”,“Mode”:“Cool”,“Celsius”:“On”,“Temp”:21,“FanSpeed”:“Auto”,“SwingV”:“Highest”,“SwingH”:“RightMax”,“Quiet”:“Off”,“Turbo”:“Off”,“Econo”:“Off”,“Light”:“Off”,“Filter”:“Off”,“Clean”:“Off”,“Beep”:“Off”,“Sleep”:-1}

Now to make it work with Openhab and PaperUI. I assume might need to setup a rule and configure the “Outgoing Value Transformation” Any ideas?

Are you just trying to turn it on, or also control all those other settings?

What do you need to publish to the MQTT broker to turn the air conditioning on? Or, how do you command it via the console - just power on?

At the moment I’d just like to focus on turning it on and off, however it might be worthwhile configuring all the other features. But from my first tests, it looks like the air conditioner always needs complete settings along with the “on” and “off”.

With regards to what I need to publish to the MQTT broker… well that is a good question.

I’ve found something which might point me in the right direction: [SOLVED] IR Send with Tasmota MQTT Binding V2.5

I will report back.

Hi Alex,
I am also using tasmota-ir to control ACs and an A/V receiver. I would suggest to try the following approach that is working for me:

  1. Create a new MQTT thing
  2. In the MQTT thing create a strings channel named “AC_Commands” with the following configuration
    i) MQTT state topic empty
    ii) MQTT Command Topic “cmnd/<your tasmota topic>/IRHVAC”
    iii) No transformations needed
  3. Create a .items file like this
//AC Control
String AC_Commands          "AC Commands"      {channel="mqtt:topic:<mqtt topic id from step 1:AC_Commands"}
Switch AC_ON_OFF            "AC ON/OFF []"       
  1. Create a .rules file
rule "AC ON"
when
    Item AC_ON_OFF changed from OFF to ON
then
    val actions = getActions("mqtt","mqtt:broker:<mqtt broker id>")
    actions.publishMQTT("cmnd/<your topic from tasmota>/IRHVAC"," {\“Vendor\”:\“MITSUBISHI_AC\”,\“Model\”:-1,\“Power\”:\“On\”,\“Mode\”:\“Cool\”,\“Celsius\”:\“On\”,\“Temp\”:21,\“FanSpeed\”:\“Auto\”,\“SwingV\”:\“Highest\”,\“SwingH\”:\“RightMax\”,\“Quiet\”:\“Off\”,\“Turbo\”:\“Off\”,\“Econo\”:\“Off\”,\“Light\”:\“Off\”,\“Filter\”:\“Off\”,\“Clean\”:\“Off\”,\“Beep\”:\“Off\”,\“Sleep\”:-1} ")
end

rule "AC OFF"
when
    Item AC_ON_OFF changed from ON to OFF
then
    val actions = getActions("mqtt","mqtt:broker:<mqtt broker id>")
    actions.publishMQTT("cmnd/<your topic from tasmota>/IRHVAC"," {\“Vendor\”:\“MITSUBISHI_AC\”,\“Model\”:-1,\“Power\”:\Off\”,\“Mode\”:\“Cool\”,\“Celsius\”:\“On\”,\“Temp\”:21,\“FanSpeed\”:\“Auto\”,\“SwingV\”:\“Highest\”,\“SwingH\”:\“RightMax\”,\“Quiet\”:\“Off\”,\“Turbo\”:\“Off\”,\“Econo\”:\“Off\”,\“Light\”:\“Off\”,\“Filter\”:\“Off\”,\“Clean\”:\“Off\”,\“Beep\”:\“Off\”,\“Sleep\”:-1} ")
end

A similar process can be followed to control all the other parameters.

1 Like

Thanks for the tip. Looks like it’s a pretty neat solution. I’ll give that a try.

Hi Nikolaos,

I followed your steps and I’m getting some strange error: [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘AC ON’: actions cannot be null

Got any ideas?

This is my rule:

rule “AC ON”
when
Item AirconControl changed from OFF to ON
then
val actions = getActions(“mqtt”,“mqtt:broker:49eebb2a”)
actions.publishMQTT(“cmnd/ircontrol/IRHVAC”,"{“Vendor”:“MITSUBISHI_AC”,“Model”:-1,“Power”:“On”,“Mode”:“Cool”,“Celsius”:“On”,“Temp”:21,“FanSpeed”:“Auto”,“SwingV”:“Highest”,“SwingH”:“RightMax”,“Quiet”:“Off”,“Turbo”:“Off”,“Econo”:“Off”,“Light”:“Off”,“Filter”:“Off”,“Clean”:“Off”,“Beep”:“Off”,“Sleep”:-1}")
end

Hi Alex,
Try escaping the " in the command to be sent with \ like in my example. For example instead of “Vendor” try \“Vendor\” and so on for all arguments in quotes. At the end you need to have only the quotes before and after the { } not escaped.

1 Like

A simple example of turning on the TV, I think based on it you will do whatever you want.

things:

Thing topic ir_tv_things "TV" @ "Room" {
    Channels:
        Type string	    : cmd		"IR Code"           [commandTopic="cmnd/ir-remote/IRsend"]
        Type datetime   : update    "Update"            [stateTopic="tele/ir-remote/STATE", transformationPattern="JSONPATH:$.Time"]
        Type number     : rssi	    "IR Wifi Signal"    [stateTopic="tele/ir-remote/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI" ]
        Type string     : lwt       "lwt"               [stateTopic="tele/ir-remote/LWT"]
            
    }

items:

String		IR_TV_Cmd		"cmd [%s]"	<tv>					{channel="mqtt:topic:v_mqtt:ir_tv_things:cmd", channel="mqtt:topic:v_mqtt:ir_tv_things:state", autoupdate="false"}
Switch		TV_Power		"On/Off [%s]"		(gRestore,gSceneVillage_3_ON)	{expire="1s,command=OFF"}

rules:

rule "TV on/off"
when 
    Item TV_Power changed to ON
then
    IR_TV_Cmd.sendCommand("{\"Protocol\":\"NEC\",\"Bits\":32,\"Data\":\"0x20DF10EF\"}")
    //logInfo("RULE","<-- TV on/off")
end

Hi guys, I’m struggling trying to find a solution from my case…

I’m using Tasmota 8.4 and I’m able to read and write commands by local Tasmota console but I’m not able to do the same by MQTT FX (I’m trying here before go OH2).

This is from Tasmota Console:
01:52:53 CMD: Irsend {“Protocol”:“NEC”,“Bits”:32,“Data”:0x20DF10EF}
01:52:53 MQT: stat/Tasmota_135/RESULT = {“IRSend”:“Done”}

This is from MQTT FX:
Input on MQTT FX: cmnd/Tasmota_135/Irsend {“Protocol”:“NEC”,“Bits”:32,“Data”:“0x20DF10EF”}
Output on Tasmota Console: 01:54:11 MQT: stat/Tasmota_135/RESULT = {“Command”:“Unknown”}

Do you guys have any tip for me?
Thank you in advance,
From Brazil!!!