MailBoxGuard icon indicating copy to clipboard operation
MailBoxGuard copied to clipboard

HA Sensor Notification not triggering

Open APT256 opened this issue 10 months ago • 54 comments

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.

APT256 avatar Jan 21 '26 18:01 APT256

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:

  1. 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_KEY must be identical on both ends.

  2. Check MQTT Topics and Devices in HA:
    Once your sensor triggers, you should see a corresponding MQTT device/entity appear in HA (for example sensor.mbox_state). If it doesn't, the gateway might not be forwarding the message correctly.

  3. 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.

  4. HA Automation Trigger:
    The example automation in the README triggers on the sensor state change to mail. This trigger fires 1 second after the state changes to mail. 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.

  5. 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.
  6. Refer to Gateway Setup Guidance in README:

    • Make sure the config.h file 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.
  7. Links that may help:

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.

AI-RedCode avatar Jan 21 '26 18:01 AI-RedCode

As I am troubleshooting this, there is a definite possibility that I have the configuration wrong, as I am seeing duplicate entities:

Image

APT256 avatar Jan 21 '26 19:01 APT256

  1. You can connect CapiBridge to PC and monitor incoming messages.
  2. Delete all old mailbox topics from MQTT via client "like MQTT Explorer"
  3. Triger sensor one more time, if state is "mail" then all working correctly
  4. 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.
  5. So reseting meen you need to publish something to "homeassistant/sensor/YourSensorName/state" topic not from HA like "Set state"

PricelessToolkit avatar Jan 21 '26 19:01 PricelessToolkit

It is looking like the issue might be with these duplicate entities as one entity has a value while the other does not.

Image

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

APT256 avatar Jan 21 '26 19:01 APT256

you can use arduino ide and open serial consol!

PricelessToolkit avatar Jan 21 '26 19:01 PricelessToolkit

i think your problem only because you don't resetting state topic to like "empty" its stays "mail"

MQTT client screenshot

Image

PricelessToolkit avatar Jan 21 '26 19:01 PricelessToolkit

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

PricelessToolkit avatar Jan 21 '26 19:01 PricelessToolkit

I think you are right... I am not seeing any of those items being published to MQTT. This is all I see:

Image

Let me go back through the ESP32 code and see if I can figure out where I messed up.

APT256 avatar Jan 21 '26 19:01 APT256

its not in capibridge but homeassistant/sensors/ and name of your sensor/state

PricelessToolkit avatar Jan 21 '26 19:01 PricelessToolkit

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:

Image

One of the mbox state entites has the correct data:

Image

But the other does not:

Image

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?

APT256 avatar Jan 21 '26 19:01 APT256

Image

PricelessToolkit avatar Jan 21 '26 19:01 PricelessToolkit

Ahh... mine is a little different:

Image

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?

APT256 avatar Jan 21 '26 19:01 APT256

Yep!! then trigger sensor and see if it appears

PricelessToolkit avatar Jan 21 '26 19:01 PricelessToolkit

will do...

APT256 avatar Jan 21 '26 19:01 APT256

Here are the results after deleting and triggering the sensor:

Image

APT256 avatar Jan 21 '26 19:01 APT256

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


PricelessToolkit avatar Jan 21 '26 19:01 PricelessToolkit

I thought I had that set up. Here is a couple of screen-shots showing what I did:

Image Image Image Image

I am sure I have overlooked something, but I cannot find it...

APT256 avatar Jan 21 '26 19:01 APT256

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.

APT256 avatar Jan 21 '26 20:01 APT256

post screenshot of notification automation but open "when" part

PricelessToolkit avatar Jan 21 '26 20:01 PricelessToolkit

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?

APT256 avatar Jan 21 '26 20:01 APT256