Skip to content
arendst edited this page Dec 29, 2016 · 9 revisions

Sonoff supports Domoticz MQTT 'out of the box'. Find below the procedure to start using it.

Assumptions

The following servers should be made available:

  • You have installed/access to a MQTT server and made contact with your sonoff
  • You have installed Domoticz

Domoticz

Configure MQTT and Virtual Sensor hardware

  1. On the hardware page add Type MQTT Client Gateway with LAN interface
    1. Give it a name
    2. Configure the interface with access to your MQTT server (Remote Address, Port, Username and Password)
    3. Choose a Public Topic what might be the default as set to out
  2. On the hardware page add Type Dummy (used for virtual switches)
    1. Give it a name
  3. Make a new virtual switch to be used with Sonoff by clicking Create Virtual Sensors
    1. Give it a name
    2. Select Sensor Type Switch
  4. On the Devices page find the new switch by it's name
    1. Remember it's Idx number

Sonoff

Sonoff provides several ways of configuring Domoticz parameters.

  • Make updates to the Domoticz section of user_config.h but remember that these changes are only propagated if you also change the CFG_HOLDER define. This is NOT my preferred way of configuring.
    1. Set DOMOTICZ_OUT_TOPIC to domoticz/ added with the Public Topic as defined in step 1.3
    2. Configure DOMOTICZ_RELAY_IDX1 to the value read in step 4.1
  • Use the webinterface and select Configuration - Configure Domoticz
    1. Set Out topic to domoticz/ added with the Public Topic as defined in step 1.3
    2. Configure Idx 1 to the value read in step 4.1
  • Use MQTT and execute commands
    1. cmnd/sonoff/DomoticzOutTopic with payload domoticz/ added with the Public Topic as defined in step 1.3
    2. cmnd/sonoff/DomoticzIdx1 with payload value read in step 4.1
  • Use the serial interface and execute commands
    1. DomoticzOutTopic with domoticz/ added with the Public Topic as defined in step 1.3
    2. DomoticzIdx1 with the value read in step 4.1

Domoticz

That's it! You can now switch Sonoff from the Domoticz user interface.

  1. On the Switches page scroll down and find your Switch as configured in step 3
    1. Toggle the light bulb; Sonoff should respond
Clone this wiki locally