US Home
Automation

(Last updated: Sunday, October 15,2017)
Google
 

Node-Red TV Timer

This is a work in progress. I'm trying to put my notes here of what I was thinking and what I did to get this working.

Purpose

My wife wished for some kind of timer that she could hit a button from her Tivo remote and then the lights and the TV set would go off after N minutes. So how hard can that be? I've got plenty of device controllers and I'm sure I could find an IR remote node that would handle the Tivo remote. On the software side Node-Red, MQTT and the Arduino env. to the rescue.

While all of that is true it turns out that I couldn't find someone that had already done anything even close. So with that I decided I'd do it and document it here. ... Okay, I now need to update this, I think I found the ESP8266 node information I need (see the references below).

The first problem seemed pretty simple. I had to find or create a timer that would accept the values in a message payload. ...

Research - "Creativity is intelligence having fun." - Einstein

Yeah, it is fun to create, which is why I do this. :-) Anyone who is a Maker enjoys going from hmm to something working. Hardware, software, it's all a bit of a blur today. This 'wish' from my wife sent me down the usual roads. First check to see what was available on Node-Red. and what the existing ESP8266 community have come up with.

Node-Red

I like working with Node-Red it makes some things easy to do. Toss in MQTT topics and you can simulate devices you haven't yet built (like the ESP8266 or ESP32 IR transceiver node). The asymchronous nature of it's programming and the single flow does require a different way of thinking but with time it isn't too difficult to work with. It turns out many things in HA are asynchronous in nature.

Well, on the subject of timers, there are lots of node-red timer packages. But none that seem to do what I want. Which was to feed it a JSON message containing the timer's run time (in seconds) and the timer's warning time (in seconds). This would allow my wife to set the time via a simple web page (see above) or MQTT topic. There she could set the times and start the timer. I added the other devices to make it easy to see what's going on.

So with no timer package found I decided to write one. The easiest way was to take something that was close and modifiy it to match my needs. That timer package was Pete Scargill's timeout package. Pete's package is very close but doesn't support feeding it information so it can be dynamically set. Feeding it this information would simply reset the timer to extend the timer for whatever it was configured for. Also Pete's timer starts when Node-Red was restarted. I only wanted it running when I sent it specific commands.

Sonoff Basic node

This is the simpliest thing to build. I have several Sonoff Basic modules and I've found many sites that recommend all sorts of software to load into the module. It's so easy to reprogram this module to fit our own needs.

As the name suggests, it's a basic on/off node. But it is based on the ESP8266 Wifi board so it's easy to program with the Arduino env.

IR Transceiver node

This node is still being built and it might be the hardest part. I've found many IR receivers and IR transmitters but none that contained both. So it looks like I need to combine both.

Parts list:

  • 1 - Adafruit - HUZZAH ESP8266 Breakout, PRODUCT ID: 2471
  • 1 - 5.0v power supply
  • 2 - IR LED (TSAL6100 from Vishay)
  • 1 - IR Receiver ()
  • 1 - 2n3904 transistor
  • 1 - Resistor @ 3k3 Ω ¼W
  • 1 - Resistor @ 2.5 Ω ¼W
  • 2 - Diodes (1N4148)
  • 1 - case

The diodes provide for a constant current infrared led circuit. See the link for an explanation.

References:

Zigbee Smart Plug

Features

Future Features

  • IR transceiver node
    • IR transmit
    • IR receive
    • Status LED (tri-color)

Testing