Does 2 into 1 really work?

I have been running 2 separate esp32 units for some time, but advice I received in this post on the forum has made me think it might be time to go from 2 to 1 unit.

Here’s the board I am considering using…

The KC868-A4 board seems to have most of the options I need, so should be a good candidate to combine the code below.

Air-Conditioner code…

esphome:
  name: esp5-studio-ac
  platform: ESP32
  board: esp32doit-devkit-v1
  on_boot:
  - wait_until:
      condition: api.connected
  - delay: 2s
  - script.stop: ac_timer
  - climate.control:
      id: ac_climate_id
      mode: 'off'
  - mqtt.publish:
      topic: HomeAssistant/Studio/Aircon/Status
      payload: "OFF"

# Enable logging
logger:
#  level: VERBOSE

# Enable Home Assistant API
api:
  reboot_timeout: 0s

ota:
  password: !secret esp5-studio-ac-ota

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-Ir-Test Fallback Hotspot"
    password: "<REDACTED>"

captive_portal:

status_led:
  pin: GPIO2

#Temperature Sensor Pin
dallas:
  - pin: 23
    update_interval: 30s

mqtt:
#  broker: !secret mqtt_broker
  broker: !secret mqtt_broker_new
  username: !secret mqtt_login
  password: !secret mqtt_passwd
  port: 1883
  reboot_timeout: 0s
  keepalive: 60s
  discovery: false

# IR TRansmitter entry
remote_transmitter:
  pin: GPIO5
  id: ir_transmit
  carrier_duty_percent: 50%

climate:
  - platform: daikin
    name: "Aircon Studio"
    id: ac_climate_id
    supports_heat: false
    transmitter_id: ir_transmit

script:
  - id: ac_timer
    then:
      - binary_sensor.template.publish:
          id: timer_status
          state: ON
      - logger.log: "AC Timer is ON"
      - delay: 20min
      - binary_sensor.template.publish:
          id: timer_status
          state: OFF
      - logger.log: "AC Timer is OFF"

binary_sensor:
  - platform: template
    id: ac_climate_mgmt
    name: "Studio AC Climate"
    on_press:
      then:
          - climate.control:
              id: ac_climate_id
              mode: COOL
              fan_mode: AUTO
              target_temperature: 23°C
          - mqtt.publish:
              topic: HomeAssistant/Studio/Aircon/Status
              payload: "ON"
          - logger.log: "AC is ON"
    on_release:
      then:
          - climate.control:
              id: ac_climate_id
              mode: 'off'
          - mqtt.publish:
              topic: HomeAssistant/Studio/Aircon/Status
              payload: "OFF"
          - logger.log: "AC is OFF"
  - platform: template
    id: out_ac_temp_status
  
  - platform: template
    id: timer_status

sensor:
# Studio Inside temperature sensor
  - platform: dallas
    id: in_ac_dallas
    resolution: 12
    address: 0x2401204FD9433118
    name: "Studio AC Inside Temperature"
    on_value:
      then:
      - if:
          condition:
              # Is the inside temp higher than 24
              - lambda: 'return id(in_ac_dallas).state > 24;'
          then:
              # Open the damper
              - binary_sensor.template.publish:
                  id: ac_climate_mgmt
                  state: on
              - script.execute: ac_timer
              - logger.log: "Telling Climate to START"
          
      - if:
          condition:
            and:
              # Is the Outside temp under 18
              - lambda: 'return id(out_temp_studio).state < 18;'
              # Is the inside temp lower than 23
              - lambda: 'return id(in_ac_dallas).state < 23;'
              - binary_sensor.is_off: timer_status
          then:
              - binary_sensor.template.publish:
                  id: ac_climate_mgmt
                  state: off
              - script.stop: ac_timer
              - logger.log: "Telling Climate to STOP"

# Studio Outside Temperature from HA  
  - platform: homeassistant
    id: out_temp_studio
    name: "Studio Outside Temperature"
    entity_id: sensor.studio_temp_out

And the fresh air cooling code…

esphome:
  name: "esp1-studio-climate"
  platform: esp32
  board: az-delivery-devkit-v4
  on_boot:
    - lambda: 'id(studio_fan_climate).mode = climate::CLIMATE_MODE_COOL;'

# Enable logging
logger:
#  level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "<REDACTED>"

ota:
  password: "<REDACTED>"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "esp1-studio-climate hot spot"
    password: "<REDACTED>"

captive_portal:

# MQTT Interface
mqtt:
#  broker: !secret mqtt_broker
  broker: !secret mqtt_broker_new
  username: !secret mqtt_login
  password: !secret mqtt_passwd
  port: 1883
  reboot_timeout: 0s
  keepalive: 60s
  discovery: false
  on_message:
    - topic: esp5-studio-ac/binary_sensor/studio_ac_climate/state
      payload: "OFF"
      qos: 0
      then:
        - binary_sensor.template.publish:
            id: ac_status
            state: off
        - logger.log: "The AC is OFF"
    - topic: esp5-studio-ac/binary_sensor/studio_ac_climate/state
      payload: "ON"
      qos: 0
      then:
        - binary_sensor.template.publish:
            id: ac_status
            state: on
        - logger.log: "The AC is ON"

#Temperature Sensor Pin
dallas:
  - pin: 18
    update_interval: 30s

#Relay switches
switch:
  - platform: gpio
    pin: 
      number: 25
      inverted: True
    id: studio_damper_sw
    name: "Studio Damper Switch"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 26
      inverted: True
    id: studio_fan_sw
    name: "Studio Fan Switch"
    restore_mode: RESTORE_DEFAULT_OFF

# Binary Sensors
binary_sensor:

# AC status
  - platform: template
    id: ac_status
    on_press:
      - binary_sensor.template.publish:
          id: climate_status
          state: off
    on_release:
      - binary_sensor.template.publish:
          id: climate_status
          state: on
  - platform: template
    id: climate_status
    on_press:
      - climate.control:
          id: studio_fan_climate
          mode: 'cool'
      - switch.turn_on: studio_damper_sw
    on_release:
      - climate.control:
          id: studio_fan_climate
          mode: 'off'
      - switch.turn_off: studio_damper_sw

