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

MQTT support would be great #3

Open
duffy6 opened this issue Jul 29, 2022 · 10 comments
Open

MQTT support would be great #3

duffy6 opened this issue Jul 29, 2022 · 10 comments

Comments

@duffy6
Copy link

duffy6 commented Jul 29, 2022

MQTT support would be great.
Then you can send the location updates to a mqtt server

@joe248
Copy link

joe248 commented Oct 1, 2022

@duffy6 I just added MQTT support in my fork. I haven't tested it extensively yet but it seems to work okay.

@lennarto
Copy link

lennarto commented Oct 2, 2022

@joe248 @fjxmlzn

Nice project!
However, I am not able to show the GPS coordinates in Home Assistant. Are you sure that your Home Assistant Configuration is correct?

I also needed to change "name" to "modelDisplayName" in the constansts.py since this generic name was not allowed.

@joe248
Copy link

joe248 commented Oct 2, 2022

Are you getting a configuration error in Home Assistant, or you're just not getting any data populated in the sensor?

If you watch the MQTT topic mosquitto_sub -t "FindMyHistory/#" what does the data look like for the device(s) you're trying to track?

@lennarto
Copy link

lennarto commented Oct 2, 2022

I think the main problem is that I get a ValueError: Publish topic cannot contain wildcards. because of the line

MQTT_TOPIC_KEY = 'name' in the file "constants.py"

I tried to change the name, but that broke your code 😅
Try to find a solution now, but if you have any idea that would be great.

Seems to be related to https://stackoverflow.com/questions/64410064/java-paho-mqtt-publish-to-wildcard

@joe248
Copy link

joe248 commented Oct 2, 2022

Do any of your device or item names contain any non-alphanumeric characters? Those probably need to be filtered out.

@joe248
Copy link

joe248 commented Oct 2, 2022

I'm guessing you have a + or # in one of your device names. Try changing log_manager.py - add import re at the top, then towards the bottom right after topic_key_value is first defined, add this line: topic_key_value = re.sub(r"[\#\+]", '', topic_key_value) to remove any + or # in the names

@lennarto
Copy link

lennarto commented Oct 2, 2022

Thanks for your help !!
I actually had an "#" in my name and now this error got away.

However,
when stripping the name string in the topic_key_value = line, the string will differ and therefore fail in the If loops in the def refresh_log(self) just before and therefore, no updates are pushed into Home Assistant.

@joe248
Copy link

joe248 commented Oct 2, 2022

when stripping the name string in the topic_key_value = line, the string will differ and therefore fail in the If loops in the def refresh_log(self) just before and therefore, no updates are pushed into Home Assistant.

Glad you got it working. The topic_key_value is only used to generate the topic that is published over MQTT. It's not used to do anything else within the script. The only reason that this statement: if topic_key_value and topic_key_value != "NULL": would be false is if topic_key_value == "NULL" or contains only # or + characters.

@Acitta
Copy link

Acitta commented Jan 23, 2023

Is it possible to do this on an iPad?

@DShakar
Copy link

DShakar commented Dec 23, 2023

Unless you can manage to jailbreak your iPad and install MacOS somehow. it is not

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

5 participants