Skip to content
New issue

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

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

Already on GitHub? # to your account

No messages to MQTT #34

Open
danesolutions opened this issue Mar 24, 2022 · 11 comments
Open

No messages to MQTT #34

danesolutions opened this issue Mar 24, 2022 · 11 comments

Comments

@danesolutions
Copy link

Hi,

First of all, great software just what I was looking for!
I only have an issue with registering to my MQTT (Mosquitto) I don't have credentials set on Mosquitto.
I can't get it to work that the topic "p2000" is getting published and filled with P2000 messages.
Attached is my config.ini file.
I tried to leave the fields username/password empty or just filled in random text but I can't see the p2000 topic published.

Hope you can help me.
Kind regards
image

@cris1
Copy link

cris1 commented Jun 7, 2022

I have the same issue, also with mosquitto.
I do use a username and password but p2000 messages are not published although the debug log says it did -->

python3[15860]: 2022-06-07 22:33:00 - (PostThread) - p2000.py - DEBUG - MQTT status: Posting to 192.168.100.188:1883 topic:huis/p2000

@Dinges28
Copy link
Contributor

Dinges28 commented Jun 7, 2022

Try to outcomment (#) line 720
[https://github.com/cyberjunky/RTL-SDR-P2000Receiver-HA/blob/94e251ee60ca4f97d4a470e85af88201b7aabd8b/p2000.py#L720]

It might solve your login credentials issue (not using mqtt myself)

@cyberjunky
Copy link
Owner

If this works i will do check for password/username to see if we need to call the set_pw

@cris1
Copy link

cris1 commented Jun 13, 2022

For me that did not solve the issues. My MQTT requires authentication btw.

@Dinges28
Copy link
Contributor

Fill in a dummy user and password, and add and change line 717 and 722 with the data from my pull request.
#37

@cyberjunky
Copy link
Owner

@cris1 did the fix from @Dinges28 fixed your MQTT issue? (code is now updated)

@cyberjunky
Copy link
Owner

@cris1 can you try the latest code and let us know?
There was a bug which is fixed now.

@dfsx1
Copy link

dfsx1 commented Sep 10, 2022

@cyberjunky @chris1

I think this is the problem.
Debug says it posts to mqtt_topic

f"MQTT status: Posting to {self.mqtt_server}:{self.mqtt_port} topic:{self.mqtt_topic}"

But this is wrong because it actually posts to mqtt_topic_sensor

client.publish(self.mqtt_topic_sensor, data)

self.mqtt_topic_sensor = (
  self.mqtt_topic + "/sensor/" + self.sensorname
)

I still have a manual MQTT sensor configured in HA that expects state_topic: "p2000"
So for now I just modify the code to post to mqtt_topic again.

client.publish(self.mqtt_topic_sensor, data)
client.publish(self.mqtt_topic, data)

Maybe later it would be nice to change the format to HA MQTT Discovery...
https://www.home-assistant.io/docs/mqtt/discovery/#discovery-messages

@Dinges28
Copy link
Contributor

This is done because the current script allows multiple sensors. therefore the topic_sensor is made.
But if you don't use that, be free to change it what you want it to be, no harm done... ;-)

Doing the discovery.. I tried, but no succes for me.. but if somebody else wants to try?

@cris1
Copy link

cris1 commented Sep 10, 2022

@cris1 can you try the latest code and let us know? There was a bug which is fixed now.

Hi, sorry for the delay, took me a bit to find time to test the update.
I can tell you it works for me!!

I have Mosquitto MQTT running on port 1883 and use authentication.

image

The mistake I made was how I subscribed to the topic. The trailing slash did the trick for me and now I see the P2000 messages in MQTT. I am not sure if this always was the issue or not..but I am glad it works.

Sep 10 22:56:57 /huis/p2000/sensor/p2000_catchall {"state": "P 2 BDH-02 BR gerucht Bazuinlaan Rijswijk ZH 155630", "attributes": {"time received": "Sat Sep 10 22:56:55 2022", "group id": "14.039", "receivers": "001500161", "capcodes": ["002029568", "001503902", "001500196", "001500161"], "priority": 2, "disciplines": "", "raw message": "FLEX|2022-09-10 20:56:55|1600/2/K/A|14.039|002029568 001503902 001500196 001500161|ALN|P 2 BDH-02 BR gerucht Bazuinlaan Rijswijk ZH 155630", "region": "", "location": "", "postal code": "", "city": "Rijswijk ZH", "address": "Bazuinlaan Rijswijk ZH", "street": "", "remarks": "", "longitude": "4.3216871", "latitude": "52.0316638", "opencage": "enabled: True ratelimit: False gps-checked: False", "mapurl": "https://www.openstreetmap.org/?mlat=52.03166&mlon=4.32169#map=17/52.03166/4.32169", "distance": 38.39, "friendly_name": "P2000 Catchall"}}

Good job!

@spiralshapeturtle
Copy link

Thanks, this thread helps me to solve my MQTT problems.

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

No branches or pull requests

6 participants