Start/stop counting for utility meter, based on state of other sensor

Hi folks,

I want to summarize the milage (kilometers) driven with a car, separted by users.

I have the total milage of the car as a sensor in HA. My idea now is, to use an utility meter and count the milage based on the total sensor.

My problem is, how to differenciate between different users? I’d like to have a utility meter per user and then based on an other sensor‘s state (i.e. the connection of the users phone to the WiFi of the car) start/stop the counting.

Example: if my phone connects to the car WiFi “my” utility meter shall start adding the milage which comes from the total milage sensor. Once I disconnect from the car WiFi, the counting shall stop.

And if the phone of my wife connects to the car WiFi, “her” utility meter shall start counting.

I couldn’t find an option to solve this. Any ideas?

Of course other ways are also welcome.

Thanks guys!

Set up your utility meter with two tariffs. One for each driver.

Switch the tariffs using an automation, as explained here: Utility Meter - Home Assistant

This will give you two sensors. One for each driver.

1 Like

Thanks, that did the trick.

However it didn’t worked like described in the link. I couldn’t assign variables in the trigger section, got an error message that variables are not allowed there.

I assigned trigger IDs to the triggers and used an if/then with a condition checking for the trigger ID and then executing the tariff change.