Differential Control of Air Conditioner

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Differential Control of Air Conditioner

#1 Post by gregoinc » 31 Jan 2019, 10:36

Greetings,

I have been reading multiple sources in the forum and decided it was probably best to put together a concise description of what I am trying to achieve in the hope that someone can give me guidance. I am totally new to the Rules concept, so struggling to learn the syntax and values. Once I have a few pointers I suspect I will be fine.

The project... I have a modest man cave / home data center in my back yard. The building has a wall mounted Daikin air conditioner. I run a number of servers and obviously need to keep them cool on hot days, or when the room temperature reaches an upper limit.

So, what do I have... My ESP8266 device is a NodeMCU, using two DS18b20 temperature sensors on GPIO-14, and an Infrared LED on GPIO-12 using the Heatpump IR transmitter code created by ToniA (found here): viewtopic.php?f=2&t=1915&hilit=heatpumpir

Here is a look on the devices page...
Studio_20190131_173242.png
Studio_20190131_173242.png (102.73 KiB) Viewed 10437 times
The heatpumpir command is used to send the Daikin infrared codes via the IR LED on GPIO-12. Here's an example code to turn the Daikin Air Conditioner ON: heatpumpir,daikin,1,3,0,24,4,2

There will also be a separate heatpumpir command that would send the IR codes to turn the Daikin Air Conditioner OFF.

So here is my early thinking on differential logic (note this is not in rules programmatic syntax - which is where I need help)...

if Temp2 > Temp1 and Temp1 > 25 send IR codes to turn ON AC
if Temp2 < Temp1 and Temp1 , 25 send IR codes to turn OFF AC
if Temp1 > 27 send IR codes to turn ON AC (this is like an emergency AC start if the room starts to get too hot, even if the outside temperature Temp2 is lower than inside Temp1)
if Temp1 < 25 and Temp2 < Temp1 send IR codes to turn OFF AC (part of the emergency start/stop process)

Key to above: Temp1 = inside, and Temp2 = outside

What am I trying to achieve... I am trying to ensure the man cave / home DC room stays below 25 degrees (the AC temperature is set to 24.5). I dont want the Rules logic to only use a single DS18b20 in the room itself, because the Rules would most likely flip flop the air conditioner on and off. So instead I want the Rules logic to monitor the outside and inside temperature, assuming if the outside temperature is higher than the inside temperature then the Rule should keep the air conditioner running. Obviously when it cools down outside then the rules logic should turn the AC unit OFF.

I have never done this before, so am open to suggestions. Especially on writing the rule, including how the heatpumpir,daikin,1,3,0,24,4,2 is executed based on the logic I have written above.

Over to you... your help is very much appreciated :)

Thanks, Mark

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Differential Control of Air Conditioner

#2 Post by gregoinc » 31 Jan 2019, 12:14

So far I've developed the rules code below and have confirmed it works... and turns the air conditioner ON.. woo hoo!!

Code: Select all

on Temp1#Temperature do
   if [Temp1#Temperature] > 27
      heatpumpir,daikin,1,3,0,24,4,2
   endif
endon
Only problems...

- I am still stuck on the best way to write the code for the rules to meet the differential logic I wrote above?
- I cannot workout how to program the rule to only send the heatpumpir command once? Whilst Temp1 stays higher than 27 the heatpumpir code is sent every 10 seconds, which is the time between reads of Temp1 sensor. I could increase the polling time to longer, but hope there is some rules code that can do the job?

Open to any suggestions :)

Thanks, Mark

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Differential Control of Air Conditioner

#3 Post by grovkillen » 31 Jan 2019, 13:05

Look into variables and you can see that you can make the unit only send one time when going from below X to above X. And then you will be able to set it to do something else when going from anchor X to below X.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Differential Control of Air Conditioner

#4 Post by gregoinc » 31 Jan 2019, 22:18

Hi Grovkillen,

When you say variables, I assume you are referring to the TaskValueSet and Dummy Device?

With code like...

Code: Select all

