Controlling my AC unit with NodeMcu and MQTT

I’ve been working on this to control and automate my AC unit (LG) for starter, I wanted everything to be simple to figure out what I need in the future, because its kinda of a waste to use a nodemcu just for this. The idea is simple, but I figured I would share as I go so if anyone else searching for something similar or have a better way to do things.
I am using a NodeMcu with IR led connected to it sending the codes to turn off the AC or turn it on with mode auto and temp 25 which is simple enough.
here is my arduino sketch

and here is the switch in home assistant

switch:
   - platform: mqtt
      name: "AC"
      command_topic: "ac/state"
      payload_on: "1"
      payload_off: "0"
      retain: true

next thing i want to do is the mount the NodeMcu on the AC unit and connect a photoresistor and use it to know the status of the AC to be certain if its off or on. and since Im using the IRremote any way, I might as well control the wall mounted fan and could try to control the TV/media stuff as well if I could figure a way to position the the device in a place where the IR led can send the signal to everything. while i am at it, a simple dht11 sensor to monitor indoor temp and humidity wouldn’t hurt.

1 Like

thanks for sharing one question how did you get the ir code ?

no problem.

Using an arduino (or the nodeMcu) and ir receiver you can pretty much get any ir codes of any remote. I found this library to be working with my AC remote as other libraries couldn’t get the decoding. https://github.com/cyborg5/IRLib2 and i actually found most of the codes and much more than I actually need in this library for the esp8266 https://github.com/markszabo/IRremoteESP8266 however I haven’t tried any of them because I just wanted a simple on/off solution for now.

My server where hass.io is installed crashed a couple of days ago and I didn’t have backups so I will be making everything from the ground up and I might change a couple of things and I would be sure to post it here regarding the AC control.

hope all that made sense :slight_smile:

1 Like