Automating "unsmart" IR devices

guys,
i realy need help with recording my Air condition.
i tryed this great blog but couldnt make it work
https://partofthething.com/thoughts/?p=1010 (and the inside links)
i tryed to record in raw mode and pipe it to file but it didnt worked for me
can some one write the methode in details?

@Claire would it be possible to add a photo-resistor to check if the tv etc. is on or is that a bit too much work??

So HA always has the right state.

Could you let us know at which step you got stuck?
irrecord is recording the keys that you press in raw mode and sometimes, it is not very accurate. I remember I struggled a bit and it took me several times to record some of my devices.

Can you try the following steps:

 # Stop lirc to free up /dev/lirc0
sudo /etc/init.d/lirc stop
# Create a new remote control configuration file (using /dev/lirc0) and save the output to ~/lircd.conf
irrecord -d /dev/lirc0 ~/lircd.conf

I recommend to record only a few keys at first and see how it goes. Then, you can add the other keys progressively.

And then:

# Make a backup of the original lircd.conf file
 sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf
# Copy and analyze the raw codes from your new configuration file
irrecord -a ~/lircd.conf > /etc/lirc/lircd.conf

i made al of this for my tv and it works well but what can i do with my Air condition? i cant record it and i read that it can be done in raw mode? i did you made yourself?

You should be able to do exactly what you’ve done with your TV with your Air condition.
What happens when you use irrecord and try to record from your AC remote?
If it is indeed IR, there is no reason why you wouldn’t be able to record it.

in MODE 2 it works…i can see that it record (pulse…)
but if i make irrecord -d /dev/lirc0 ~/lircd.conf , i doesnt see DOTS when pressing the AC remote
refer to this link: http://absurdlycertain.blogspot.co.il/2013/03/lirc-raspi-remote-control-configuration.html

mode2 is recording everything so if you have interferences from a light or a TV, you could be seeing those and not your remote (or a mix of those and signal from your remote).
On the other hand, irrecord is looking for specific signals with specific length and frequency. If you have interferences coming from a light or other device, this might explain why irrecord is not working.
Are there any differences between your environment now and the environment when you where recording your TV remote?

There were also some cases similar to yours because of a kernel configuration. However, if you had this issue, I guess your TV remote wouldn’t have worked either…
Refer to the following link and look for the edit of “January 25th 2015”.

I don’t have any other idea so far but this issue is quite common based on what I could see on the Internet. I suggest you look around on other forums about LIRC to see if you can find a solution.
Again, it should work so be patient, you’ll figure it out!

This is a great idea!
Indeed, it is quite frustrating to have a system that is still not fully smart. You cannot build proper automations.
However, I am not convinced about the photoresistor as it would have too many limitations: might not be reliable in daylight or if lights are on, and would not work with devices other than a TV.
Here are the options I would consider:

  1. If your device is a connected one (it is the case for my TV and my DAC, for instance), you could track it through a device tracker component such as nmap component.
  2. Use a current sensor on the power supply of your device. It will be more universal.

I’ll have a look into option 1 first and will dig into option 2 later (I need to get the hardware and will need some time for the setup and testing).
If anyone has already done something similar or wants to test in parallel, let me know!

Great thinking both of you! I have struggled with this through many universal remotes over the years. I think the idea of using a smart automation system combined with current measurement for the actual device state could be a huge breakthrough in reliable IR system operation, one that my wife will appreciate hugely!

I have a few other projects planned first but I will definitely be looking into this.

Yeah you could use some clip-on current sensor which you just clip on the cable or my first thought was to check the status led of the device with a photocell.

@balloob how hard would it be to add this “remote IR feature” to an existing component like samsungtv? The thought behind that is to switch the tv on if it is in standby.

That’s what automation rules are for

yes for sure, but you can’t use the on/off button to turn the tv on?

I went for option 1, but created a command_line switch like below for this. No need to add your tv to the device_tracker, unless there is a reason for this I’ve missed?

I’ve also added a sleep 5 before the ping to add a timeout so the switch doesn’t move back as soon as I slide it off, but that needs more tweaking. As soon as you slide the toggle, it jumps back since irsend and my tv take a bit of time before turning off, and the statecmd had polled it before it got a chance to turn off.

- platform: command_line
  switches:
    tv:
      oncmd: irsend -a 192.168.1.102 SEND_ONCE Samsung_BN59-01014A KEY_POWERON
      offcmd: irsend -a 192.168.1.102 SEND_ONCE Samsung_BN59-01014A KEY_POWEROFF
      statecmd: sleep 5 && ping -q -W 1 -c 1 tv.local

Any other place I can buy this?

IR emitter on the Pi’s GPIO

Can’t seem to find a valid link. Thanks!

EDIT:

Found one! http://www.newegg.com/Product/Product.aspx?Item=9SIA5W02EF6093

Sorry for the late reply. I haven’t work on my HA for a while… Anyway, just wanted to say thanks, your solution is indeed much more efficient!

Instead of using a Raspberry, you can also solder something together with an ESP8266: https://alexbloggt.com/universal-infrarot-websteuerung-ueber-esp8266/

1 Like

Thank you! Have you set it up yet? Is this module plug and play (can I just insert it in by raspberry pi without any cables) and start configuring it through command line?

A much easier way to get npm on your Pi:
creationix/nvm

@Claire, how do you get the button layout as you did with lirc_web?