Hello People. I have some NOOB and very beginner question.
I’m using Tasmota-ir and flashed it into Eachen IR device to control my SAMSUNG AirConditioner via OpenHAB and MQTT. Everything works fine.
The command can be sent directly via IRhvac command.
But I notice that
If we send command like:
ํYou will notice that temperature is sent 21. Instead of 25
Meaning that IRHVAC will send all lump default of parameter. That’s a problem when I need to map it to openhab
Why? Because let’s say If you have On Off Button,Temp Selection and Mode selection
If I change Temp to 25, then set mode “Cool”. Temp will change back to 21.
Likewise. If set temp back to 25. Mode will change to the default “Auto”.
So I have an idea that if we can use rules to send the lump of command but command can be vary with an openhab input in example
It’s like that if we can get latest parameter into variable. So the command can sent with lump of parameter that memorize the latest another parameter.
Or if it cannot. I have to create a many rule to done this openhab A/C remote. That’s terrible.
I try hard to explain but I know that may hard to understand. haha. But hope someone can help me.
Or if anyone have the better idea than this and your idea is already worked. Please share to NOOB like me.
I also have the idea to make a universal remote in my openhab like you can select list of model. Meaning you can use openhab to command any of A/C that usable with IR Command libraly that refer to this link: https://tasmota.github.io/docs/Tasmota-IR/
When you are dealing with character strings, + just means join them together.
var x = "fred" + "mary" // result "fredmary"
var y = 2 + 2
x = x + y.toString // result "fredmary4"
x = "elephant " + x + mySwitchItem.state.toString
// result "elephant fredmary4ON"
So, in a rule, you can gather different bits of data either from calculations in the rule or from other Items in your system, and stick them together in one bundle.
rule "Send Command to Aircon through IRBLASTER"
when
Item AirconditionerPower received command or
Item AirconditionerSetTemp received command or
Item AirconditionerSetMode received command
then
val mqttActions = getActions("mqtt","mqtt:broker:myMQTTBroker")
var int setTemp = (AirconditionerSetTemp.state as Number).intValue
var jsonString = '{"Vendor":"GREE","Model":1,' +
'"Power":"'+ AirconditionerPower.state.toString +'",' +
'"Mode":"'+ AirconditionerSetMode.state.toString +'",' +
'"Celsius":"On",' +
'"Temp":'+ setTemp +',' +
'"FanSpeed":"Auto",' +
'"SwingV":"Auto",' +
'"SwingH":"Off",' +
'"Quiet":"Off",' +
'"Turbo":"Off",' +
'"Econo":"Off",' +
'"Light":"On",' +
'"Clean":"Off",' +
'"Filter":"Off",' +
'"Beep":"Off",' +
'"Sleep":-1}'
logInfo("IRhvac", " Aircon To " + jsonString )
mqttActions.publishMQTT("irBlaster2/cmnd/IRhvac", jsonString )
end
rule "If google control tuning aircon on/off"
when
Item AirconditionerMode received command
then
if (receivedCommand != OFF){
AirconditionerPower.sendCommand(ON)
AirconditionerSetMode.sendCommand(receivedCommand)
} else {
AirconditionerPower.sendCommand(OFF)
}
end
In frontail I can see the command is published. But looks like these commands not reaching to my tasmota-ir device
I also have a doubt with
logInfo("IRhvac", " Aircon To " + jsonString )
What does ‘Aircon To’ stand for? It publish it and it is shown IRhvac Aircon To {jsoncommand}.
I also try to use
loginfo(“IRhvac”, jsonString)
It’s shown IRhvac {jsonString)
But tasmota-ir device still not get it.
MQTT already enable in tasmota-ir
MQTT things in openhab also online
It is very different if you want to track your remotes.
Ok so you are a very beginner that is copy pasting code that is not working fun.
In my example I was using google voice assistant to control so I needed to handle the integration in a specific way.
This is just a message you can send to a logfile so you can see what is going on.
The “Aircon To” is just what I want the aircon to be set to, its just a message in the logfile that is all.
Front tail only shows what you tell it to and this is telling it to write what is in the jsonString variable to log file. This shows that the json string is formatted correctly.
As two systems are never the same use my example as a experts tutorial and with no explanation its not for beginners to be able to understand.
So now I hope you understand that its not the whole picture.
First you say you got it working on the tasmota console with
Awesome you got it to work.
Now read all tasmota docs and you will likely pull your hair out.
This tells me the format of your topics.
Can you install my favourite MQTT tool http://mqtt-explorer.com/ connect it to your broker as a tool to be able to look at what is happening inside MQTT
Now what are your items associated with this device?
Something like but can be anything…
Switch AirconditionerPower
Number AirconditionerSetTemp
String AirconditionerSetMode
What is your openHAB MQTT Broker name ?
I think it is mqtt:broker:MosquittoMqttBroker from your first post but may be different.
In the example mine is mqtt:broker:myMQTTBroker
What editor are you using to change your rule files?
rule "Send Command to Aircon through IRBLASTER"
when
Item AirconditionerPower received command or
Item AirconditionerSetTemp received command or
Item AirconditionerSetMode received command
then
val mqttActions = getActions("mqtt","mqtt:broker:myMQTTBroker")
var int setTemp = (AirconditionerSetTemp.state as Number).intValue
var jsonString = '{"Vendor":"SAMSUNG_AC","Model":1,' +
'"Power":"'+ AirconditionerPower.state.toString +'",' +
'"Mode":"'+ AirconditionerSetMode.state.toString +'",' +
'"Celsius":"On",' +
'"Temp":'+ setTemp +',' +
'"FanSpeed":"Auto",' +
'"SwingV":"Auto",' +
'"SwingH":"Off",' +
'"Quiet":"Off",' +
'"Turbo":"Off",' +
'"Econo":"Off",' +
'"Light":"On",' +
'"Clean":"Off",' +
'"Filter":"Off",' +
'"Beep":"Off",' +
'"Sleep":-1}'
logInfo("IRhvac", " Aircon To " + jsonString )
mqttActions.publishMQTT("cmnd/tasmota_6E7106/IRhvac", jsonString )
end
Now you should be able to control the power set temp and mode. You can add to it to be able to change more settings if you want.
Ok in MQTT Explorer to the
topic cmnd/tasmota_6E7106/IRhvac
publish {"Vendor":"SAMSUNG_AC", "Power":"ON"}
This should work and be able to control your devices.
This cmnd topic appear suddenly when I click to command from my BasicUI
But in Tasmota console there is nothing happen
What I’m already did:
I just copy json payload from MQTTE (I don’t know I call it correctly or not lol). and deleted “=” as I told you guy then put in directly into tasmota console
Below is my rules (That I adapted from your code. Anyway, Not just copy and pasted I can say lol)
rule "Send Command to Aircon"
when
Item AirconditionerSetPower received command or
Item AirconditionerSetTemp received command or
Item AirconditionerSetMode received command or
Item AircondotionerSetFanSpeed received command or
Item AirconditionerSetSwingV received command or
Item AirconditionerSetTurbo received command
then
val mqttActions = getActions("mqtt","mqtt:broker:MosquittoMqttBroker")
var int setTemp = (AirconditionerSetTemp.state as Number).intValue
var jsonString = '{"Vendor":"SAMSUNG_AC","Model":1,' +
'"Power":"'+ AirconditionerSetPower.state.toString +'",' +
'"Mode":"'+ AirconditionerSetMode.state.toString +'",' +
'"Celsius":"On",' +
'"Temp":'+ setTemp +',' +
'"FanSpeed":"Medium",' +
'"SwingV":"Auto",' +
'"SwingH":"Off",' +
'"Quiet":"Off",' +
'"Turbo":"Off",' +
'"Econo":"Off",' +
'"Light":"On",' +
'"Clean":"Off",' +
'"Filter":"Off",' +
'"Beep":"Off",' +
'"Sleep":-1}'
logInfo("IRhvac", " Aircon To " + jsonString )
mqttActions.publishMQTT("/cmnd/tasmota_6E7106/IRHvac", jsonString )
end
Thing mqtt:topic:bedroom1ac "Bedroom1 Air Conditioner" (mqtt:broker:MosquittoMqttBroker) {
Type switch : AirconPower [stateTopic = "stat/tasmota_6E7106/RESULT" , transformationPattern = "REGEX:(.*\"Power\".*)∩JSONPATH:$.IRHVAC.Power"]
//commandTopic = "cmnd/tasmota_6E7106/IRhvac" ]
Type number : AirconTemp [stateTopic = "stat/tasmota_6E7106/RESULT" , transformationPattern = "REGEX:(.*\"Temp\".*)∩JSONPATH:$.IRHVAC.Temp"]
//commandTopic = "cmnd/tasmota_E304CB/ZbSend", formatBeforePublish = "{ \"device\":\"LIVINGROOM1GLEDOPTO1\", \"send\":{\"Hue\":\"%s\"}}", min = "0", max = "254"]
Type string : AirconMode [stateTopic = "stat/tasmota_6E7106/RESULT" , transformationPattern = "REGEX:(.*\"Mode\".*)∩JSONPATH:$.IRHVAC.Mode"]
//commandTopic = "cmnd/tasmota_E304CB/ZbSend", formatBeforePublish = "{ \"device\":\"LIVINGROOM1GLEDOPTO1\", \"send\":{\"Sat\":\"%s\"}}", min = "0", max = "254"]
Type string : AirconFanSpeed [stateTopic = "stat/tasmota_6E7106/RESULT" , transformationPattern = "REGEX:(.*\"FanSpeed\".*)∩JSONPATH:$.IRHVAC.FanSpeed"]
//commandTopic = "cmnd/tasmota_E304CB/ZbSend", formatBeforePublish = "{ \"device\":\"LIVINGROOM1GLEDOPTO1\", \"send\":{\"Dimmer\":\"%s\"}}", min = "0", max = "254" ]
Type string : AirconSwingV [stateTopic = "stat/tasmota_6E7106/RESULT" , transformationPattern = "REGEX:(.*\"SwingV\".*)∩JSONPATH:$.IRHVAC.SwingV"]
//commandTopic = "cmnd/tasmota_E304CB/ZbSend", formatBeforePublish = "{ \"device\":\"LIVINGROOM1GLEDOPTO1\", \"send\":{\"Dimmer\":\"%s\"}}", min = "0", max = "254" ]
Type switch : AirconTurbo [stateTopic = "stat/tasmota_6E7106/RESULT" , transformationPattern = "REGEX:(.*\"Turbo\".*)∩JSONPATH:$.IRHVAC.Turbo"]
}
I have // comment because I modified from my rgb strip thing but no need to command via things channel. I think if we command from rules in will publish directly to pointed mqttbroker. So I just add channel to get the result state.
I think OpenHAB and tasmota already connected to mqtt broker already from the picture above. But wonder why Tasmota not received this mqtt message
Note: 192.168.1.103 is my openhabiandevice with port 1883 to MosquittoMqttBroker
Thankyou thankyou thankyou for providing such detailed information
This helps to take a detailed look as to the problem you have with your system it is a typo. You have now progressed to regular user and can no longer call yourself a NOOB.
the typo is / before cmnd in the rule
It changes the topic so tasmota doesn’t see it
It has been a pleasure helping you as you have put considerable effort in to get it working on your own and giving us enough detail to help you.