IR Air Conditioner (AC) + Broadlink + Lovelace

Tags: #<Tag:0x00007f326b2ac570> #<Tag:0x00007f326b2ac368> #<Tag:0x00007f326b2b3e60>

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.

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

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