# Studio Air Conditioner Status from HA  
  - platform: homeassistant
    id: studio_ac_climate
    name: "Studio AC Status from HA"
    entity_id: binary_sensor.studio_ac_climate

# Studio Temperature Sensors
sensor:

# Studio DHT Inside Temperature
  - platform: dht
    pin: 17
    model: DHT11
    temperature:
      name: studio_dht_temp_in
      id: studio_dht_temp_in
    humidity:
      name: studio_dht_hum_in
      id: studio_dht_hum_in
    update_interval: 30s

# Studio Dallas Inside Temperature
  - platform: dallas
    name: studio_temp_in
    id: studio_temp_in
    resolution: 12
    address: 0x1101143025227D28

# Studio Outside Temperature
  - platform: dallas
    name: studio_temp_out
    id: studio_temp_out
    resolution: 12
    address: 0xE602131B13F9AA28
    on_value:
        then:
          - if:
              condition:
                and:
                  # Is the outside temp below 18 and the AC off
                  - binary_sensor.is_off: studio_ac_climate
                  - lambda: 'return id(studio_temp_out).state < 18;'
              then:
                  # Open the damper
                  - binary_sensor.template.publish:
                     id: climate_status
                     state: on
                  - mqtt.publish:
                     topic: HomeAssistant/Studio/Damper/Status
                     payload: "1"
                  - logger.log: "The damper and climate is active"
          - if:
              condition:
                or:
                  # Is the outside temp above 18 or the AC on
                  - binary_sensor.is_on: ac_status
                  - lambda: 'return id(studio_temp_out).state > 18;'
              then:
                  - binary_sensor.template.publish:
                     id: climate_status
                     state: off
                  - mqtt.publish:
                     topic: HomeAssistant/Studio/Damper/Status
                     payload: "0"
                  - logger.log: "The damper and climate is off"

climate:
  - platform: thermostat
    name: "Studio Climate Controller"
    sensor: studio_temp_in
    min_cooling_off_time: 120s
    min_cooling_run_time: 120s
    min_idle_time: 30s
    id: studio_fan_climate
    cool_action:
      - switch.turn_on: studio_fan_sw
      - logger.log: "The fan is now on"
      - mqtt.publish:
          topic: HomeAssistant/Studio/Fan/Status
          payload: "1"
    idle_action:
      - switch.turn_off: studio_fan_sw
      - logger.log: "The fan is now off"
      - mqtt.publish:
          topic: HomeAssistant/Studio/Fan/Status
          payload: "0"
    default_preset: Studio
    preset:
      - name: Studio
        default_target_temperature_high: 22 °C
        mode: COOL

My plan was to combine the code in both yaml files, excluding all the unnecessary portions. Please excuse my yaml code… I know it is less than good quality.

I wondered… might there be a better approach… a better way… perhaps using a thermostat, or some other way of combining the two cooling types?

Would be very interested in thinking from the guru’s here… if there’s an easier way to build a single unit that handles climate control via two sources… AC and free cooling.

So I decided to start with the climate section in the code as that is likely to be the greatest challenge. I know there will be other challenges with MQTT and such, but I figure if I have the climate working it should be good.

First, combine the climate from both yaml codes…

# Studio Climate Control
climate:
  - platform: daikin
    name: "Studio Aircon"
    id: daikin_ac
    supports_heat: false
    transmitter_id: infrared_transmit

  - platform: thermostat
    name: "Studio Fan Controller"
    sensor: studio_in_temp
    min_cooling_off_time: 120s
    min_cooling_run_time: 120s
    min_idle_time: 30s
    id: studio_fan_control
    cool_action:
      - switch.turn_on: studio_fan_rly
      - logger.log: "The studio fan is now on"
      - mqtt.publish:
          topic: HomeAssistant/Studio/Fan/Status
          payload: "ON"
    idle_action:
      - switch.turn_off: studio_fan_rly
      - logger.log: "The studio fan is now off"
      - mqtt.publish:
          topic: HomeAssistant/Studio/Fan/Status
          payload: "OFF"
    default_preset: Studio
    preset:
      - name: Studio
        default_target_temperature_high: 22 °C
        mode: COOL

Next, workout how to individually activate each climate section based on inside and outside temperatures.

Getting much closer now… except I think I might have a formatting error. My code is below, but immediately below is a screen grab of what esphome is reporting?

Esphome wont let me compile it?

esphome_compile

esphome:
  name: esp-a4-studio-climate
  platform: esp32
  board: esp32dev

# Enable logging
logger:
  level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "<redacted>"

ota:
  password: "<redacted>"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-A4-Studio-Climate"
    password: "<redacted>"

captive_portal:

dallas:
  - pin: 13
    update_interval: 30s

# IR TRansmitter entry
remote_transmitter:
  pin:
    number: 22
  id: infrared_transmit
  carrier_duty_percent: 50%

# MQTT Interface
mqtt:
  broker: !secret mqtt_broker_new
  username: !secret mqtt_login
  password: !secret mqtt_passwd
  port: 1883
  reboot_timeout: 0s
  keepalive: 60s
  discovery: false

#Relay switches
switch:
  - platform: gpio
    pin: 
      number: 2
      ignore_strapping_warning: true
      inverted: false
    id: studio_damper_rly
    name: "Studio Damper Relay"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 15
      ignore_strapping_warning: true
      inverted: false
    id: studio_fan_rly
    name: "Studio Fan Relay"
    restore_mode: RESTORE_DEFAULT_OFF

# Studio Dallas Inside Temperature
sensor:
  - platform: dallas
    name: 'Studio Inside Temperature'
    id: studio_in_temp
    resolution: 12
    address: 0x7a01204fd46dcb28

