Closed johnbaker26222 closed 4 months ago
This is an awesome project. May I ask if these Tags listed here (i would buy them here, think they are the same, right?) work "out of the box" with this project or will I need to solder around and flash them somehow. I am not a talented solderer/coder...
It's a bit of a gamble if you get a tag with an st17h66, you'll have to try and see.. I sometimes get different chips from the same seller. And they for sure will not work out of the box, you'll need to solder around (a bit targeted actually), and flash a custom firmware. With the firmware we can help you, and soldering is a useful skill to have under your belt!
- Installing Openhaystack in a Docker Container on a Synology NAS
I doubt a NAS is able to run a full os like macOS, you probably need an average desktop/laptop for this
- using both these super cheap airtag-clone devices linked above and original AirTags without the need to do any soldering
Yeah soldering required, or at least some trickery with probes / test pins.
- Optimal, yet optional: track these Tags wtih HomeAssistant to automate certain actions
There is nothing stopping you from pushing the reports on an MQTT queue or such, which then should be available in HomeAssistant
- Optional: if this will not work with HA: automate Telegram bot actions for reaching/leaving predefined areas (at a certain time) e.g. "Your Cat is not at home" after 9pm
I think there is a telegram script a couple posts up in this issue. You mentioned you haven't done any deep reading yet, this is definitely a requirement to get this up and running the way you want.
- I guess this would work as an "at home" receiver, right?
Any bluetooth capable device can receive the BLE advertisements and process them "at home", so this ESP32 thing as well. Also RPi's or any other SBC or even just your home workstation can do this.
This will require an update to the custom firmware you'll need to flash, I did not get to implementing that yet.
In short my use case is: "Using (Off-Brand) AirTags on Android devices, Bonus: HomeAssistant Integration"
I'm not sure how your Android is coming into this story, but HomeAssistant integration is definitely possible but will require a bit of effort.
@biemster
Just to summarize, hoping I understood it correctly: The most up-to-date functioning firmware is this branch, which was compiled with Keil. All other GCC attempts are not suitable since broadcasting is missing, making it impossible to track. The only realistic chance (without significant modifications) to implement the feature with changing keys is using the (commercial) Keil compiler?
@Cyl0nius
Thank you for the link/video, this clears a lot how the anti-tracking feature works and how often the key is switched.
@supaeasy
My response would have been similar to biemster's. In general, anything is possible; your NAS needs to be a real PC. There may be NAS devices on the market that run, for example, Windows, or you can build your own where it might work. Unfortunately, you won't be able to avoid soldering. I conducted my tests with this and this device. I flashed it with that, if this helps. For an Home-Assistant integration you can have a look at this project
By Android, do you mean the APK from this project?
Hi @dchristl that is almost correct. Currently the only fully functioning FindMy firmware is https://github.com/biemster/st17h66_FindMy, which has to be compiled with Keil indeed. All future development will happen in https://github.com/biemster/st17h66_RF, which is only very marginally behind the aforementioned one and compiles with GCC. The moment I find some time again for this project the st17h66_RF
repo will be the main one, which really should not take more than a couple hours.
Here is a better version of a geofence alert via telegram. This allows a home position to be specified. If a tracker goes outside the fence (1 mile radius in this example) it will send an alert once to prevent nuisance alerts. This should automatically rearm for another alert when the tracker is back inside the fence.
import time
import subprocess
import json
from geopy.distance import geodesic
from telegram import Bot
# Telegram bot token - Replace 'YOUR_TELEGRAM_BOT_TOKEN' with your actual bot token.
telegram_bot_token = 'YOUR_BOT_TOKEN'
# Telegram chat ID - Replace 'YOUR_TELEGRAM_CHAT_ID' with your actual Telegram chat ID.
telegram_chat_id = 'YOUR_CHAT_ID'
# Define your home coordinates here (latitude and longitude).
home_coordinates = (your_home_latitude, your_home_longitude)
# Dictionary to store the last known location of each key and its alert status.
last_known_locations = {}
item_alert_status = {}
# Function to get the distance between two coordinates in miles.
def get_distance(coord1, coord2):
return geodesic(coord1, coord2).miles
# Function to send a Telegram alert.
def send_telegram_alert(key, distance):
bot = Bot(token=telegram_bot_token)
message = f"Item '{key}' has moved {distance:.2f} miles from home."
bot.send_message(chat_id=telegram_chat_id, text=message)
# Main loop to run the geofencing check every 5 minutes.
while True:
try:
print("Running the geofencing check...")
# Execute the request_reports.py script and capture the output.
process = subprocess.Popen(['python', 'request_reports.py', '-H', '1', '-k', '7/Q4Cwq1QnNUfgg55gg5g2NLLM7HvmQViQ='], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
# Decode the output and split it into individual lines.
output_lines = stdout.decode().splitlines()
# Parse the output to extract location data for each key.
location_data = [json.loads(line.replace("'", '"')) for line in output_lines if line.startswith('{')]
for data in location_data:
key = data['key']
latitude = float(data['lat'])
longitude = float(data['lon'])
timestamp = int(data['timestamp'])
# Calculate the distance between the current location and your home location.
current_location = (latitude, longitude)
distance_miles = get_distance(current_location, home_coordinates)
print(f"Checking '{key}' - Distance from home: {distance_miles:.2f} miles")
# Check if an alert has been sent for this item and it's more than 1 mile from home.
if key not in item_alert_status and distance_miles > 1.0:
send_telegram_alert(key, distance_miles)
item_alert_status[key] = True
elif key in item_alert_status and distance_miles <= 1.0:
# Reset the alert status if the item is back within 1 mile.
del item_alert_status[key]
print("Geofencing check completed.")
except Exception as e:
print("Error:", e)
# Wait for 5 minutes before checking again.
print("Waiting for the next geofencing check...")
time.sleep(5 * 60)
@biemster How often do the Lenze devices advertise the key with your code?
When i have a look at it, with nrf connect, it varies from 8 to 15sec. ?!
@Systm21 every 5 seconds: https://github.com/biemster/st17h66_FindMy/blob/68f7b2be9ca8ec68f289e885bdb3673ee2179153/FindMy/source/FindMy.c#L260 In my tests (I also use nRF Connect) this was very consistent, so you might have some other issues if you see different. Especially if you see intervals that are not a multiple of 5 seconds (nrfconnect might miss an advertisement sometimes)
Those "fake AliExpress AirTags" are also ST17H66 in a nice but rather plasticky enclosure compared to real AirTags https://fr.aliexpress.com/item/1005006246691706.html?spm=a2g0o.productlist.main.99.5c5awGeGwGeGDX&algo_pvid=7ecf5b25-304c-4241-802f-02c914daf180&algo_exp_id=7ecf5b25-304c-4241-802f-02c914daf180-49&pdp_npi=4%40dis%21PLN%2117.40%2117.28%21%21%2130.22%2130.01%21%40211b61a417062891737635333e46b0%2112000036454320451%21sea%21PL%21787963629%21&curPageLogUid=wE2JD5kdo3JO&utparam-url=scene%3Asearch%7Cquery_from%3A
In short my use case is: "Using (Off-Brand) AirTags on Android devices, Bonus: HomeAssistant Integration"
Just for anyone reading up on this: Everything works very fine and ever since this project has gone from headless to macless it even runs completely on my Synology NAS. Marvellous project! Indoor tracking works quite fine with espresense-companion for anyone interested in that. What astonishes me the most is that there is more functionality than with original apple devices.
These are so cheap and easily available trackers, would be real nice to also support as well. Thanks!