First thing to do is install MQTT on your RPI which is needed to command the module inside your MHI airco.
Here is one out of many instructions how to.
Next is to buy the hardware and flash the software.
Install the Arduino IDE on your computer.
Open ArduinoIDE File>Preferences (Ctrl , ) and then Aditional Board Managers URLs and add this url https://arduino.esp8266.c...age_esp8266com_index.json and close window.
Go to Tools>BoardManagers and search esp8266 and install it.
Go to Tools>Manage Libraries and search PubSubClient (by Nick o Leary) and note install version 2.7.0 also search ArduinoOTA and install the latest version.
Now you can download the MHI-AC-CTRL files https://github.com/absalo...rchive/refs/tags/v2.8.zip and unzip them. The file support.h which is the src folder sit open in e.g. notepad but can also in arduino itself. Adjust the settings so Wifi, Hostname, MQTT server settings and possibly an OTA password for updating your script wirelessly. Feel free to look through the list for any other settings.
In ArduinoIDE open the MHI-AC-CTRL.ino file this is in the src folder of the download. It is possible that a new folder will be created and the ino file will be moved. Then manually add the other 5 .h and .cpp files to the new directory which was created by Arduino IDE. These should be in the same folder.
In support.h fill in your credentials.
I enabled USE_EXTENDED_FRAME_SIZE as well as POWERON_WHEN_CHANGING_MODE (read about it in the SW-Configuration.md)
Keep this page at hand as a reference to use with the dzVents file.
Go to Tools>Board>ESP8266> LOLIN WEMON D1 mini clone (if you have another board then select that one).
Go to Tools>Port and select the port where your arduino is connected.
Then hit the green -> at the top left of the screen and if all goes well it will only write to the board and the data will come into your MQTT server.
Now you have the hardware and software installed and will be able to find the device (after unplugging RX and TX) in your network. Advanced IP scanner is a nice tool on Windows like NMap is on any platform.
Your new device is listed as MHI-AC-Ctrl.
Now let's go to Domoticz
Goto Setup -> Hardware -> Creat Virtual Sensors
Setup 5 selector switches named Airco Mode, Airco Temp, Airco Fan, Airco HSwing and Airco VSwing.
As an example the setup of the Airco mode selector.
Level 0 - Off, Level 10 - Auto, Level 20 - Cool, Level 30 - Heat, Level 40 - Dry, Level 50 - Fan
You will find the corresponding values in the software and on the SW-Configuation.md page.
The software:
Code: Select all
return {
on = {
devices = {'Airco on/off', 'Airco Temp', 'Airco Fan', 'Airco VSwing', 'Airco HSwing', 'Airco Mode'},
},
data = {},
logging = {
-- Level can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG, domoticz.LOG_ERROR or domoticz.LOG_FORCE
--level = domoticz.LOG_INFO,
level = domoticz.LOG_DEBUG,
marker = '---- Airco -----',
},
execute = function(domoticz, triggerObject)
local OnOffSwitch = domoticz.devices('Airco on/off')
local Temp = domoticz.devices('Airco Temp')
local Fan = domoticz.devices('Airco Fan')
local VSwing = domoticz.devices('Airco VSwing')
local HSwing = domoticz.devices('Airco HSwing')
local Mode = domoticz.devices('Airco Mode')
domoticz.log('# Airco temp level :' .. Temp.level, domoticz.LOG_DEBUG)
domoticz.log('# Airco fan level :' .. Fan.level, domoticz.LOG_DEBUG)
domoticz.log('# Airco VSwing level :' .. VSwing.level, domoticz.LOG_DEBUG)
domoticz.log('# Airco HSwing level :' .. HSwing.level, domoticz.LOG_DEBUG)
domoticz.log('# Airco Mode level :' .. Mode.level, domoticz.LOG_DEBUG)
if triggerObject.name == 'Airco Mode' then
if Mode.level == 0 then
domoticz.log('Mode set to Off :' .. triggerObject.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Mode" -m "Off"')
elseif Mode.level == 10 then
domoticz.log('Mode set to Auto :' .. triggerObject.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Mode" -m "Auto"')
elseif Mode.level == 20 then
domoticz.log('Mode set to Cool :' .. triggerObject.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Mode" -m "Cool"')
elseif Mode.level == 30 then
domoticz.log('Mode set to Heat :' .. triggerObject.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Mode" -m "Heat"')
elseif Mode.level == 40 then
domoticz.log('Mode set to Dry :' .. triggerObject.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Mode" -m "Dry"')
elseif Mode.level == 50 then
domoticz.log('Mode set to Fan :' .. triggerObject.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Mode" -m "Fan"')
end
elseif triggerObject.name == 'Airco Temp' then
if Temp.level == 0 then
domoticz.log('4 Temp set to 18º :' .. Temp.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Tsetpoint" -m 18.0')
elseif Temp.level == 10 then
domoticz.log('5 Temp set to 19º :' .. Temp.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Tsetpoint" -m "19.0"')
elseif Temp.level == 20 then
domoticz.log('6 Temp set to 20º :' .. Temp.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Tsetpoint" -m "20.0"')
elseif Temp.level == 30 then
domoticz.log('7 Temp set to 21º :' .. Temp.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Tsetpoint" -m "21.0"')
elseif Temp.level == 40 then
domoticz.log('8 Temp set to 22º :' .. Temp.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Tsetpoint" -m "22.0"')
end
elseif triggerObject.name == 'Airco Fan' then
if Fan.level == 0 then
domoticz.log('9 Fan set to Auto :' .. Fan.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Fan" -m "Auto"')
elseif Fan.level == 10 then
domoticz.log('10 Fan set to Low :' .. Fan.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Fan" -m "1"')
elseif Fan.level == 20 then
domoticz.log('11 Fan set to Medium-Low :' .. Fan.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Fan" -m "2"')
elseif Fan.level == 30 then
domoticz.log('12 Fan set to Medium-High :' .. Fan.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Fan" -m "3"')
elseif Fan.level == 40 then
domoticz.log('13 Fan set to High :' .. Fan.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Fan" -m "4"')
end
elseif triggerObject.name == 'Airco VSwing' then
if VSwing.level == 0 then
domoticz.log('14 VSwing set to Auto :' .. VSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Vanes" -m "Swing"')
elseif VSwing.level == 10 then
domoticz.log('15 VSwing set to High :' .. VSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Vanes" -m "1"')
elseif VSwing.level == 20 then
domoticz.log('16 VSwing set to Medium-High :' .. VSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Vanes" -m "2"')
elseif VSwing.level == 30 then
domoticz.log('17 VSwing set to Medium-Low :' .. VSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Vanes" -m "3"')
elseif VSwing.level == 40 then
domoticz.log('18 VSwing set to Low :' .. VSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Vanes" -m "4"')
end
elseif triggerObject.name == 'Airco HSwing' then
if HSwing.level == 0 then
domoticz.log('20 HSwing set to Auto :' .. HSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/VanesLR" -m "Swing"')
elseif HSwing.level == 10 then
domoticz.log('21 HSwing set to Far Left :' .. HSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/VanesLR" -m "1"')
elseif HSwing.level == 20 then
domoticz.log('22 HSwing set to Left :' .. HSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/VanesLR" -m "2"')
elseif HSwing.level == 30 then
domoticz.log('23 HSwing set to Center-Left :' .. HSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/VanesLR" -m "3"')
elseif HSwing.level == 40 then
domoticz.log('24 HSwing set to Center :' .. HSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/VanesLR" -m "4"')
elseif HSwing.level == 50 then
domoticz.log('25 HSwing set to Center-Right :' .. HSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/VanesLR" -m "5"')
elseif HSwing.level == 60 then
domoticz.log('26 HSwing set to Right :' .. HSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/VanesLR" -m "6"')
elseif HSwing.level == 70 then
domoticz.log('27 HSwing set to Far Right :' .. HSwing.state, domoticz.LOG_DEBUG)
domoticz.executeShellCommand('mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/VanesLR" -m "7"')
end
end
end
}
On one terminal commands can be sent to the broker, the other one is listening.
In one terminal you can publish like: mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Mode" -m "Off" or mosquitto_pub -h 192.168.2.104 -t "MHI-AC-Ctrl/set/Mode" -m "Auto"
In the other terminal ypu can listen: mosquitto_sub -v -h 192.168.2.104 -p 1883 -t 'MHI-AC-Ctrl/#'
It will show you something like
Code: Select all
MHI-AC-Ctrl/connected 1
MHI-AC-Ctrl/Version 2.8
MHI-AC-Ctrl/RSSI -47
MHI-AC-Ctrl/WIFI_LOST 0
MHI-AC-Ctrl/MQTT_LOST 0
MHI-AC-Ctrl/WIFI_BSSID 82:B7:BD:30:42:3D
MHI-AC-Ctrl/APs BSSID:92:B7:BD:36:42:07 RSSI:-86
MHI-AC-Ctrl/fSCK 0
MHI-AC-Ctrl/fMOSI 0
MHI-AC-Ctrl/fMISO 0
MHI-AC-Ctrl/cmd_received o.k.
MHI-AC-Ctrl/set/Fan Auto
MHI-AC-Ctrl/cmd_received o.k.
First look in Settings -> Log to check if the dzVents script doesn't render ERRORS
Then go look at you switches and switch. If everything is ok you will see the commands in the MQTT listening terminal followed by MHI-AC-Ctrl/cmd_received o.k.
Enjoy!