Milfra MFA05
The Milfra MFA05 is a smart light switch with a built-in motion sensor.
Hardware
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.
Installing Tasmota
This unit is based on a ESP8266 and supports Tasmota.
Wiring
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.
Configuration
The template for this unit is available at https://templates.blakadder.com/milfra_MFA05.html. 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