Controlling AC throught Openhab and ESP Easy

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Normal user
Posts: 7
Joined: 07 Jan 2019, 22:37

Controlling AC throught Openhab and ESP Easy

#1 Post by jimmys01 » 13 Jul 2019, 15:16

This is my setup that utilizes the new extended AC commands of the IR library.
The only think that needs to be costumized is the .items file. You substitute the LivingRoom part with anything you want and you leave the part after the _ the same.
Also in the items file you change the XXXX_Protocol "PUT YOUR PROTOCOL HERE".
The rules follow patterns so you can have as many AC nodes as you wish without messing with the rules.
There is also a timer that wont let you send more that 1 command per second.
This example uses the 1.x mqtt binding, if i transfer it to 2.x i will post it here.


Code: Select all

Group   Ghome "Home"  <house>
Group:String                    gAC               "All AC In the House [%d]"       <snow>          (Ghome)

String LivingRoom_Protocol "GREE"             (gAC) //put in the label the protocol name
Switch  LivingRoom_Power  "Power"           	(gAC) // mode of operation - one of Auto/Dry/Cool/Heat/Fan/Night
String LivingRoom_Mode   "Mode [%s]"      (gAC) 
Number  LivingRoom_Temp   "Temp [%.0f °C]" (gAC) // temperature set point
String LivingRoom_Fan   "Fan [%s]"       (gAC) // fan mode - one of Auto/F1/F2/F3/F4/F5
String LivingRoom_Swing  "Swing [%s]"      (gAC) // swing mode - one of Off/UpDown
String 	LivingRoom_IR "Living Room IR"   	(gAC)    ["Switchable"]  {mqtt=">[broker:ESP_Easy/LivingRoomNode1/cmd:command:*:default]"}

Code: Select all

var Timer acCommandDelay = null
rule "AC state changed"
Member of gAC received command
//logInfo("AC", "------------" +" changed to " + triggeringItem.state)
var   baseItemName=,"_"))

var   protocol =gAC.members.findFirst[name.equals(,"_"))+"_Protocol")]
var   power =gAC.members.findFirst[name.equals(,"_"))+"_Power")]
var   mode =gAC.members.findFirst[name.equals(,"_"))+"_Mode")]
var   temp =gAC.members.findFirst[name.equals(,"_"))+"_Temp")]
var   fan =gAC.members.findFirst[name.equals(,"_"))+"_Fan")]
var   swing =gAC.members.findFirst[name.equals(,"_"))+"_Swing")]
//val spower = transform("MAP", "", power.state.toString)
if (protocol.label==NULL){return}
if (power.state===NULL){postUpdate(,OFF)}
if (temp.state===NULL){postUpdate(,"22")}
if (fan.state===NULL){postUpdate(,"auto")}
if (swing.state===NULL){postUpdate(,"auto")}

if(acCommandDelay!==null) {
acCommandDelay=createTimer(now.plusSeconds(1))[ //dont send the command right away, maybe the user is not fineshed yet
    sendCommand( baseItemName +"_IR", "IRSENDAC,{\"protocol\":\""+protocol.label+"\",\"power\":\""+power.state.toString+"\",\"opmode\":\""+mode.state+"\",\"degrees\":"+temp.state+",\"fanspeed\":\""+fan.state+"\",\"swingv\":\""+swing.state+"\"}")


Code: Select all

Default item=LivingRoom_Power 
Switch item=LivingRoom_Mode  mappings=[cold="Cold" , hot="Hot", dry="Dry", fanonly="Fan Only", auto="AUTO"] 
Setpoint item=LivingRoom_Temp  minValue=16 maxValue=30 step=1
Switch item=LivingRoom_Fan  mappings=[min="Lowest" , low="Medium", high="High", max="Max", auto="AUTO"] 
Switch item=LivingRoom_Swing mappings=[min="Lowest" , low="Medium", high="High", max="Max", auto="AUTO"]
Last edited by jimmys01 on 14 Jul 2019, 09:02, edited 1 time in total.

User avatar
Normal user
Posts: 336
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Controlling AC throught Openhab and ESP Easy

#2 Post by ThomasB » 14 Jul 2019, 00:50

Thanks for sharing your setup. I'm also using ESPEasy with Openhab home control. Compatibility between them is excellent thanks to MQTT.

And giving a voice to ESPEasy devices is possible using Openhab's Alexa Control Binding. Telling Alexa to control a ESPEasy device and/or have her provide voice responses with useful information about them is all done in rules. If not already using it, I highly recommend the Alexa Control binding. Details are here: ... hab2/37844

- Thomas

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest