0x00 Intro

At this point I'm guessing you have already read the previous article about how to install ESPEasy (with the correct plugin) on Anavi Light Controller, so you can control it.
If you have not, you can check it out here: Anavi ESPEasy

Small note:
In this setup we'll be sending the command to the ESP controller over HTTP, not over MQTT.
I'm very lazy ...and implementing the modes in MQTT will probably be a pain (on the domoticz side)... and since that will have to be done over http, I decided i'll just do all the RGB contol over http for now.

0x01 Create RGB Switch in Domoticz

Lets start...
Go into your domoticz interface > Setup > Hardware
I'm guessing you already have a Dummy Devices setup, if not - create a Dummy Devices
and after that click on the Create Virtual Sensor

Dummy Devices

Select RGB Switch and write whatever name you like.
After that you should have a new device in Setup > Devices.
Get the ID of the device, we will need it later on.

0x02 The helper script

There was a neat script I found when browsing around the domoticz forum.
I did some small modifications but overall it is just like the one you can find in there.

#!/usr/bin/env python

import sys
import getopt
import requests
import ast

domoticz_url = 'domoticz'

def app(argv):
    ID = ''
    IP = ''
        opts, args = getopt.getopt(argv, "hi:e:", ["ID=", "IP="])
    except getopt.GetoptError:
        print("night_light.py -i <Domoticz IDX> -e <easyESP IP last octet>")
    for opt, arg in opts:
        if opt == '-h':
            print("night_light.py -i <Domoticz IDX> -e <easyESP IP last octet>")
        elif opt in ("-i", "--id"):
            ID = arg
        elif opt in ("-e", "eIP"):
            IP = arg

        domo_url = "http://{}/json.htm?type=devices&rid={}".format(domoticz_url, ID)
        data = requests.get(url=domo_url)
        colour_data = ast.literal_eval(data.json()['result'][0]['Color'])
        level_data = data.json()['result'][0]['Level']
        state = data.json()['result'][0]['Data']
        red = int(colour_data["r"])
        green = int(colour_data["g"])
        blue = int(colour_data["b"])
        level = int(level_data)

        redl = int((red/100) * level)
        greenl = int((green/100) * level)
        bluel = int((blue/100) * level)

        if state == 'Off':
            redl = 0
            greenl = 0
            bluel = 0

    curl4 = 'http://{}/control?cmd=RGB,{},{},{}'.format(IP, redl, greenl, bluel)
    _i = requests.get(url=curl4)

    except Exception as err:

if __name__ == "__main__":

Replace domoticz_url with the URL of your Domoticz URL.

As you can see the script is both smart but in the end doing things the most wrong way possible.
The way you set it up is like this.... you make the RGB Switch execute it on every change in the status
When started the script asks Domoticz about the status of the RGB switch,
gets the relevant values and sends them to the controller over http.

So lets get put the final touches to make everything work.

0x03 Config the RGB Switch

Again we have to go to the Domoticz Interface,
but this time we are looking for the created RGB Switch in Switches.
There should be a small Settings icon on the switch itself, click it!


It will open up the settings page for the switch
There you will see On Action and Off Action fields. In them add:


script:///path/to/script/rgb_control.py -i 50 -e

0x04 Mode control

To control the modes you can create a custom switch(es) in Domoticz, but insted of starting a script they can direclly do a GET request with the command to the controller.
Commands look like this: http://domoticz_url/control?cmd=Mode,5,400
Replace domoticz_url with the correct one.

You can get more details about the commands Here

0x05 End result


RGB Small