interval:
  - interval: 1min
    then:
    - if:
          condition:
              # Is the inside temp higher than 24
              - lambda: 'return id(studio_in_temp).state > 24;'
          then:
              # Turn off the fan and close the damper
              - binary_sensor.template.publish:
                  id: studio_fan_status
                  state: off
              - mqtt.publish:
                  # remove test once confirmed working
                  topic: test_HomeAssistant/Studio/Damper/Status
                  payload: "OFF"
              - logger.log: "The damper and climate is OFF"
              # Start the Air Conditioner
              - binary_sensor.template.publish:
                  id: aircon_climate_mgmt
                  state: on
              - logger.log: "Telling Air Conditioner to START"

    - if:
          condition:
            and:
              # Is the Outside temp under 18
              - lambda: 'return id(out_temp_studio).state < 18;'
              # Is the inside temp lower than 23
              - lambda: 'return id(studio_in_temp).state < 23;'
          then:
              # Stop the Air Conditioner     
              - binary_sensor.template.publish:
                  id: aircon_climate_mgmt
                  state: off
              - logger.log: "Telling Air Conditioner to STOP"         
              # Turn on the fan and open the damper
              - binary_sensor.template.publish:
                  id: studio_fan_status
                  state: on
              - mqtt.publish:
                  # remove test once confirmed working
                  topic: test_HomeAssistant/Studio/Damper/Status
                  payload: "ON"
              - logger.log: "The damper and fan is active" 

binary_sensor:
  - platform: template
    id: aircon_climate_mgmt
    name: "Studio AC Climate"
    on_press:
      then:
          - climate.control:
              id: ac_climate_id
              mode: COOL
              fan_mode: AUTO
              target_temperature: 23°C
          - mqtt.publish:
              # remove test once confirmed working
              topic: test_HomeAssistant/Studio/Aircon/Status
              payload: "ON"
          - logger.log: "AC is ON"
    on_release:
      then:
          - climate.control:
              id: ac_climate_id
              mode: 'off'
          - mqtt.publish:
              # remove test once confirmed working
              topic: test_HomeAssistant/Studio/Aircon/Status
              payload: "OFF"
          - logger.log: "AC is OFF"

- platform: template
    id: studio_fan_status
    on_press:
      - switch.turn_on: studio_damper_rly
      - climate.control:
          id: studio_fan_climate
          mode: 'cool'
    on_release:
      - climate.control:
          id: studio_fan_climate
          mode: 'off'
      - switch.turn_off: studio_damper_rly

# Studio Climate Control
climate:
  - platform: daikin
    name: "Studio Aircon Control"
    id: daikin_ac
    supports_heat: false
    transmitter_id: infrared_transmit

  - platform: thermostat
    name: "Studio Fan Control"
    sensor: studio_in_temp
    min_cooling_off_time: 120s
    min_cooling_run_time: 120s
    min_idle_time: 30s
    id: studio_fan_control
    cool_action:
      - switch.turn_on: studio_fan_rly
      - logger.log: "The studio fan is ON"
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Fan/Status
          payload: "ON"
    idle_action:
      - switch.turn_off: studio_fan_rly
      - logger.log: "The studio fan is OFF"
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Fan/Status
          payload: "OFF"
    default_preset: Studio
    preset:
      - name: Studio
        default_target_temperature_high: 22 °C
        mode: COOL

I am obviously doing something wrong, any suggestions appreciated.

Why? What error is printed when you want to compile?

Hey There… thanks for the response. Apology, should have added the error.

Spits out below, but from experience the error is innocuous and is normally due to another mistake I have made.

INFO ESPHome 2023.12.8
INFO Reading configuration /config/esphome/esp-a4-studio-climate.yaml...
ERROR Error while reading config: Invalid YAML syntax:

while parsing a block mapping
  in "/config/esphome/esp-a4-studio-climate.yaml", line 1, column 1:
    esphome:
    ^

I’ll keep digging… I am sure it will be human error on my part :roll_eyes:

Maybe some special hidden symbol is present - mostly due to copy and paste.

You can try deleting the first row and write esphome: again to see if it makes a difference.

Ended up finding it… simple fat finger mistake on my behalf.

So below is the latest code… but being new code the results are not great. I would give my left arm (I type one fingered with my right arm so) for a thermostat function that would handle an AC and a fan… anyway, I think I am over complicating below.

Open to ideas, thoughts, suggestions, criticisms… :yum:

esphome:
  name: esp-a4-studio-climate
  platform: esp32
  board: esp32dev

# Enable logging
logger:
#  level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "<REDACTED>"

ota:
  password: "<REDACTED>"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-A4-Studio-Climate"
    password: "<REDACTED>"

captive_portal:

dallas:
  - pin: 13
    update_interval: 15s

# IR TRansmitter entry
remote_transmitter:
  pin:
    number: 22
  id: infrared_transmit
  carrier_duty_percent: 50%

# MQTT Interface
mqtt:
  broker: !secret mqtt_broker_new
  username: !secret mqtt_login
  password: !secret mqtt_passwd
  port: 1883
  reboot_timeout: 0s
  keepalive: 60s
  discovery: false

#Relay switches
switch:
  - platform: gpio
    pin: 
      number: 2
      ignore_strapping_warning: true
      inverted: false
    id: studio_damper_rly
    name: "Studio Damper Relay"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 15
      ignore_strapping_warning: true
      inverted: false
    id: studio_fan_rly
    name: "Studio Fan Relay"
    restore_mode: RESTORE_DEFAULT_OFF

# Studio Dallas Inside Temperature
sensor:
  - platform: dallas
    name: 'Studio Inside Temperature'
    id: studio_in_temp
    resolution: 12
    address: 0x7a01204fd46dcb28
  - platform: dallas
    name: 'Studio Outside Temperature'
    id: out_temp_studio
    resolution: 12
    address: 0x120120500dc9ab28

interval:
  - interval: 30sec
    then:
    - if:
          condition:
              # Is the inside temp higher than 24
              - lambda: 'return id(studio_in_temp).state > 24;'
          then:
              # Turn off the fan and close the damper
              - binary_sensor.template.publish:
                  id: studio_fan_status
                  state: off
              - mqtt.publish:
                  # remove test once confirmed working
                  topic: test_HomeAssistant/Studio/Damper/Status
                  payload: "OFF"
              - logger.log: "The damper and climate is OFF"
              # Start the Air Conditioner
              - binary_sensor.template.publish:
                  id: aircon_climate_mgmt
                  state: on
              - logger.log: "Telling Air Conditioner to START"
    - if:
          condition:
           and:
              # Is the Outside temp under 18 and inside under 23
              - lambda: 'return id(out_temp_studio).state < 18;'
              - lambda: 'return id(studio_in_temp).state < 23;'
          then:
              # Stop the Air Conditioner     
              - binary_sensor.template.publish:
                  id: aircon_climate_mgmt
                  state: off
              - logger.log: "Telling Air Conditioner to STOP"         
              # Turn on the fan and open the damper
              - binary_sensor.template.publish:
                  id: studio_fan_status
                  state: on
              - mqtt.publish:
                  # remove test once confirmed working
                  topic: test_HomeAssistant/Studio/Damper/Status
                  payload: "ON"
              - logger.log: "The damper and fan is active" 

binary_sensor:
  - platform: template
    id: aircon_climate_mgmt
    name: "Studio AC Climate"
    on_press:
      then:
          - climate.control:
              id: daikin_ac
              mode: COOL
              fan_mode: AUTO
              target_temperature: 23°C
          - mqtt.publish:
              # remove test once confirmed working
              topic: test_HomeAssistant/Studio/Aircon/Status
              payload: "ON"
          - logger.log: "AC is ON"
    on_release:
      then:
          - climate.control:
              id: daikin_ac
              mode: 'off'
          - mqtt.publish:
              # remove test once confirmed working
              topic: test_HomeAssistant/Studio/Aircon/Status
              payload: "OFF"
          - logger.log: "AC is OFF"

  - platform: template
    id: studio_fan_status
    on_press:
      - switch.turn_on: studio_damper_rly
      - climate.control:
          id: studio_fan_control
          mode: 'cool'
    on_release:
      - climate.control:
          id: studio_fan_control
          mode: 'off'
      - switch.turn_off: studio_damper_rly

# Studio Climate Control
climate:
  - platform: daikin
    name: "Studio Aircon Control"
    id: daikin_ac
    supports_heat: false
    transmitter_id: infrared_transmit

  - platform: thermostat
    name: "Studio Fan Control"
    sensor: studio_in_temp
    min_cooling_off_time: 120s
    min_cooling_run_time: 120s
    min_idle_time: 30s
    id: studio_fan_control
    cool_action:
      - switch.turn_on: studio_fan_rly
      - logger.log: "The studio fan is ON"
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Fan/Status
          payload: "ON"
    idle_action:
      - switch.turn_off: studio_fan_rly
      - logger.log: "The studio fan is OFF"
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Fan/Status
          payload: "OFF"
    default_preset: Studio
    preset:
      - name: Studio
        default_target_temperature_high: 22 °C
        mode: COOL

esphome native api?

Had originally thought of that… but I designed this to be completely independent of HA, so if all else fails the ESP32 controls the air conditioner turning on… and the equipment running in my lab doesn’t cook :stuck_out_tongue_winking_eye:

I only make use of the native api still my esphome nodes with climate components (and others) are indepenent of HA. Isn’t a mqtt broker an extra (another) point of failure?

I completely agree. Unfortunately I am so deep into MQTT now it’s not on my radar to untangle myself :frowning:

Good thing when changing/migrating from mqtt to native api nothing new is to learn. The api is essentially a zero setup after authentication. You also can start slowly just moving one node - just take care that they don’t coexist with both protocols (remove mqtt: line when adding the api: to your node).

Good thing with the api is that you save a lots of time which you can use for tinkering instead!

Sounds interesting, do you have an example code I could look at?

Ok, latest installment / iteration of my journey joining the two versions of code together.

I still have testing to do, so it could be a fail… hope not but you never know. Wish I had something that simulate temperature sensors, or simulate temperature.

esphome:
  name: esp-a4-studio-climate
  platform: esp32
  board: esp32dev
  on_boot:
  - delay: 2s
  - binary_sensor.template.publish:
      id: aircon_climate_mgmt
      state: off
  - logger.log: "Telling Air Conditioner to STOP"

# Enable logging
logger:
#  level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "<redacted>"

ota:
  password: "<redacted>"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-A4-Studio-Climate"
    password: "<redacted>"

captive_portal:

dallas:
  - pin: 13
    update_interval: 30s

# IR TRansmitter entry
remote_transmitter:
  pin:
    number: 22
  id: infrared_transmit
  carrier_duty_percent: 50%

# MQTT Interface
mqtt:
  broker: !secret mqtt_broker_new
  username: !secret mqtt_login
  password: !secret mqtt_passwd
  port: 1883
  reboot_timeout: 0s
  keepalive: 60s
  discovery: false

output:
  - platform: ledc
    pin: GPIO18
    id: rtttl_out

rtttl:
  output: rtttl_out
  on_finished_playback:
    - logger.log: 'Song ended!'

button:
  - platform: template
    name: "Play Module!"
    on_press:
      then:
        - rtttl.play: 'mission_imp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d'

  - platform: template
    name: "Stop !"  
    on_press:
      then:
        - rtttl.stop

#Relay switches
switch:
  - platform: gpio
    pin: 
      number: 2
      ignore_strapping_warning: true
      inverted: false
    id: studio_damper_rly
    name: "Studio Damper Relay"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 15
      ignore_strapping_warning: true
      inverted: false
    id: studio_fan_rly
    name: "Studio Fan Relay"
    restore_mode: RESTORE_DEFAULT_OFF

# Studio Dallas Inside Temperature
sensor:
  - platform: dallas
    name: 'Studio Inside Temperature'
    id: in_temp_studio
    resolution: 12
    address: 0x7a01204fd46dcb28
  - platform: dallas
    name: 'Studio Outside Temperature'
    id: out_temp_studio
    resolution: 12
    address: 0x120120500dc9ab28
    filters:
    - sliding_window_moving_average:
        window_size: 5
        send_every: 5

