FindMyHistory icon indicating copy to clipboard operation
FindMyHistory copied to clipboard

MQTT support would be great

Open duffy6 opened this issue 3 years ago • 10 comments

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

duffy6 avatar Jul 29 '22 14:07 duffy6

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

joe248 avatar Oct 01 '22 16:10 joe248

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

lennarto avatar Oct 02 '22 16:10 lennarto

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?

joe248 avatar Oct 02 '22 17:10 joe248

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

lennarto avatar Oct 02 '22 18:10 lennarto

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

joe248 avatar Oct 02 '22 18:10 joe248

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

joe248 avatar Oct 02 '22 18:10 joe248

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.

lennarto avatar Oct 02 '22 20:10 lennarto

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.

joe248 avatar Oct 02 '22 22:10 joe248

Is it possible to do this on an iPad?

Acitta avatar Jan 23 '23 21:01 Acitta

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

DShakar avatar Dec 23 '23 23:12 DShakar