<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.domoticz.com/index.php?action=history&amp;feed=atom&amp;title=ESPEasy_Aircondition_Inverter_IR_control</id>
	<title>ESPEasy Aircondition Inverter IR control - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.domoticz.com/index.php?action=history&amp;feed=atom&amp;title=ESPEasy_Aircondition_Inverter_IR_control"/>
	<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=ESPEasy_Aircondition_Inverter_IR_control&amp;action=history"/>
	<updated>2026-09-19T10:14:12Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wiki.domoticz.com/index.php?title=ESPEasy_Aircondition_Inverter_IR_control&amp;diff=12337&amp;oldid=prev</id>
		<title>Lotte3500: /* LUA script to control heatpumpIR */</title>
		<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=ESPEasy_Aircondition_Inverter_IR_control&amp;diff=12337&amp;oldid=prev"/>
		<updated>2019-05-18T07:31:36Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;LUA script to control heatpumpIR&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Purpose=&lt;br /&gt;
With this script you will be able to control your heatpump supported by toniA&amp;#039;s heatpumpir library. Check his lib to see supported heatpumps / AC https://github.com/ToniA/arduino-heatpumpir&lt;br /&gt;
You shall use ESPEASY that also contains Toni&amp;#039;s heatpumpir plugin, I have also added 1 pcs DS18B20, so I am able to monitor airtemp blown out from heatpump&lt;br /&gt;
&lt;br /&gt;
=Hardware=&lt;br /&gt;
Wemos D1 Mini Pro&lt;br /&gt;
&lt;br /&gt;
USB power supply&lt;br /&gt;
&lt;br /&gt;
940nm IR LED&lt;br /&gt;
&lt;br /&gt;
100 Ohm resister&lt;br /&gt;
&lt;br /&gt;
DS18B20&lt;br /&gt;
&lt;br /&gt;
Cables and pinheader connectors&lt;br /&gt;
&lt;br /&gt;
=Software=&lt;br /&gt;
ESPEASY: http://www.letscontrolit.com/wiki/index.php/ESPEasy&lt;br /&gt;
&lt;br /&gt;
Download heatpumpIr lib: https://github.com/ToniA/arduino-heatpumpir&lt;br /&gt;
&lt;br /&gt;
I use Arduino IDE, Compile it all and upload your firmware to the Wemos D1 Mini Pro&lt;br /&gt;
&lt;br /&gt;
==Check heatpumpIR==&lt;br /&gt;
How to add this ESPEASY to your own wifi is not in this scope and can be found in ESPEASY help pages&lt;br /&gt;
&lt;br /&gt;
ESPEASY shall look like this, depending of your chosen GPIO pins&lt;br /&gt;
&lt;br /&gt;
Since I use Wemos D1 Mini Pro, use GPio 16 -&amp;gt; D0 on the actual Wemos D1 Mini Pro, if you choose to other GPIO pin, then compare here:&lt;br /&gt;
[https://www.wemos.cc/product/d1-mini-pro.html Wemos D1 Mini Pro]&lt;br /&gt;
&lt;br /&gt;
[[File:Espeasy_heatpumpir.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Check that you are able to control your heatpump from a webbrowser: I have an IVT model&lt;br /&gt;
&lt;br /&gt;
switch on: http://192.168.1.2/control?cmd=heatpumpir,ivt,1,2,1,24,0,0&lt;br /&gt;
&lt;br /&gt;
Switch off: http://192.168.1.2/control?cmd=heatpumpir,ivt,0,2,1,24,0,0&lt;br /&gt;
&lt;br /&gt;
If you are able to control heatpump from the webrowser then you can control it from domoticz&lt;br /&gt;
&lt;br /&gt;
===Dummy devices in Domoticz ===&lt;br /&gt;
Notice that LUA scripts are case sensitive, so you need to pay attention to spelling, &amp;quot;AC Fan Speed&amp;quot; is not same as &amp;quot;ac fan speed&amp;quot;&lt;br /&gt;
&lt;br /&gt;
IVT temperature is not really needed, but I have added 1 pcs DS18B20, create a dummy device and put it to a temperature sensor, remember the IDX number, which you add to ESPEASY, in my setup it&amp;#039;s idx120.&lt;br /&gt;
&lt;br /&gt;
All 3 devices shall be created as dummy devices&lt;br /&gt;
like those pics show&lt;br /&gt;
[[File:AC_set_temperature.png]]&lt;br /&gt;
[[File:Ac_fan_speed.png]]&lt;br /&gt;
[[File:Ac_mode.png]]&lt;br /&gt;
&lt;br /&gt;
Then you should get those below devices&lt;br /&gt;
[[File:Domo_AC.png]]&lt;br /&gt;
&lt;br /&gt;
==LUA script to control heatpumpIR==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
Script created by hpapagaj and modified by bjacobse&lt;br /&gt;
to use with ToniA&amp;#039;s heatpumpir lib + ESpeasy and _P115_heatpumpir &lt;br /&gt;
&lt;br /&gt;
Create the following dummy switches (Note that LUA are case sensitiv):&lt;br /&gt;
&amp;#039;AC Mode&amp;#039;&amp;#039;AC Fan Speed&amp;#039;&amp;#039;AC Set Temperature&amp;#039;&lt;br /&gt;
&lt;br /&gt;
and if your AC/heatpoump support then also create:&lt;br /&gt;
&amp;#039;AC Hor dir&amp;#039;&amp;#039;AC Vert dir&amp;#039;&lt;br /&gt;
And add -- in front of line 27. And remove -- in line 29&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 https://github.com/ToniA/arduino-heatpumpir/blob/master/HeatpumpIR.h&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Changelog:&lt;br /&gt;
 &lt;br /&gt;
    Version 1.0, 2017 January&lt;br /&gt;
    - Initial release&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
--Set espeasy heatpump IP address&lt;br /&gt;
local ipadress = &amp;#039;192.168.2.6&amp;#039;&lt;br /&gt;
local model = &amp;#039;ivt&amp;#039;&lt;br /&gt;
&lt;br /&gt;
commandArray = {}&lt;br /&gt;
for key, value in pairs(devicechanged) do&lt;br /&gt;
  --if (key == &amp;#039;AC Mode&amp;#039; or key == &amp;#039;AC Fan Speed&amp;#039; or key == &amp;#039;AC Set Temperature&amp;#039; or key == &amp;#039;AC Hor dir&amp;#039; or key == &amp;#039;AC Ver dir&amp;#039;) then&lt;br /&gt;
  if (key == &amp;#039;AC Mode&amp;#039; or key == &amp;#039;AC Fan Speed&amp;#039; or key == &amp;#039;AC Set Temperature&amp;#039;) then&lt;br /&gt;
&lt;br /&gt;
    print (&amp;quot;HeatpumpIR event started&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Power mode is ON if operating modes are in use&lt;br /&gt;
--// Power state&lt;br /&gt;
--#define POWER_OFF   0&lt;br /&gt;
--#define POWER_ON    1&lt;br /&gt;
    local power = 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--// Operating modes&lt;br /&gt;
--#define MODE_AUTO   1&lt;br /&gt;
--#define MODE_HEAT   2&lt;br /&gt;
--#define MODE_COOL   3&lt;br /&gt;
--#define MODE_DRY    4&lt;br /&gt;
--#define MODE_FAN    5&lt;br /&gt;
--#define MODE_MAINT  6&lt;br /&gt;
    local mode = 2&lt;br /&gt;
    if (otherdevices[&amp;#039;AC Mode&amp;#039;]) == &amp;#039;Off&amp;#039; then&lt;br /&gt;
        mode = 0&lt;br /&gt;
        power = 0&lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Mode&amp;#039;] == &amp;#039;Auto&amp;#039;) then&lt;br /&gt;
        mode = 1        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Mode&amp;#039;] == &amp;#039;Heat&amp;#039;) then&lt;br /&gt;
        mode = 2        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Mode&amp;#039;] == &amp;#039;Cool&amp;#039;) then&lt;br /&gt;
        mode = 3        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Mode&amp;#039;] == &amp;#039;Dry&amp;#039;) then&lt;br /&gt;
        mode = 4        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Mode&amp;#039;] == &amp;#039;fan&amp;#039;) then&lt;br /&gt;
        mode = 5        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Mode&amp;#039;] == &amp;#039;Maint&amp;#039;) then&lt;br /&gt;
        mode = 6        &lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
--print (otherdevices_svalues[&amp;#039;AC mode&amp;#039;])&lt;br /&gt;
 --for i, v in pairs(devicechanged) do print(i, v) end&lt;br /&gt;
&lt;br /&gt;
--// Fan speeds. Note that some heatpumps have less than 5 fan speeds&lt;br /&gt;
--#define FAN_AUTO    0&lt;br /&gt;
--#define FAN_1       1&lt;br /&gt;
--#define FAN_2       2&lt;br /&gt;
--#define FAN_3       3&lt;br /&gt;
--#define FAN_4       4&lt;br /&gt;
--#define FAN_5       5&lt;br /&gt;
    local fan = 1&lt;br /&gt;
    if (otherdevices[&amp;#039;AC Fan Speed&amp;#039;]) == &amp;#039;Auto&amp;#039; then&lt;br /&gt;
        fan = 0&lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Fan Speed&amp;#039;]) == &amp;#039;1&amp;#039; then&lt;br /&gt;
        fan = 1        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Fan Speed&amp;#039;]) == &amp;#039;2&amp;#039; then&lt;br /&gt;
        fan = 2        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Fan Speed&amp;#039;]) == &amp;#039;3&amp;#039; then&lt;br /&gt;
        fan = 3        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Fan Speed&amp;#039;]) == &amp;#039;4&amp;#039; then&lt;br /&gt;
        fan = 4        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Fan Speed&amp;#039;]) == &amp;#039;5&amp;#039; then&lt;br /&gt;
        fan = 5&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
--Set temperature&lt;br /&gt;
    local settemperature = 23&lt;br /&gt;
    settemperature = tonumber(otherdevices[&amp;#039;AC Set Temperature&amp;#039;])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--// Vertical air directions. Note that these cannot be set on all heat pumps&lt;br /&gt;
--#define VDIR_AUTO   0&lt;br /&gt;
--#define VDIR_MANUAL 0&lt;br /&gt;
--#define VDIR_SWING  1&lt;br /&gt;
--#define VDIR_UP     2&lt;br /&gt;
--#define VDIR_MUP    3&lt;br /&gt;
--#define VDIR_MIDDLE 4&lt;br /&gt;
--#define VDIR_MDOWN  5&lt;br /&gt;
--#define VDIR_DOWN   6&lt;br /&gt;
    local verdir = 0&lt;br /&gt;
    if (otherdevices[&amp;#039;AC Ver dir&amp;#039;]) == &amp;#039;Auto&amp;#039; then&lt;br /&gt;
        verdir = 0&lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Ver dir&amp;#039;]) == &amp;#039;Manual&amp;#039; then&lt;br /&gt;
        verdir = 0        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Ver dir&amp;#039;]) == &amp;#039;Swing&amp;#039; then&lt;br /&gt;
        verdir = 1        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Ver dir&amp;#039;]) == &amp;#039;Up&amp;#039; then&lt;br /&gt;
        verdir = 2        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Ver dir&amp;#039;]) == &amp;#039;Mup&amp;#039; then&lt;br /&gt;
        verdir = 3        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Ver dir&amp;#039;]) == &amp;#039;Middle&amp;#039; then&lt;br /&gt;
        verdir = 4        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Ver dir&amp;#039;]) == &amp;#039;Mdown&amp;#039; then&lt;br /&gt;
        verdir = 5&lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Ver dir&amp;#039;]) == &amp;#039;Down&amp;#039; then&lt;br /&gt;
        verdir = 6&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--// Horizontal air directions. Note that these cannot be set on all heat pumps&lt;br /&gt;
--#define HDIR_AUTO   0&lt;br /&gt;
--#define HDIR_MANUAL 0&lt;br /&gt;
--#define HDIR_SWING  1&lt;br /&gt;
--#define HDIR_MIDDLE 2&lt;br /&gt;
--#define HDIR_LEFT   3&lt;br /&gt;
--#define HDIR_MLEFT  4&lt;br /&gt;
--#define HDIR_MRIGHT 5&lt;br /&gt;
--#define HDIR_RIGHT  6&lt;br /&gt;
    local hordir = 0&lt;br /&gt;
    if (otherdevices[&amp;#039;AC Hor dir&amp;#039;]) == &amp;#039;Auto&amp;#039; then&lt;br /&gt;
        hordir = 0&lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Hor dir&amp;#039;]) == &amp;#039;Manual&amp;#039; then&lt;br /&gt;
        hordir = 0        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Hor dir&amp;#039;]) == &amp;#039;Swing&amp;#039; then&lt;br /&gt;
        hordir = 1        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Hor dir&amp;#039;]) == &amp;#039;Middle&amp;#039; then&lt;br /&gt;
        hordir = 2        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Hor dir&amp;#039;]) == &amp;#039;Left&amp;#039; then&lt;br /&gt;
        hordir = 3        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Hor dir&amp;#039;]) == &amp;#039;Mleft&amp;#039; then&lt;br /&gt;
        hordir = 4        &lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Hor dir&amp;#039;]) == &amp;#039;Mright&amp;#039; then&lt;br /&gt;
        hordir = 5&lt;br /&gt;
    elseif (otherdevices[&amp;#039;AC Hor dir&amp;#039;]) == &amp;#039;Right&amp;#039; then&lt;br /&gt;
        hordir = 6&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
    print (&amp;quot;HeatpumpIR event transmitted&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print (&amp;#039;http://&amp;#039; ..ipadress.. &amp;#039;/control?cmd=heatpumpir,&amp;#039; .. model..&amp;#039;,&amp;#039;..power..&amp;#039;,&amp;#039;..mode..&amp;#039;,&amp;#039;..fan..&amp;#039;,&amp;#039;..settemperature..&amp;#039;,&amp;#039;..verdir..&amp;#039;,&amp;#039;..hordir)&lt;br /&gt;
    commandArray[&amp;#039;OpenURL&amp;#039;] = &amp;#039;http://&amp;#039; ..ipadress.. &amp;#039;/control?cmd=heatpumpir,&amp;#039; .. model..&amp;#039;,&amp;#039;..power..&amp;#039;,&amp;#039;..mode..&amp;#039;,&amp;#039;..fan..&amp;#039;,&amp;#039;..settemperature..&amp;#039;,&amp;#039;..verdir..&amp;#039;,&amp;#039;..hordir&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
return commandArray&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:ESPEasy]]&lt;br /&gt;
[[Category:Hardware]]&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Lotte3500</name></author>
	</entry>
</feed>