interval:
  - interval: 30sec
    then:
    - if:
          condition:
              # Is the inside temp higher than 24
              - lambda: 'return id(in_temp_studio).state > 24;'
          then:
              # Turn off the Fan
              - binary_sensor.template.publish:
                  id: studio_fan_status
                  state: off
              # Close the Damper
              - binary_sensor.template.publish:
                  id: studio_damper_status
                  state: off
              # Start the Air Conditioner
              - binary_sensor.template.publish:
                  id: aircon_climate_mgmt
                  state: on
              - logger.log: "Telling Air Conditioner to START"
              # test buzzer sound
              - rtttl.play: 'two_short:d=4,o=5,b=100:16e6,16e6'
    - if:
          condition:
           and:
              # Is the Outside temp under 18 and inside under 23
              - lambda: 'return id(out_temp_studio).state < 18;'
              - lambda: 'return id(in_temp_studio).state < 23;'
          then:
              # Stop the Air Conditioner     
              - binary_sensor.template.publish:
                  id: aircon_climate_mgmt
                  state: off
              - logger.log: "Telling Air Conditioner to STOP"
              # test buzzer sound
              - rtttl.play: 'two_short:d=4,o=5,b=100:16e6,16e6,16e6'
              # Open the Damper
              - binary_sensor.template.publish:
                  id: studio_damper_status
                  state: on
              # Turn on the Fan
              - binary_sensor.template.publish:
                  id: studio_fan_status
                  state: on
              
binary_sensor:
  - platform: template
    id: aircon_climate_mgmt
    name: "Studio AC Management"
    on_press:
      then:
          - climate.control:
              id: daikin_ac
              mode: COOL
              fan_mode: AUTO
              target_temperature: 23°C
          - mqtt.publish:
              # remove test once confirmed working
              topic: test_HomeAssistant/Studio/Aircon/Status
              payload: "ON"
          - logger.log: "AC is ON"
    on_release:
      then:
          - climate.control:
              id: daikin_ac
              mode: 'off'
          - mqtt.publish:
              # remove test once confirmed working
              topic: test_HomeAssistant/Studio/Aircon/Status
              payload: "OFF"
          - logger.log: "AC is OFF"

  - platform: template
    id: studio_fan_status
    on_press:
      - climate.control:
          id: studio_fan_control
          mode: 'cool'
    on_release:
      - climate.control:
          id: studio_fan_control
          mode: 'off'

  - platform: template
    id: studio_damper_status
    on_press:
      - switch.turn_on: studio_damper_rly
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Damper/Status
          payload: "ON"
      - logger.log: "The damper is OPEN" 
    on_release:
      - switch.turn_off: studio_damper_rly
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Damper/Status
          payload: "OFF"
      - logger.log: "The damper is CLOSED" 

# Studio Climate Control
climate:
  - platform: daikin
    name: "Daikin Aircon"
    id: daikin_ac
    supports_heat: false
    transmitter_id: infrared_transmit

  - platform: thermostat
    name: "Studio Fan Control"
    sensor: in_temp_studio
    min_cooling_off_time: 120s
    min_cooling_run_time: 120s
    min_idle_time: 30s
    id: studio_fan_control
    cool_action:
      - switch.turn_on: studio_fan_rly
      - logger.log: "The studio fan is ON"
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Fan/Status
          payload: "ON"
    idle_action:
      - switch.turn_off: studio_fan_rly
      - logger.log: "The studio fan is OFF"
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Fan/Status
          payload: "OFF"
    default_preset: Studio
    preset:
      - name: Studio
        default_target_temperature_high: 23 °C
        mode: COOL

Please forgive my really bad yaml coding, I am learning as I go :slight_smile:

Api and mqtt for one esphome node? Technically possible but why if you have things locally and want to avoid extra point of failures (broker)?

Template number?

Thanks for the feedback.

The mqtt traffic is really used to provide external telemetry… and the esp32 is not reliant upon the mqtt traffic to operate.

That is really interesting… and when I have the time I will look into it.

Slowly but surely chipping away at the bugs… getting much closer now, but some gremlins remain in turning off the AC unit in some conditions. I’ll keep running the testing and see how things go.

Latest code…

esphome:
  name: esp-a4-studio-climate
  platform: esp32
  board: esp32dev
  on_boot:
  - delay: 2s
  - binary_sensor.template.publish:
      id: aircon_climate_mgmt
      state: off
  - logger.log: "Telling Air Conditioner to STOP"

# Enable logging
logger:
#  level: INFO

# Enable Home Assistant API
api:
  encryption:
    key: "<redacted>"

ota:
  password: "<redacted>"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-A4-Studio-Climate"
    password: "<redacted>"

captive_portal:

dallas:
  - pin: 13
    update_interval: 30s

# IR TRansmitter entry
remote_transmitter:
  pin:
    number: 22
  id: infrared_transmit
  carrier_duty_percent: 50%

# MQTT Interface
mqtt:
  broker: !secret mqtt_broker_new
  username: !secret mqtt_login
  password: !secret mqtt_passwd
  port: 1883
  reboot_timeout: 0s
  keepalive: 60s
  discovery: false

output:
  - platform: ledc
    pin: GPIO18
    id: rtttl_out

rtttl:
  output: rtttl_out
  on_finished_playback:
    - logger.log: 'Song ended!'

button:
  - platform: template
    name: "Play Module!"
    on_press:
      then:
        - rtttl.play: 'mission_imp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d'

  - platform: template
    name: "Stop !"  
    on_press:
      then:
        - rtttl.stop

#Relay switches
switch:
  - platform: gpio
    pin: 
      number: 2
      ignore_strapping_warning: true
      inverted: false
    id: studio_damper_rly
    name: "Studio Damper Relay"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 15
      ignore_strapping_warning: true
      inverted: false
    id: studio_fan_rly
    name: "Studio Fan Relay"
    restore_mode: RESTORE_DEFAULT_OFF

# Studio Dallas Inside Temperature
sensor:
  - platform: dallas
    name: 'Studio Inside Temperature'
    id: in_temp_studio
    resolution: 12
    address: 0x7a01204fd46dcb28
  - platform: dallas
    name: 'Studio Outside Temperature'
    id: out_temp_studio
    resolution: 12
    address: 0x120120500dc9ab28
    filters:
    - sliding_window_moving_average:
        window_size: 5
        send_every: 5

interval:
  - interval: 30sec
    then:
    - if:
          condition:
           and:
              # Is the Inside temp over 24 and the AC is off
              - lambda: 'return id(in_temp_studio).state > 24;'
              - binary_sensor.is_off: aircon_climate_mgmt
          then:
              # Turn off the Fan
              - binary_sensor.template.publish:
                  id: studio_fan_status
                  state: off
              # Close the Damper
              - binary_sensor.template.publish:
                  id: studio_damper_status
                  state: off
              # Start the Air Conditioner
              - binary_sensor.template.publish:
                  id: aircon_climate_mgmt
                  state: on
              - logger.log: "Telling Air Conditioner to START"
              # test buzzer sound
#              - rtttl.play: 'two_short:d=4,o=5,b=100:16e6,16e6'

    - if:
          condition:
           and:
              # Is the Outside temp under 18 and inside under 23
              - lambda: 'return id(out_temp_studio).state < 18;'
              - lambda: 'return id(in_temp_studio).state < 22;'
          then:
              # Stop the Air Conditioner     
              - if:
                      condition:
                       - binary_sensor.is_on: aircon_climate_mgmt
                      then:
                          - binary_sensor.template.publish:
                              id: aircon_climate_mgmt
                              state: off
                          - logger.log: "Telling Air Conditioner to STOP"
                      else:
                          # test buzzer sound
#                          - rtttl.play: 'two_short:d=4,o=5,b=100:16e6,16e6,16e6'
                          # Open the Damper
                          - binary_sensor.template.publish:
                              id: studio_damper_status
                              state: on
                          # Turn on the Fan
                          - binary_sensor.template.publish:
                              id: studio_fan_status
                              state: on
              
binary_sensor:
  - platform: template
    id: aircon_climate_mgmt
    name: "Studio AC Management"
    on_press:
      then:
          - climate.control:
              id: daikin_ac
              mode: COOL
              fan_mode: AUTO
              target_temperature: 23°C
          - mqtt.publish:
              # remove test once confirmed working
              topic: test_HomeAssistant/Studio/Aircon/Status
              payload: "ON"
          - logger.log: "AC is ON"
    on_release:
      then:
          - climate.control:
              id: daikin_ac
              mode: 'off'
          - mqtt.publish:
              # remove test once confirmed working
              topic: test_HomeAssistant/Studio/Aircon/Status
              payload: "OFF"
          - logger.log: "AC is OFF"

  - platform: template
    id: studio_fan_status
    on_press:
      - climate.control:
          id: studio_fan_control
          mode: 'cool'
    on_release:
      - climate.control:
          id: studio_fan_control
          mode: 'off'

  - platform: template
    id: studio_damper_status
    on_press:
      - switch.turn_on: studio_damper_rly
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Damper/Status
          payload: "ON"
      - logger.log: "The damper is OPEN" 
    on_release:
      - switch.turn_off: studio_damper_rly
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Damper/Status
          payload: "OFF"
      - logger.log: "The damper is CLOSED" 

# Studio Climate Control
climate:
  - platform: daikin
    name: "Daikin Aircon"
    id: daikin_ac
    supports_heat: false
    transmitter_id: infrared_transmit

  - platform: thermostat
    name: "Studio Fan Control"
    sensor: in_temp_studio
    min_cooling_off_time: 120s
    min_cooling_run_time: 120s
    min_idle_time: 30s
    id: studio_fan_control
    cool_action:
      - switch.turn_on: studio_fan_rly
      - logger.log: "The studio fan is ON"
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Fan/Status
          payload: "ON"
    idle_action:
      - switch.turn_off: studio_fan_rly
      - logger.log: "The studio fan is OFF"
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Fan/Status
          payload: "OFF"
    default_preset: Studio
    preset:
      - name: Studio
        default_target_temperature_high: 23 °C
        mode: COOL

The section below is the focus of my debugging and testing…

interval:
  - interval: 30sec
    then:
    - if:
          condition:
           and:
              # Is the Inside temp over 24 and the AC is off
              - lambda: 'return id(in_temp_studio).state > 24;'
              - binary_sensor.is_off: aircon_climate_mgmt
          then:
              # Turn off the Fan
              - binary_sensor.template.publish:
                  id: studio_fan_status
                  state: off
              # Close the Damper
              - binary_sensor.template.publish:
                  id: studio_damper_status
                  state: off
              # Start the Air Conditioner
              - binary_sensor.template.publish:
                  id: aircon_climate_mgmt
                  state: on
              - logger.log: "Telling Air Conditioner to START"
              # test buzzer sound
#              - rtttl.play: 'two_short:d=4,o=5,b=100:16e6,16e6'

    - if:
          condition:
           and:
              # Is the Outside temp under 18 and inside under 23
              - lambda: 'return id(out_temp_studio).state < 18;'
              - lambda: 'return id(in_temp_studio).state < 22;'
          then:
              # Stop the Air Conditioner     
              - if:
                      condition:
                       - binary_sensor.is_on: aircon_climate_mgmt
                      then:
                          - binary_sensor.template.publish:
                              id: aircon_climate_mgmt
                              state: off
                          - logger.log: "Telling Air Conditioner to STOP"
                      else:
                          # test buzzer sound
#                          - rtttl.play: 'two_short:d=4,o=5,b=100:16e6,16e6,16e6'
                          # Open the Damper
                          - binary_sensor.template.publish:
                              id: studio_damper_status
                              state: on
                          # Turn on the Fan
                          - binary_sensor.template.publish:
                              id: studio_fan_status
                              state: on

Any suggestions or tips appreciated.

Thanks to the awesome Samuel @ssieb on the ESPHome Discord I believe below is the final yaml code for my man cave climate management.

The code works really well and I appreciate Samuel sticking with me through my crazy questions, I have learnt a lot from the process.

Highly recommend you check out the ESPHome Discord, there are lots of people like Samuel willing to help.

I am posting the code here in the hope that it might help one of you in the future.

esphome:
  name: esp-a4-studio-climate
  platform: esp32
  board: esp32dev
  on_boot:
  - delay: 2s
  - climate.control:
      id: daikin_ac
      mode: 'off'
  - logger.log: "Telling Air Conditioner to STOP"

# Enable logging
logger:
#  level: INFO

# Enable Home Assistant API
api:
  encryption:
    key: "<redacted>"

ota:
  password: "<redacted>"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-A4-Studio-Climate"
    password: "<redacted>"

captive_portal:

dallas:
  - pin: 13
    update_interval: 30s

# IR Transmitter entry
remote_transmitter:
  pin:
    number: 22
  id: infrared_transmit
  carrier_duty_percent: 50%

# MQTT Interface
mqtt:
  broker: !secret mqtt_broker_new
  username: !secret mqtt_login
  password: !secret mqtt_passwd
  port: 1883
  reboot_timeout: 0s
  keepalive: 60s
  discovery: false

# rtttl output
output:
  - platform: ledc
    pin: GPIO18
    id: rtttl_out

rtttl:
  output: rtttl_out
  on_finished_playback:
    - logger.log: 'Song ended'

button:
  - platform: template
    name: "Play Module"
    on_press:
      then:
        - rtttl.play: 'mission_imp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d'

  - platform: template
    name: "Stop"  
    on_press:
      then:
        - rtttl.stop

#Relay switches
switch:
  - platform: template
    id: do_cooling
    optimistic: true
  - platform: gpio
    pin: 
      number: 2
      ignore_strapping_warning: true
      inverted: false
    id: studio_damper_rly
    name: "Studio Damper Relay"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 15
      ignore_strapping_warning: true
      inverted: false
    id: studio_fan_rly
    name: "Studio Fan Relay"
    restore_mode: RESTORE_DEFAULT_OFF

# Studio Dallas Inside Temperature
sensor:
  - platform: dallas
    name: 'Studio Inside Temperature'
    id: in_temp_studio
    resolution: 12
    address: 0x7a01204fd46dcb28
  - platform: dallas
    name: 'Studio Outside Temperature'
    id: out_temp_studio
    resolution: 12
    address: 0x120120500dc9ab28
    filters:
    - sliding_window_moving_average:
        window_size: 10
        send_every: 5

binary_sensor:
  - platform: template
    id: damper
    lambda: return (id(out_temp_studio).state < 18) && (id(in_temp_studio).state <= 24);
    on_press:
      - logger.log: "Telling Damper to OPEN"
      - switch.turn_on: studio_damper_rly
    on_release:
      - logger.log: "Telling Damper to CLOSE"
      - switch.turn_off: studio_damper_rly
  - platform: copy
    id: damper_open
    source_id: damper
    filters:
      - delayed_on: 6sec
  - platform: template
    id: fan
    lambda: return id(do_cooling).state && id(damper_open).state;
    on_press:
      - logger.log: "Telling Fan to START"
      - switch.turn_on: studio_fan_rly
    on_release:
      - logger.log: "Telling Fan to STOP"
      - switch.turn_off: studio_fan_rly
  - platform: template
    id: ac
    lambda: "return (id(do_cooling).state && !id(damper).state);"
    on_press:
      - logger.log: "Telling Air Conditioner to START"
      - climate.control:
          id: daikin_ac
          mode: COOL
          fan_mode: AUTO
          target_temperature: 23°C
    on_release:
      - logger.log: "Telling Air Conditioner to STOP"
      - climate.control:
          id: daikin_ac
          mode: 'off'

# Studio Climate Control
climate:
  - platform: daikin
    name: "Daikin Aircon"
    id: daikin_ac
    supports_heat: false
    transmitter_id: infrared_transmit

  - platform: thermostat
    name: "Fan Climate Control"
    sensor: in_temp_studio
    min_cooling_off_time: 120s
    min_cooling_run_time: 120s
    min_idle_time: 30s
    id: fan_climate_control
    cool_action:
      - switch.turn_on: do_cooling
      - logger.log: "The studio fan is ON"
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Fan/Status
          payload: "ON"
    idle_action:
      - switch.turn_off: do_cooling
      - logger.log: "The studio fan is OFF"
      - mqtt.publish:
          # remove test once confirmed working
          topic: test_HomeAssistant/Studio/Fan/Status
          payload: "OFF"
    default_preset: Studio
    preset:
      - name: Studio
        default_target_temperature_high: 23 °C
        mode: COOL

So it appears my success has been short lived. Let me explain… Most of my testing was done during winter, so activating the air conditioning unit in winter was simulated at best.

Now the whether has become warmer it appears there is a critical oversight in the code. I ended up migrating my code to a KC868-A2 board, mostly because the KC868-A4 board was overkill for what I needed and the KC868-A2 board has an Ethernet port which I wanted. The KC868-A2 board has been stable and reliable, so has proven to be a good choice.

Here’s the KC868-A2 board yaml code…

esphome:
  name: esp-a2-studio-climate
  platform: esp32
  board: esp32dev
  on_boot:
  - delay: 2s
  - climate.control:
      id: fan_climate_control
      target_temperature: 22 °C
  - climate.control:
      id: daikin_ac
      mode: 'off'
  - logger.log: "Telling Air Conditioner to STOP"
  - mqtt.publish:
      topic: HomeAssistant/Studio/Aircon/Status
      payload: "OFF"

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: <REDACTED>

ota:
  platform: esphome
  password: <REDACTED>

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0

# Optional manual IP
  manual_ip:
    static_ip: <REDACTED>
    gateway: <REDACTED>
    subnet: 255.255.255.0

# MQTT Interface
mqtt:
  broker: !secret mqtt_broker
  username: !secret mqtt_login
  password: !secret mqtt_passwd
  port: 1883
  reboot_timeout: 0s
  keepalive: 60s
  discovery: false

i2c:
- id: bus_a
  sda: 4
  scl: 16
  scan: true

# Dallas 1-wire sensors
one_wire:
  - platform: gpio
    pin: 33

# IR TRansmitter entry
remote_transmitter:
  pin:
    number: 14
  id: infrared_transmit
  carrier_duty_percent: 50%

