HA Sensor Notification not triggering
I finally got everything set back up at the new house. HA is installed and configured, the Capibridge is connecting to the MQTT server, and the mailbox sensor is triggering on motion. If I run the HA automation manually, they appear to be working fine. However, just triggering the sensor with movement does NOT cause HA to message me. Is there a way to "trace" the activity all of the way from the sensor recognizing movement, the Capibridge forwarding this on to the MQTT server, and the HA noticing the MQTT activity and then "firing" the associated automation? I think I am really close to having this work.
Hi APT256,
To trace the activity from your sensor trigger through the Capibridge to Home Assistant (HA) and the notification automation, here are some steps and tips based on the project README:
-
Verify LoRa and MQTT configuration match exactly between your MailBox Guard sensor firmware and the CapiBridge gateway firmware. The LoRa parameters (bandwidth, spreading factor, coding rate, sync word, etc.) and the
GATEWAY_KEYmust be identical on both ends. -
Check MQTT Topics and Devices in HA:
Once your sensor triggers, you should see a corresponding MQTT device/entity appear in HA (for examplesensor.mbox_state). If it doesn't, the gateway might not be forwarding the message correctly. -
Use the Gateway's MQTT Logs:
The CapiBridge gateway is responsible for forwarding sensor data over MQTT. You should monitor the MQTT broker logs or use an MQTT client subscribed to the topic (e.g.,homeassistant/sensor/...) to verify messages arrive when motion triggers the sensor. -
HA Automation Trigger:
The example automation in the README triggers on the sensor state change tomail. This trigger fires 1 second after the state changes tomail. Because the automation works fine when run manually, it suggests the sensor state is not being updated automatically or MQTT messages are not correctly processed by HA. -
Debugging Idea:
- Use an MQTT client (like MQTT Explorer) to watch real-time MQTT messages from the sensor and gateway.
- Check in HA Developer Tools > States if the sensor entity changes state when motion happens.
- Ensure your MQTT server details, username/password, port, etc., are correctly set in both gateway and HA.
-
Refer to Gateway Setup Guidance in README:
- Make sure the
config.hfile on your gateway firmware has the correct WiFi and MQTT credentials configured. - The sensor's firmware config fields such as
NODE_NAME,GATEWAY_KEY, and LoRa parameters must match.
- Make sure the
-
Links that may help:
- CapiBridge Gateway setup instructions for gateway configuration.
- The Home Assistant automation example included in the README for notification setup.
This approach will help you trace and confirm the entire chain:
Sensor PIR trigger → Sensor LoRa transmit → Capibridge LoRa receive → Capibridge MQTT publish → Home Assistant MQTT receive → HA sensor state update → Automation trigger → Notification.
If any step in this chain fails (especially MQTT messages not arriving or sensor state not updating), the notification won't trigger.
For more detailed debugging, you may want to:
- Enable verbose logging on the gateway firmware (if supported) or within your MQTT client.
- Confirm MQTT topics used by your sensor by checking the sensor firmware or gateway logs.
- Confirm MQTT topic in the Home Assistant automation matches the topic the gateway publishes.
If you want, you can also check the YouTube channel linked in the README for helpful setup videos:
https://www.youtube.com/@PricelessToolkit/videos
I hope this information helps you get your notifications triggered automatically when the sensor detects motion.
✅ If this answer helped, please close the issue. 🤖 I’m an AI and If my response is incorrect or not sufficient, don’t worry @PricelessToolkit will review this topic soon.
As I am troubleshooting this, there is a definite possibility that I have the configuration wrong, as I am seeing duplicate entities:
- You can connect CapiBridge to PC and monitor incoming messages.
- Delete all old mailbox topics from MQTT via client "like MQTT Explorer"
- Triger sensor one more time, if state is "mail" then all working correctly
- MailBox Guard is sending only one state "mail" so if you not reset that topic to anything else, it will not trigger automation the next time.
- So reseting meen you need to publish something to "homeassistant/sensor/YourSensorName/state" topic not from HA like "Set state"
It is looking like the issue might be with these duplicate entities as one entity has a value while the other does not.
I will go ahead and try monitoring the Capibridge. It is currently connected to my PC via USB-C. Do you have any doccumentation on doing this? Do I need to shell into the capibride or can I connect to it via a serial TTL application? If the later, what are the serial settings for the connection: 9600 baud, 8N1, etc
you can use arduino ide and open serial consol!
i think your problem only because you don't resetting state topic to like "empty" its stays "mail"
MQTT client screenshot
You need this part too
action:
- service: mqtt.publish
data:
qos: 0
retain: true
topic: homeassistant/sensor/YourSensorName/state
payload: empty
https://github.com/PricelessToolkit/MailBoxGuard?tab=readme-ov-file#automation--mailbox-dismiss-notification-from-notification
I think you are right... I am not seeing any of those items being published to MQTT. This is all I see:
Let me go back through the ESP32 code and see if I can figure out where I messed up.
its not in capibridge but homeassistant/sensors/ and name of your sensor/state
I think I am getting confused with the CLI naming and the GUI naming. I am looking at Settings, Devices and Services, Entities (in the HA web GUI). I then type this into the filter field: sensor.mbox_state Here are the results:
One of the mbox state entites has the correct data:
But the other does not:
I would think the best thing to do to troubleshoot this is get rid of those duplicate entities with no data? If you agree, I will go ahead and delete those and see what happens?
Ahh... mine is a little different:
Just so I don't mess everything up, from within MQTT Explorer I should expand homeassistant and then expand sensor. I should then select mbox, move to the upper right-hand side of the screen, then click on the trash can?
Yep!! then trigger sensor and see if it appears
will do...
Here are the results after deleting and triggering the sensor:
perfect so all working if your automation is set to trigger when state is changed from anything to "mail" it will trigger, but remember to reset state every time to "empty"
like here https://github.com/PricelessToolkit/MailBoxGuard?tab=readme-ov-file#automation--mailbox-dismiss-notification-from-notification
basicaly you need to post mqtt message, payload "empty"
action:
- service: mqtt.publish
data:
qos: 0
retain: true
topic: homeassistant/sensor/YourSensorName/state
payload: empty
I thought I had that set up. Here is a couple of screen-shots showing what I did:
I am sure I have overlooked something, but I cannot find it...
Interesting... if I leave MQTT Explorer open an run the "LoRa MailBox Dismiss Notification automation, the mbox sensor's state changes to empty. Thus, it appears that the back-end "stuff" is working, but I am not receiving notifications on my iPhone when the state changes to "mail". However, if I manually run the "LoRa MailBox Sensor Notification", I do get a notification on my iPhone. Thus, it appears that the "LoRa MailBox Sensor Notification" is not being triggered via the MQTT message? Does that make sense? Please keep in mind that I am new to Home Assistant so it is entirely possible that I am overlooking something.
post screenshot of notification automation but open "when" part
I just screwd up :-( I deleted what I thought was an old automation but ended up being the sensor notification automation with a different name. Of well, now that it is gone, I will re-create it and maybe that will fix my issue?