Reminder to change the bike part using Strava input

Bikers understand the importance of changing the chain every 2,500 km and the cassette every 5,000 km to avoid bigger expenses down the road. To help with this, I’ve developed a bike sensor that pulls gear-ridden distance data from Strava. I’m looking to create an additional feature that tracks the remaining distance until the chain needs to be replaced. For example, if I changed the chain at 14,300 km, the next change should occur at 16,800 km.

An example. After completing an 80 km ride, Strava would update the gear-ridden distance to 14,380 km. The new ‘chain remaining distance’ should automatically adjust to 2,420 km (2,500 km - 80 km).

Is there anyone who can help me achieve this functionality?

Assuming the “gear-ridden” sensor value is in HA, a plain template sensor should do, no?

Yes, the “gear-ridden” sensor is already in HA. I do not know how it can be done via a template. Can you share an example?

There are a bazillion examples on this forum, but the entrypoint should be the doc