Sonoff Mini to only send MQTT and not actually cut power?

Tags: #<Tag:0x00007fc42fa91230> #<Tag:0x00007fc42fa910f0> #<Tag:0x00007fc42fa91028>

Hi all,

I recently installed a Sonoff Mini thinking it was the solution for wanting a physical switch to control my existing yeelight smart bulb setup. However I’m now experiencing the situation where the Sonoff will cut power to the bulb rendering it unavailable.

Ideally I would like to retain colour/voice control etc for the bulb and be able to use the physical switch in my wall when desired. Is there a way to configure the Sonoff Mini to only send On/Off signals to the bulb when the physical switch is toggled and have the actual power cut be limited to a specific command through HA?

If the Sonoff Mini was infact the wrong way to go about this could anybody recommend a better route?

Thanks in advance :slight_smile:

You can flash them with Tasmota and assign an MQTT topic for single, double an hold actions.

I have flashed it with Tasmota and have the MQTT settings according to the Drzzs video. Everything works in terms of toggling the switch power, either through HA or the physical switch. The problem remains however that when the on/off is actioned by the Sonoff it makes the Yeelight bulb become unavailable.

Unfortunately I don’t fully understand

My config currently looks like this:

  - platform: mqtt
    name: "Jonathan Top Light"
    command_topic: "cmnd/sonoffJonathan/power"
    state_topic: "stat/sonoffJonathan/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true

I have GPIO4 set to Switch1

Go to your Tasmota web console and type SwitchMode1 5, then SetOption32 10. Now create this two rules in the console:

  1. This rule send a toggle message to topic “cmnd/LohaLed1/power” with a single press and send a toogle message to the topic “cmnd/kitchen_leds/power” when the button is press and hold.

    rule1 on switch1#state=2 do publish cmnd/LohaLed1/power toggle endon on switch1#state=3 do publish cmnd/kitchen_leds/power toggle endon

    rule1 1

  2. I use this rule to disable the rule 1 and use switch as normal in case the wifi or the Mqtt connection is lost.

    rule2 on Mqtt#Disconnected do rule1 0 endon on Mqtt#Connected do rule1 1 endon

    rule2 1

Change the topics to your needs. If your yeelight bulb doesn’t have Mqtt you need to create an automation to toggle your lights when message is received on those topics.

Check this video with a better explanation:

Is this the best way to achieve a always-on smart light system in your opinion?

With Tasmota on the Mini and connected to MQTT broker on Home Assistant, go to the Tasmota console. There are only three commands needed:

PowerOnState 1
SwitchMode1 0
SetOption114 1

PowerOnState 1 turns the relay on upon start. SeitchMode1 0 reports a TOGGLE whenever the Mini switch detects a change (on-to-off or off-to-on) on MQTT for your Mini topic (will use this later). And the real magic is SetOption114 1 which disconnects the switch from the relay. Toggling the switch now physically does nothing to the relay.

Now you need an Automation in HA. Create one with the following Trigger and Condition setup:

Mode: Single
Trigger type: MQTT
Topic: stat/<Your Mini R2 MQTT Name>/RESULT
Condition type: Template
Value template: {{ trigger.payload_json['Switch1']['Action'] == 'TOGGLE' }}
Action type: Device
Device: <your light>
Action: Toggle <your light>