Controlling AC throught Openhab and ESP Easy

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
jimmys01
Normal user
Posts: 13
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.


ac.items

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]"}
ac.rules

Code: Select all

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

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


if(acCommandDelay!==null) {
    acCommandDelay.cancel    
    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+"\",\"mode\":\""+mode.state+"\",\"temp\":"+temp.state+",\"fanspeed\":\""+fan.state+"\",\"swingv\":\""+swing.state+"\"}")
]

end
home.sitemap

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 16 Sep 2019, 07:51, edited 2 times in total.

User avatar
ThomasB
Normal user
Posts: 406
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:
https://community.openhab.org/t/release ... hab2/37844

- Thomas

8lazo8
Normal user
Posts: 8
Joined: 26 Dec 2018, 13:22

Re: Controlling AC throught Openhab and ESP Easy

#3 Post by 8lazo8 » 31 Jul 2019, 14:04

jimmys01 wrote:
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.


ac.items

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]"}
ac.rules

Code: Select all

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

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


if(acCommandDelay!==null) {
    acCommandDelay.cancel    
    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+"\"}")
]

end
home.sitemap

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"]
Thanks Jimmy for sharing this, very useful.

How does an mqtt message looks like in this case? Which plugin do you use in espeasy?

jimmys01
Normal user
Posts: 13
Joined: 07 Jan 2019, 22:37

Re: Controlling AC throught Openhab and ESP Easy

#4 Post by jimmys01 » 31 Jul 2019, 21:09

The plug in is the "Communication - IR Transmit" plug in or else the P035.
The mqtt cmd message is like:

Code: Select all

IRSENDAC,{"Protocol":"COOLIX","Power":"on","Opmode":"dry","Fanspeed":"auto","Degrees":22,"Swingv":"max","Swingh":"off"}

8lazo8
Normal user
Posts: 8
Joined: 26 Dec 2018, 13:22

Re: Controlling AC throught Openhab and ESP Easy

#5 Post by 8lazo8 » 01 Aug 2019, 19:49

jimmys01 wrote:
31 Jul 2019, 21:09
The plug in is the "Communication - IR Transmit" plug in or else the P035.
The mqtt cmd message is like:

Code: Select all

IRSENDAC,{"Protocol":"COOLIX","Power":"on","Opmode":"dry","Fanspeed":"auto","Degrees":22,"Swingv":"max","Swingh":"off"}
Thanks a lot!

8lazo8
Normal user
Posts: 8
Joined: 26 Dec 2018, 13:22

Re: Controlling AC throught Openhab and ESP Easy

#6 Post by 8lazo8 » 14 Sep 2019, 23:26

jimmys01 wrote:
31 Jul 2019, 21:09
The plug in is the "Communication - IR Transmit" plug in or else the P035.
The mqtt cmd message is like:

Code: Select all

IRSENDAC,{"Protocol":"COOLIX","Power":"on","Opmode":"dry","Fanspeed":"auto","Degrees":22,"Swingv":"max","Swingh":"off"}
Hi Jimmy,

I tried the mqtt setup and after all the message/signal reaches the AC but whatever option I send to it, it always turns on in fan only mode at 25 degree celsius.
Did you try this with a Gree AC?

8lazo8
Normal user
Posts: 8
Joined: 26 Dec 2018, 13:22

Re: Controlling AC throught Openhab and ESP Easy

#7 Post by 8lazo8 » 14 Sep 2019, 23:51

8lazo8 wrote:
14 Sep 2019, 23:26
jimmys01 wrote:
31 Jul 2019, 21:09
The plug in is the "Communication - IR Transmit" plug in or else the P035.
The mqtt cmd message is like:

Code: Select all

IRSENDAC,{"Protocol":"COOLIX","Power":"on","Opmode":"dry","Fanspeed":"auto","Degrees":22,"Swingv":"max","Swingh":"off"}
Hi Jimmy,

I tried the mqtt setup and after all the message/signal reaches the AC but whatever option I send to it, it always turns on in fan only mode at 25 degree celsius.
Did you try this with a Gree AC?
I found the solution for Gree: instead of opmode is only mode, instead of degrees is temp.

jimmys01
Normal user
Posts: 13
Joined: 07 Jan 2019, 22:37

Re: Controlling AC throught Openhab and ESP Easy

#8 Post by jimmys01 » 16 Sep 2019, 07:54

Thanks, leftovers from early versions of the JSON

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests