IR Air Conditioner (AC) + Broadlink + Lovelace

Posted to Github as well

Home assistant package to manage IR AC and Lovelace cards configurations

I have started it as a day-to-day improvement, but it ended with 400 lines of code. Hope it will be used by someone.

Basic task:

  • To create a lovely page to controll all temperature and humidiy data for Lovelace from Home Assistant

Hardware and software:
Software:

Hardware:

  • Broadlink RM Pro/Mini - Will send the commands to the AC
  • Cooper&Hunter CH-S09XN7 (or any AC with IR remote)
  • PZEM 004v3 + Sonoff Basic (or any esp32/8266 board with Tasmota) - Used to monitor if the AC is ON or OFF and power consumption as a benefit

As a result:

General design for Temperature Lovelace View (one card, multiply it for your rooms/zones)

Preview Preview

Logic: General UI layout

  • Each room/space has its own place/card. Inside it there are swiped cards:
    • First card - Picture with sensors data
    • Second - mini-graph. Humidity is a key metric to monitor as it’s really important to stay helthy at home.
    • Third+ cards - some card to mamage the climate.
    • Swipe jumps back to the enitial view in 10 seconds

AC IR management package:

  • Main data is collected from virtual climate device to mega-sensor.
  • Data from sensor is concatinated to script name
  • You need to create a matrix of scripts for each command. In my case 4 2 2 24/25/26/27 C * Swing Up/Down * Cool/Heat
  • Scripts have own name convention, like: k1_ac_cool_24_up
  • Some automation to manage it
  • I’m using PZEM 004 to monitor energy and ON and OFF status, but you can use any small door sensor, or anything else.
  • I made a combination of cards to make it work and look as I think is good (K1 Kitchen at the GIF). + Some button card templates to save code space

Please take a look at the code comment at the package. Have fun and Enjoy.

1 Like

Hi there,

I want to learn how to make my broadlink IR able to detect my AC states. I believe you already able to do it… Need some tips and since I’m not good with python, still having difficulty understanding the broadlink calling. Thanks

Hi there.
Unfortunately, there is no way Broadlink can read your ac state.

It works only one direction: it sends IR signal to the air. And it does not knows if anyone get it.
Moreover, each AC state = unique command.
It contains all the data, like: temperature, flow direction, heat mode etc. In one line

So you can not just send command - flow up.
It will contain flow up, temp to XX, mode: heat, and so on.

What I do with my code: each time Lovelace Ui has changed climate state it launches one of saved codes. 24 total.

And when some one take an remote and changes the temp, data at HA will be incorrect, and there is no way you can do it easy

Hi there,

In my case the AC is connected to a smart plug which getting mA usage for example if the AC is on then the usage will be 400+ mA but when its OFF its will shown as 0-2 mA only. This way I can have a binary_sensor with an on/off state. However, implementing it to the script is still puzzle me. Am I right? Since the state is now will show HA that my AC is on or off based on that reading? I hope you can help. Thanks

Oh, yep. I have this in my implementation.

  1. I have tasmota flashed device that measures power of AC. At Tasmota I have created the rule to send mqtt command on power more or less than 25w.

ON tele-ENERGY#Power>5 DO publish tele/k1_ac_power/power On ENDON ON tele-ENERGY#Power<5 DO publish tele/k1_ac_power/power Off ENDON

You can reproduce the same logic with Home assistant automation.

  1. As a recipient of this data I use mqtt sensor:
sensor:
# I use power stats from PZEM 004 v3 collected with Tasmota.
# Tasmota rules for logical sensor
# Rule   ON tele-ENERGY#Power>5 DO publish tele/k1_ac_power/power On ENDON  ON tele-ENERGY#Power<5 DO publish tele/k1_ac_power/power Off ENDON
# TelePeriod 30

- platform: mqtt
  name: K1 AC Power state
  state_topic: "tele/k1_ac_power/power"
  # value_template: "{{ value_json['ENERGY'].Total }}"
  icon: mdi:power-plug

Hi there,

Thanks for the reply… since I’m using binary_sensor instead of MQTT wondering how do I do it… not good with python so trying to gues… Can you give me some idea? On how to do it let per say I have a binary sensor that allow me to detect the AC status.

I would do it using a template sensor.