sensor:
  - platform: dallas_temp
    address: 0x1046e67f1f64ff28
    name: "Studio Inside Temp"
    id: a2_in_temp_studio
    resolution: 12
    update_interval: 30s
      
  - platform: dallas_temp
    name: "Studio Outside Temp"
    id: a2_out_temp_studio
    resolution: 12
    address: 0x120120500dc9ab28
    update_interval: 30s
    filters:
    - sliding_window_moving_average:
        window_size: 10
        send_every: 5

#Relay switches
switch:
  - platform: template
    id: do_cooling
    optimistic: true
  - platform: gpio
    pin: 
      number: 15
      ignore_strapping_warning: true
      inverted: false
    id: studio_damper_rly
    name: "Studio Damper Relay"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 2
      ignore_strapping_warning: true
      inverted: false
    id: studio_fan_rly
    name: "Studio Fan Relay"
    restore_mode: RESTORE_DEFAULT_OFF

binary_sensor:
  - platform: template
    id: damper
    lambda: return (id(a2_out_temp_studio).state < 18) && (id(a2_in_temp_studio).state <= 24);
    on_press:
      - logger.log: "Telling Damper to OPEN"
      - switch.turn_on: studio_damper_rly
      - mqtt.publish:
          topic: HomeAssistant/Studio/Damper/Status
          payload: "OPEN"
    on_release:
      - logger.log: "Telling Damper to CLOSE"
      - switch.turn_off: studio_damper_rly
      - mqtt.publish:
          topic: HomeAssistant/Studio/Damper/Status
          payload: "CLOSED"
  - platform: copy
    id: damper_open
    source_id: damper
    filters:
      - delayed_on: 4sec
  - platform: template
    id: fan
    lambda: return id(do_cooling).state && id(damper_open).state;
    on_press:
      - logger.log: "Telling Fan to START"
      - switch.turn_on: studio_fan_rly
      - mqtt.publish:
          topic: HomeAssistant/Studio/Fan/Status
          payload: "OFF"
    on_release:
      - logger.log: "Telling Fan to STOP"
      - switch.turn_off: studio_fan_rly
      - mqtt.publish:
          topic: HomeAssistant/Studio/Fan/Status
          payload: "OFF"
  - platform: template
    id: ac
    lambda: return (id(do_cooling).state && !id(damper).state);
    on_press:
      - logger.log: "Telling Air Conditioner to START"
      - mqtt.publish:
          topic: HomeAssistant/Studio/Aircon/Status
          payload: "ON"
      - climate.control:
          id: daikin_ac
          mode: 'cool'
          fan_mode: AUTO
          target_temperature: 23 °C
      - binary_sensor.template.publish:
          id: studio_ac_status
          state: "ON"
    on_release:
      # Wait until outside temperature is below 18 degrees
      - wait_until:
          condition:
            - lambda: return (id(a2_out_temp_studio).state < 18);
      - logger.log: "Telling Air Conditioner to STOP"
      - mqtt.publish:
          topic: HomeAssistant/Studio/Aircon/Status
          payload: "OFF"      
      - climate.control:
          id: daikin_ac
          mode: 'off'
      - binary_sensor.template.publish:
          id: studio_ac_status
          state: "OFF"
  - platform: template
    name: "Studio Aircon"
    id: studio_ac_status

# Studio Climate Control
climate:
  - platform: daikin
    name: "Daikin Aircon"
    id: daikin_ac
    supports_heat: false
    transmitter_id: infrared_transmit
  - platform: thermostat
    name: "Fan Climate Control"
    sensor: a2_in_temp_studio
    min_cooling_off_time: 300s
    min_cooling_run_time: 300s
    min_idle_time: 30s
    id: fan_climate_control
    cool_action:
      - switch.turn_on: do_cooling
      - logger.log: "The studio fan is ON"
    idle_action:
      - switch.turn_off: do_cooling
      - logger.log: "The studio fan is OFF"
    default_preset: Studio
    preset:
      - name: Studio
        default_target_temperature_high: 22 °C

So what are the issues…

  • When the AC unit is started, it will only run until the room reaches the desired temperature… and then the yaml code turns off the air conditioner.

  • The constant ON/OFF power cycling of the AC unit every few minutes will surely break the AC unit.

  • What needs to happen… when the outside temperature is over 18 degrees, I would expect the AC unit to turn on, and continue to cycle keeping the room in the nominated hysteresis zone. Just like you would on a hot day at home, turn on the AC unit and leave it running.

  • When the temperature drops to below 18 degrees outside the AC unit would be switched off, and the fan/damper can kick in and keep the room ventilated.

So what have I done as a stop gap measure… You will notice the modified code below, where I have implemented a wait_until keeping the AC unit running until the outside temperature drops to below 18 degrees.

- platform: template
    id: ac
    lambda: return (id(do_cooling).state && !id(damper).state);
    on_press:
      - logger.log: "Telling Air Conditioner to START"
      - mqtt.publish:
          topic: HomeAssistant/Studio/Aircon/Status
          payload: "ON"
      - climate.control:
          id: daikin_ac
          mode: 'cool'
          fan_mode: AUTO
          target_temperature: 23 °C
      - binary_sensor.template.publish:
          id: studio_ac_status
          state: "ON"
    on_release:
      # Wait until outside temperature is below 18 degrees
      - wait_until:
          condition:
            - lambda: return (id(a2_out_temp_studio).state < 18);
      - logger.log: "Telling Air Conditioner to STOP"
      - mqtt.publish:
          topic: HomeAssistant/Studio/Aircon/Status
          payload: "OFF"      
      - climate.control:
          id: daikin_ac
          mode: 'off'
      - binary_sensor.template.publish:
          id: studio_ac_status
          state: "OFF"
  - platform: template
    name: "Studio Aircon"
    id: studio_ac_status

Why is this ultimately not an ideal code change… well for starters, the yaml code thinks it has turned off the AC unit, however the wait_until statement keeps the AC running.

The wait_until is working, but is not ideal, and I am sure a solution is starring me in the face? So perhaps @ssieb or another smart person has some clever ideas, suggestions?