Brilliant / Mirabella Genio Smart Plugs

Brilliant / Mirabella Genio Smart Plugs are a tuya based smart plugs sold by Bunnings and Kmart respectively in Australia.

../_images/brilliant-mirabella-genio-smart-plugs.jpg

Originally intended to be used with their companion apps once flashed using tuya-convert ESPHome generated firmware can be uploaded allowing you to control the smart plugs via Home Assistant.

1. Create the ESPHome Firmware

  1. Refer to either Getting Started with ESPHome or Getting Started with ESPHome through Hass.io before moving onto the next step.
  2. Select a plug configuration below based on the plug/s you have and copy all of the text in the code block and paste into your name_of_esphome_configuration.yaml file.
  3. Compile the firmware, again depending on your chosen setup refer to the guides in the first point.

2. Flashing

2.1 Prerequisites

  1. Before you begin you’ll need one of the following linux machines running the latest copy of Raspbian Stretch Lite
  1. Raspberry Pi 2B/B+ with USB WiFi Dongle.
  2. Raspberry Pi 3B/B+.

Note

As per the tuya-convert documentation:

Any Linux with a Wifi adapter which can act as an Access Point should also work. Please note that we have tested the Raspberry Pi with clean installations only. If you use your Raspberry Pi for anything else, we recommend using another SD card with a clean installation.

  1. A microSD card (minimum 2GB, 8GB+ recommended).
  2. Any WiFi device which can connect to the SSID generated by the Raspberry Pi and eventually the flashed tuya device. This cannot be an iOS / Apple device. Android devices will work.

2.2 Installing the OS

  1. It’s recommended to read the documentation provided by the Raspberry Pi Foundation on the best way to flash the OS to the microSD card depending on your platform - Installing operating system images.
  2. After you’ve flashed the microSD card browse to the “boot” partition and add a blank file called “ssh” (without any extension) which will enable the SSH server upon first boot, extended information on this step can be found here.
  3. Plug the microSD card into the Raspberry Pi, connect network cable and power, the Raspberry Pi will start to boot.

2.3 Connecting to the Pi via SSH

  1. Download and install Putty.
  2. Open Putty.
  3. Enter the IP of Raspberry Pi in the box that says “Host Name”, leaving the port set to 22 (default for SSH). A list of recommended ways can be found here, but the easiest is to download and use Fing (Android / iOS).
  4. In the “Saved Sessions” input box, name the Raspberry Pi connection and then press “Save”.
  5. Select your new saved session from the list.
  6. Press “Open”.

2.4 Configuring the Pi

  1. In the putty window login with the pi as the user and raspberry for the password.
  2. Type sudo apt-get update && sudo apt-get dist-upgrade -y and wait for the upgrades to install.
  3. Type sudo apt-get install git and wait for it to install.

2.5 Setup and Install tuya-convert

  1. In the putty window type git clone https://github.com/ct-Open-Source/tuya-convert press enter and wait while the repository is cloned.
  2. Type cd tuya-convert and press enter.
  3. Type ./install_prereq.sh press enter and wait as the script gathers all the required components needed to function.

2.6 Upload ESPHome Firmware using SFTP

  1. Download FileZilla or WinSCP or use your preferred FTP client.
  2. Depending on the program you need to connect to the Pi using the IP address as the hostname and the username and password the same as you used to connect via SSH and ensure your connection type is set to SFTP
  3. Browse to /root/tuya-convert/files.
  4. Upload your compiled firmware.bin file to this directory. For command line based installs you can access the file under <CONFIG_DIR>/<NODE_NAME>/.pioenvs/<NODE_NAME>/firmware.bin alternatively Hass.io users can download the file directly from the web ui.

2.7 Use tuya-convert to install ESPHome Firmware

  1. Type ./start_flash.sh

  2. Type yes to accept the warning.

  3. Connect your alternative WiFi device (non iOS / Apple based) to the vtrust-flash SSID using flashmeifyoucan as the password. This is the network being broadcast by the Pi from the tuya flash script.

  4. If you haven’t already connect your smart plug and turn it on. It should automatically enter pairing mode, if it doesn’t follow the instructions below:

    • To connect the Smart WiFi Plug to your WiFi press and hold the manual control button for about 5 seconds until you hear a click. Let go of the button as soon as you hear the click. Then press button once again to activate blinking. The red indicator light should now blink rapidly (2 times per second).
    • To do this, ensure your plug is on (the indicator light should be blue), hold the power button down for 5 seconds until you hear a click, let go of the power button and then press the button once to activate.
  5. Press enter on your putty window to start the flash process and wait. If the connection is successful you should see a large amount of scrolling text, this is the script backing up the factory shipped firmware.

  6. Once the process is complete you can type curl http://10.42.42.42/flashURL?url=http://10.42.42.1/files/firmware.bin

  7. The plug will restart and if everything is working correctly after a few seconds you should be able to press the button triggering the relay and turning the blue led on.

3. Smart Plug Configurations

Thanks to the existing work by @ideasman69 and afalzon which these adaptions created by @cryptelli are based on.

3.1 Brilliant Smart Plug

esphome:
  name: brilliant_smart_plug
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: 'WIFI'
  password: 'WIFIPASS'

logger:

api:

ota:

binary_sensor:
  - platform: gpio
    pin:
      number: 14
      mode: INPUT_PULLUP
      inverted: true
    name: "Power Button"
    on_press:
      - switch.toggle: relay

  - platform: status
    name: "Status"

switch:
  - platform: gpio
    id: red_led
    pin:
      number: GPIO12
      inverted: true

  - platform: gpio
    name: "Brilliant Smart Plug"
    pin: GPIO5
    id: relay

    # Turn off red LED to show blue when turned on
    on_turn_on:
      - switch.turn_off: red_led

    # Turns on the red LED once the plug is turned off. Stock plug doesn't do this, to restore normal behavior remove the on_turn_on and on_turn_off
    # blocks.
    on_turn_off:
      - switch.turn_on: red_led

3.2 Mirabella Genio Wi-Fi 1 USB Adaptor

esphome:
  name: mirabella_genio_smart_plug
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: 'WIFI'
  password: 'WIFIPASS'

logger:

api:

ota:

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO13
      mode: INPUT_PULLUP
      inverted: true
    name: "Power Button"
    on_press:
      - switch.toggle: relay
  - platform: status
    name: Status

switch:
  - platform: gpio
    name: "Mirabella Genio Smart Plug"
    pin: GPIO12
    id: relay

4. Adding to Home Assistant

You can now add your smart plug to home assistant via the configurations page, look for ‘ESPHome’ under the Integrations option and click ‘Configure’.

../_images/brilliant-mirabella-genio-smart-plugs-homeassistant.jpg