When mine broke on my old 2010 Mazda 6 it was a $1000 dollar job at the dealer (local mechs wouldn’t touch it) or figure it out myself.
I found figuring out myself was like troubleshooting the space shuttle..
this thing would sense me approaching or leaving the car and lock/un-lock automatically.
it all broke....lucky for me it still sensed the fob for the push button start to work.
If you run into trouble (I did again last year, losing 1 of our 2 given key/remote combos at only 1 year old), look into ikeyless.com.
They have been fantastic for all my remote fob/key issues. Got another key that I just had to get cut at the hardward store and program myself with their simple instructions - MUCH cheaper than through the dealer. I admit, we found it IS indeed cheaper in mechanism (our stupid key flips in/out, another thing to go wrong) but if you play with it a bit out comes the key. We use our original as a result but it’s ready to back up.
I’ve used them for years with my other remotes when they just plain died (NOT battery). Always much cheaper than “genuine parts”.