on Temp1#Temperature do
   if [dummy#var1]=0
    TaskValueSet 12,1,0
  else
   if [Temp1#Temperature] > 27
      heatpumpir,daikin,1,3,0,24,4,2
      TaskValueSet 12,1,1
   endif
endon
Not sure above is right? Apology for the nuffy questions... once I get my head around the syntax I'll be fine.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Differential Control of Air Conditioner

#5 Post by grovkillen » 31 Jan 2019, 22:35

Or with internal variables:

Code: Select all

on Temp1#Temperature do
   if [Temp1#Temperature]<27
    Event,StartHP
  else
    Let,1,0
   endif
endon

On StartHP Do
If [VAR#1]=0
 heatpumpir,daikin,1,3,0,24,4,2
 Let,1,1
EndIf
EndOn
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Differential Control of Air Conditioner

#6 Post by gregoinc » 31 Jan 2019, 22:45

Thanks again Grovkillen... I will give it a try. I assume I just add a similar string of code for turning the AC unit off?

Looks like I might be buying you some beers when I am in Sweden later this year :)

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Differential Control of Air Conditioner

#7 Post by grovkillen » 01 Feb 2019, 09:29

gregoinc wrote: 31 Jan 2019, 22:45 Thanks again Grovkillen... I will give it a try. I assume I just add a similar string of code for turning the AC unit off?

Looks like I might be buying you some beers when I am in Sweden later this year :)
You just add an event to it:

Code: Select all

on Temp1#Temperature do
   if [Temp1#Temperature]<27
    Event,StartHP
  else
    Event,StopHP
   endif
endon

On StartHP Do
If [VAR#1]=0
 heatpumpir,daikin,1,3,0,24,4,2
 Let,1,1
EndIf
EndOn

On StopHP Do
If [VAR#1]=1
 heatpumpir,daikin,1,3,0,24,4,2
 Let,1,0
EndIf
EndOn

Beer is always needed ;)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Differential Control of Air Conditioner

#8 Post by gregoinc » 01 Feb 2019, 22:39

Thanks again Grovkillen. Last night I moved one of the DS18b20 to it's final location, and both DS18b20 stopped working. One of the DS18b20 is now on a longer cable, which seems to have upset the NodeMCU? So I need to solve that issue and then get back to the coding. So much fun :lol:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Differential Control of Air Conditioner

#9 Post by grovkillen » 01 Feb 2019, 22:48

Shouldn't matter if it's on a one wire line but if you have a star system they must be of equal length (+/-30cm) to be happy.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Differential Control of Air Conditioner

#10 Post by gregoinc » 02 Feb 2019, 02:56

grovkillen wrote: 01 Feb 2019, 22:48 Shouldn't matter if it's on a one wire line but if you have a star system they must be of equal length (+/-30cm) to be happy.
Ok, that might be the issue... I'll try changing the cabling. Thanks again :)

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Differential Control of Air Conditioner

#11 Post by gregoinc » 02 Feb 2019, 10:53

Looked over the code from Grovkillen (thanks again Grovkillen, couldn't have got here without you) and devised my own rules code to try and replicate my differential logic above... here's my first cut...

Code: Select all

on Temp2#Temperature do
   if [Temp2#Temperature] > [Temp1#Temperature] and [Temp1#Temperature] > 25
    Event,StartHP
  else
    Event,StopHP
   endif
endon

on Temp2#Temperature do
   if [Temp2#Temperature] < [Temp1#Temperature] and [Temp1#Temperature] < 25
    Event,StopHP
   endif
endon

on Temp1#Temperature do
   if [Temp1#Temperature] > 27
    Event,StartHP
  else
    Event,StopHP
   endif
endon

On StartHP Do
If [VAR#1]=0
 heatpumpir,daikin,1,3,0,24,4,2
 Let,1,1
EndIf
EndOn

On StopHP Do
If [VAR#1]=1
 heatpumpir,daikin,0,3,0,24,4,2
 Let,1,0
EndIf
EndOn
Will test it and see what happens :)

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Differential Control of Air Conditioner

#12 Post by gregoinc » 02 Feb 2019, 23:44

I modified the code slightly and ran it to test...

Code: Select all

on Temp2#Temperature do
   if [Temp2#Temperature] > [Temp1#Temperature] and [Temp1#Temperature] > 25
    Event,StartHP
  else
    Event,StopHP
   endif
endon

on Temp1#Temperature do
   if [Temp1#Temperature] > 27
    Event,StartHP
  else
    Event,StopHP
   endif
endon

On StartHP Do
If [VAR#1]=0
 heatpumpir,daikin,1,3,0,24,4,2
 Let,1,1
EndIf
EndOn

On StopHP Do
If [VAR#1]=1
 heatpumpir,daikin,0,3,0,24,4,2
 Let,1,0
EndIf
EndOn
I am seeing this in the logs. Would appreciate some advice on the log data, is it what should be happening?

56207258: DS : Temperature: 23.50 (28-aa-f9-13-1b-13-2-e6)
56207261: EVENT: Temp1#Temperature=23.50
56207284: ACT : Event,StopHP
56207335: DS : Temperature: 24.81 (28-7d-22-25-30-14-1-11)
56207338: EVENT: Temp2#Temperature=24.81
56207370: ACT : Event,StopHP
56207421: Command: event
56207422: EVENT: StopHP
56207458: Command: event
56207459: EVENT: StopHP
56224411: WD : Uptime 937 ConnectFailures 0 FreeMem 15240
56247260: DS : Temperature: 23.44 (28-aa-f9-13-1b-13-2-e6)
56247262: EVENT: Temp1#Temperature=23.44
56247287: ACT : Event,StopHP
56247337: DS : Temperature: 24.75 (28-7d-22-25-30-14-1-11)
56247340: EVENT: Temp2#Temperature=24.75
56247374: ACT : Event,StopHP
56247421: Command: event
56247422: EVENT: StopHP
56247460: Command: event
56247460: EVENT: StopHP
56254411: WD : Uptime 938 ConnectFailures 0 FreeMem 15264

Thanks, Mark

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Differential Control of Air Conditioner

#13 Post by gregoinc » 03 Feb 2019, 02:37

Had an opportunity to test the code... and in the log when the temperature inside the room reached 25 the StartHP event came up in the log. But... the heatpumpir command appears not to have been sent?

I sent the heatpumpir command manually and the air conditioner started. So I am guessing there's an issue in this section of code?

Code: Select all

On StartHP Do
If [VAR#1]=0
 heatpumpir,daikin,1,3,0,24,4,2
 Let,1,1
EndIf
EndOn
I will cut down the code to remove the variable and see what happens. Any advice appreciated :)

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Differential Control of Air Conditioner

#14 Post by gregoinc » 03 Feb 2019, 04:39

Cut down the code to this...

Code: Select all

on Temp2#Temperature do
   if [Temp2#Temperature] > [Temp1#Temperature] and [Temp1#Temperature] > 25
    Event,StartHP
   endif
endon

on Temp1#Temperature do
   if [Temp1#Temperature] > 27
    Event,StartHP
   endif
endon

On StartHP Do
 heatpumpir,daikin,1,3,0,24,4,2
EndOn
And it works... but without the variable code in StartHP it keeps sending the heatpumpir command.

So perhaps needs another way of managing variables??? Guidance appreciated ;)

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Differential Control of Air Conditioner

#15 Post by gregoinc » 04 Feb 2019, 03:19

To close this out as Ive not had any other feedback, I found the 'Let' command didn't work for some reason? So I went back to the TaskValueSet with a dummy device which works. Still have some looping challenges to clean up in the rules coding, but will start a seperate thread under the software section to get some ideas/suggestions.

Big thanks to Grovkillen :)

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Differential Control of Air Conditioner

#16 Post by grovkillen » 04 Feb 2019, 05:36

Glad to have helped. :)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests