Home Assistant + WLED + MQTT + PIR

Hello Guys,
I am stuck on making my WLED project work. I am basicaly using esp8266 dev board installed with WLED software using mosfets and analog LED RGB Strip and a relay. I was able to successfully integrate WLED into Home Assistant instance with the RGB and it is working flawlessly.
The problem I am encountering is with adding PIR (HC-SR501). By directly adding the PIR into the WLED, it is working inverted (when presence is detected, it switches off the WLED). After trying to correct the same, I came to a conclusion that I may use MQTT publisher provided with WLED and use the same to convey presence detection to Home Assistant instance and create an automation therein to switch on the WLED. However, being new to MQTT, I am not able to set up the same.
I have installed the MQTT Add on, created new user, added Listen to a Topic in the configuration as well as provided mqtt username and password to the WLED (so as to publish the presence detection). But the same is not sending anything on the Home Assistant Instance and there is no discovery of new devices. Can someone assist me with the same.
I am adding few pictures to support my work.
Thanks in advance.







According to WLED doc, it uses HIGH to detect presence

According to the HC-SR501 specs, that’s indeed what it does, go HIGH when presence is detected.

Bottom-line: you might have a build issue that effectively invert the PIR.

Try using Button 1 rather than zero.
image

I downloaded a bin for the usermod 4-PIR_sensor_switch: this has a better way to work with a PIR.

Download the usermode from https://github.com/srg74/WLED-wemos-shield/blob/5fa8716d7313feb3dbda14c0581642468f3f08dd/resources/Firmware/%40Aircoookie/Latest/, and flash that version to your device.
Then, in the UserMods menu, init your PIR settings.

More info about the mod: Usermod PIRsensorSwitch - WLED MoonModules Project