Milfra MFA05

From Leo's Notes
Last edited on 27 November 2022, at 00:21.

The Milfra MFA05 is a smart light switch with a built-in motion sensor.


This unit's front metal plate isn't properly grounded out of the box due to a design flaw. There is a tab that connects this metal plate to the ground trace on the PCB. However, this tab doesn't extend far enough to make contact with the ground trace. This can be fixed by opening the unit and bending the tab.

Milfra MFA05 PCB
Milfra MFA05 PCB

Installing Tasmota

This unit is based on a ESP8266 and supports Tasmota.


After opening the switch, the unit comes apart into two separate PCBs connected with a header. The PCB on the switch side contains the ESP8266 chip along with some test pads that can be used to flash Tasmota.

To flash Tasmota, you need to connect 4 pins: the RX/TX pins (labeled R and T), 3.3v (labeled V), and ground (labeled G). GPIO0 is connected to ground via the tactile switch on the reverse side, so just press the switch when applying power to make the ESP8266 enter programming mode.


The template for this unit is available at The PIR sensor is set as switch 1. In order to make the PIR work with Home Assistant, you will have to additionally run the following commands after setup in Tasmota's console These commands decouple the switch from the relay, creates a rule to publish the PIR event as a motion detector, and publishes the auto discovery info to Home Assistant on startup..

Note that I use tasmota/%topic%/%prefix%/ as the MQTT full topic on my devices (the topic and prefix are in reverse order than the default). You will have to adjust this depending on your setup.

SetOption114 1

SwitchMode1 1
SwitchTopic 0
Rule1 on Switch1#state=1 do publish tasmota/%topic%/stat/PIR1 OFF endon on Switch1#state=0 do Publish tasmota/%topic%/stat/PIR1 ON endon
Rule1 1

rule2 on system#boot do publish2 homeassistant/binary_sensor/%macaddr%_motion/config {"name":"Motion Sensor","state_topic":"tasmota/%topic%/stat/PIR1","device_class":"motion","force_update":true,"off_delay":30,"availability_topic":"tasmota/%topic%/tele/LWT","payload_available":"Online","payload_not_available":"Offline","unique_id":"%macaddr%_motion","device":{"connections":[["mac","%macaddr%"]]}} endon
rule2 1

See also