Skip to content

Emulate a Philips Hue bridge running on an ESP8266 which controls a window cover

License

Notifications You must be signed in to change notification settings

dtila/MQTTWindowCover

 
 

Repository files navigation

ESP8266 Window Cover Hue Emulator

This Arduino schetch emulates a Philips Hue bridge running on ESP8266 and expose a the windows shelter as a Philips Hue bulb. The on/off commands are opening/closing the window cover and the Brightness function is acting as a tilt position.

Please note that currently only the bare minimum functions are implemented to the Hue bridge emulator, but it is enough that most common apps are able to work with.

Demo

The window covers they are running for more than a year in my house and I was able to expose via Home Assistant to Google Home. See in action below:

Bedroom Covers

Build Status

Build Status

To make this work, the sketch advertises its service with the so-called "Simple Service Discovery Protocol" (SSDP) that is also used as discovery protocol of Universal Plug and Play (UPnP).

Hardware

For now the only hardware that is supported (and tested) is:

  • electric cover to have a AC motor that can be connected directly to the 220V power network
  • the electric cover needs to have 3 wires (1 common and anoter 2 for direction - OPEN or CLOSE )
  • Sonoff Dual to act as a command gateway

You can have a look to the connection diagram here. During the tests if you have noticed that the OPEN and CLOSE are swapped, just swap the two wires.

schematic

Features

  1. The ESP board is advertised in the network as a Philips Hue bridge for controlling the cover
  2. A simple HTTP page is served as a status
  3. Remote debugging is supported via Telnet
  4. OTA updates is supported. The url for this is {ip}/update
  5. mDNS is supported
  6. MQTT control is supported thought topics: 1 Command topic: OPEN, CLOSE, STOP, CALIBRATE 2 State topic: the board is sending if it's ON or OFF 3 Position topic: the board is sending every time when the position is changed

Remarks The position of the cover is stored in the EEPROM memory. This means that if you are turning of the device, it keeps the previous position in memory.

To do

  • Web Interface & expose settings
  • WPS pairing

Usage

WARNING: Sonoff is connected directly to the 220V power network. Disconnect the board before to flash the new firmware or when you connect the electric cover.

  • Load the sketch onto your Sonoff Dual device
  • Watch the output of the sketch in a serial console
  • Connect to the emulated bridge by using a Hue client app
  • Switch on/off or adjust the Brightness

Integrations

Home Assistant

To add the cover in the Home Assistant (up to 0.85), just paste this in the configuration file:

cover:
  - platform: mqtt
    name: "Bedroom"
    command_topic: "bedroom/cover/set"
    position_topic: "bedroom/cover/position"
    set_position_topic: "bedroom/cover/set"
    payload_open: "OPEN"
    payload_closel: "CLOSE"
    payload_stop: "STOP"
    state_topic: "bedroom/cover/state"
    state_open: "open"
    state_closed: "close"
    tilt_min: 0
    tilt_max: 100
    tilt_invert_state: true

For the version above 0.85 you need to use:

  - platform: mqtt
    name: "Bedroom"
    command_topic: "bedroom/cover/set"
    position_topic: "bedroom/cover/position"
    set_position_topic: "bedroom/cover/set"
    payload_open: "OPEN"
    payload_close: "CLOSE"
    payload_stop: "STOP"
    state_topic: "bedroom/cover/state"
    state_open: "open"
    state_closed: "close"

Compilation

Before compile the software, you need to perform some additional changes:

  1. Modify the secrets.h file with the manual, host
  2. Change the FULL_TIME_MS value with the full time (in miliseconds) that your cover takes from a full opening to a full close. This can vary depending on the lenght or type of the motor that the cover has.
  3. Change the friendly_name variable with something that matches your preference

To make sure you have all the libraries needed:

mkdir -p $HOME/Arduino/libraries/
cd $HOME/Arduino/libraries/
git clone https://github.com/tilutza/aJson.git
git clone https://github.com/PaulStoffregen/Time.git
git clone https://github.com/gmag11/NtpClient.git
git clone https://github.com/thomasfredericks/Bounce2.git
git clone https://github.com/knolleary/pubsubclient.git
git clone https://github.com/tilutza/RemoteDebug.git

Credits

  • Philips for providing open Hue APIs that are not restricted for use on Philips-branded hardware (as far as I can see by looking at their liberal Terms and Conditions of Use)
  • probonopd for providing the original Hue Emulator

About

Emulate a Philips Hue bridge running on an ESP8266 which controls a window cover

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%