Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connects to MQTT But Does Not Publish Topics #4

Open
Hassiopeia opened this issue Mar 2, 2021 · 2 comments
Open

Connects to MQTT But Does Not Publish Topics #4

Hassiopeia opened this issue Mar 2, 2021 · 2 comments

Comments

@Hassiopeia
Copy link

I have this installed on a Pi Zero W and connecting to a H5074 sensor. The software is getting the 04 type advertisement packets, but not sending topics via MQTT. I can see on my MQTT broker that a connection is established, yet noting is being send from the pi to my MQTT broker. I have no idea what I missed, so this may be an issue with newer versions of paho-mqtt perhaps?

@deepcoder
Copy link
Owner

deepcoder commented Mar 2, 2021

when the app starts up, it should print a startup set of messages similar to what is shown below, pretty sure it will bomb if it fails to connect to the MQTT server correctly. Check the mqtt topic in the config file. As I said in docs, I am a pretty poor C coder so if the MQTT path in the config file is something oddly specified then the topic in MQTT maybe way off somewhere you are not thinking. Also try a program like MQTT Explorer, it should nicely display all the MQTT topics visible on the MQTT server.

Any warnings during the complie?

Try and see if you see a MQTT topic appear, try a really simple one if nothing else, just to see if that works. MQTT accepts some pretty wild strings for topics.

Let me know if you are still having issues and I will try to recomplie with latest paho-mqtt git.

pi@pi-ble-01:/ $ sudo /home/pi/ble-sensors/hack_ble.sh
Running ble_sensor_mqtt_pub
20210302121018
Press [CTRL+C] to stop..
ble_sensor_mqtt_pub v 2.12
1 Bluetooth adapter(s) in system.
Reading configuration file : ble_sensor_mqtt_pub.csv
MQTT server : tcp://192.168.2.242:1883
MQTT topic  : homeassistant/sensor/ble-temp/

@Hassiopeia
Copy link
Author

Hassiopeia commented Mar 3, 2021

No warnings during compile. Also tried a fresh setup on another Pi with the same results.

I have been using MQTT Explorer connected to the broker and see that no topics are arriving for this. I can see topics for RoomAssistant on another Pi I have running. I can see in Home Assistant Supervisor MQTT that the ble sensor is connected
1614781262: New client connected from 192.168.200.21 as ble_sensor_mqtt_pub-56:C8:5D:EB:27:B8 (p2, c1, k20). but no topics arrive.

I think I may be onto the issue though. I believe its permissions with the MQTT Broker in HA. I have a user account set as well as Anonymous. My RoomAssistant instance is connecting with the user account and has no issues. I could not find a way to specify a user account with this ble sensor. Reading more of the HA MQTT addon documentation I see that if a user account is specified then Anonymous is Read Only. I suspect that is the issue I'm seeing. I attempted to remove the user account from the MQTT Broker and only use Anonymous but since the HA addon uses HA users by default, Anonymous was still Read Only. Is there a way to include an MQTT user account and password with the ble sensor setup?

EDIT:
I figured out how to make the MQTT Addon for Home Assistant be truly "Anonymous" for read/write. It took a few hoops to jump through with ACLs, but I have it working anonymously. The BLE sensor is now publishing topics to the MQTT broker!!!

It still wouldn't be a bad idea to implement user accounts tough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants