Home Depot Eco Plugs with custom firmware (ESPEasy) and openHAB
The Eco Plugs from Home Depot (and a few others) are built around a common ESP8266 wifi module. A few different people have done the work to “reverse engineer” these plugs. I used the post here as a guide in flashing the new firmware. The link gives the pinout of the module in the Eco Plugs. I had previously used the NodeMCU development module, but this was my first experience with an ESP requiring an external USB to Serial (FTDI) adapter.
The connection between the ESP and the FTDI adapter is:
VCC -> VCC
Ground -> Ground
TX -> RX
RX -> TX
To put the ESP into a state in which it is ready to accept a new firmware from the ESPEasy flash tool, you simply jump GPIO 0 to ground at boot.
This was my first time using a FTDI adapter, and I about went nuts trying to get it to show up as a COM device. No matter what driver I tried, I could only get it to show up as a USB Serial Converter in Device Manager. The trick is to check “Load VCP” under the Advanced tab of the USB Serial Converter device.
Once you have leads connected to the ESP module, the driver loaded and connected to your computer, it is pretty straight forward to flash the new firmware http://www.esp8266.nu/index.php/Tutorial_ESPEasy_Firmware_Upload#Flashing_the_module. I started by flashing the current “stable” R78 firmware included in the download section. From there I compiled the latest build 106. Some of the logic for controlling the device requires what is called “rules” which was introduced as an experimental feature in build R86.
Once the Plug is flashed with the latest ESPEasy firmware, there is some configuration that is required. Obviously, connecting it to you wifi network is first. From there you will want to give the device a unique name, set the protocol to OpenHAB MQTT, set your MQTT controller IP and port. An important setting that caused me some issues until I did some digging is the Unit Number. If you have more than one MQTT device, and do not set a unique Unit Number, your devices will be constantly dropping their connection to the broker and will only respond intermittently.
Next comes the Device tab. The first entry is for physical button on the plug. You will want to set it up as shown.
The second device is basically a virtual “switch” to capture the state of GPIO 15, which is the relay that controls the outlet. This allows us to query the state of the outlet. It should be configured as shown:
The final step is to set up the “rules.” The logic that will control the outlet. Here is what I came up with.
on Button#Switch do
if [State]=0
gpio,15,1
else
gpio,15,0
endif
endon
on State#State do
if [State]=1
publish /%sysname%/state,ON
else if [State]=0
publish /%sysname%/state,OFF
endif
endon
The first section toggles GPIO 15 (the outlet relay) when it detects a state change on the physical button (gpio 13).
The second section publishes the state of the outlet to the MQTT topic when it detects a change in the state of GPIO 15 (the outlet relay).
It’s pretty late but hopefully this makes sense for the most part. The biggest hurdle was that ESPEasy is pretty sparsely documented. The Unit Number, for example. If you run into any issues, I will do my best to answer any questions.