with code like this:

binary_sensor:
  - platform: template
    sensors:
      your_new_ac_status_sensor_name:
        friendly_name: "AC is On"
        value_template: >-
          {{ state_attr('sensor.your_power_usage_sensor', 'mA_sensor_name') > 10 }}
# change 10 to needed value

This will return true to the new sensor if your socket uses energy
Hope it helped

1 Like

I did my own with more template, however yours idea works better. Thank you soo much for all the help. Its now working 100% and a nice one. Again thanks…

1 Like

Hello

Your project is great.

Would you please let me know how you are finding the temperature of AC?

Thanks
Shahzad Godil

Hi, @shahzadgodil
Thank you for the feedback.

There is no way I can read it from AC.
HA stores the last selected value and I only can belive that IR command was delivered.
So, If you have selected 24 degrees C at HA climate, and for some reason, someone has changed it at AC - you will no know it.
One of the solutions was (but I skipped it yet) - to send a command each XX minutes to make share that AC runs in selected mode.

Hope I get your question right

Hi,
I am looking for some ideas on how to manage/automate the air conditioner in my office/IT room on my house.

I have installed [SmartIR] to control a Broadlink RM4 Mini which then controls a Daikin air conditioner.
(GitHub - smartHomeHub/SmartIR at 9691aaaf622de33eaaeab7b02c452ce054d8e395)

This works quite well.
Now I want to set up automation(s) to further take the manual effort out of it.

As I live in the tropics the AC does not have a heater, only cooling, dry and fan.

In summer there is only one option and that is cooling.

However in cooler months (we call it winter) the days are 21-28 Celsius and nights are < 20 most nights.
As our town is by the Pacific ocean the humidity can be anywhere between 70 to 100%. This is where the dry setting comes in.
I have been running this on dry manually for an hour or so.
Drying uses less energy so I read.
Below are the lovelace cards that I have working.

I have been trying to think of an automation that can switch between cool & dry depending on temperature and humidity and season but the logic has me a bit confused at the moment.

I am unsure whether to trigger on temperature or humidity or a combination of that and season??
Can anyone give me a few ideas please.

1 Like

In the absence of any ideas I have come up with this idea.

I found this on the Daikin site

When to use dry mode:

  • When the temperature is acceptable, but the humidity is too high.
  • Use the dry mode when you do not need to cool the air.
  • During cooler months or the rainy season.

When to use cool mode:

  • You can use cool mode when both the temperature and the humidity levels are high.
  • Use the cool mode when you want the temperature to stay at a constant, cool level.

As I live in the wet tropics of the southern hemisphere we have very wet and hot summers and drier, cooler winters.
That said I decided to have a trigger on temperature and conditional on season as to what HVAC mode to run the AC in.
The winter months (June-August) would probably the time to run dry and cool through the rest of the year as temperatures and humidity are higher.

The next 6 months should test my theory
If anyone can see a better/smarter way please let me know.

I have created two automations

1. Dry mode

-- id: '1626054729276'
  alias: Office AC Dry Mode
  description: 'Run the Office AC in DRY Mode when temperature is comfortable '
  trigger:
  - platform: numeric_state
    entity_id: sensor.rm4_mini_temperature
    for: 00:01:00
    below: '26'
    above: '15'
  condition:
  - condition: state
    entity_id: sensor.season
    state: winter
  action:
  - service: climate.set_hvac_mode
    target:
      entity_id: climate.office_ac
    data:
      hvac_mode: dry
  mode: single

2. Cool Mode

- id: '1626054838752'
  alias: 'Office AC COOL Mode '
  description: 'Run the Office AC in COOL Mode when temperature is uncomfortable '
  trigger:
  - platform: numeric_state
    entity_id: sensor.rm4_mini_temperature
    for: 00:01:00
    above: '26'
  condition: []
  action:
  - service: climate.set_hvac_mode
    target:
      entity_id: climate.office_ac
    data:
      hvac_mode: cool
  mode: single

I know this is old but was curious what does mA_sensor_name stand for? Cheers!

Hi, don’t remember -(
I definitely used some dummy names, but the logic of state_attr is that you first refer to your sensor and then attribute. In the case above, it should be attributed actually with power consumption, W, or mA (milliamperes?)