Using the BMW ConnectedDrive add-on, I’m able to use a sensor that knows the fuel level in my car (sensor.320i_remaining_fuel). This value will, of-course, decrease from time 2 time, and once in a while it will shoot up again when the tank is filled again.
Since the sensor always reads the current value, would it possible to calculate the average consumption (on a timed interval, daily/weekly etc) on a template sensor? i.e. xx amount of Liters p/day ?
Yes, i did succeed to do so last week with a margin of error of 1 Liter (when refuelling).
for that you will need:
1. with Utility Meter (if not install it) create a utility sensor:
Name: " X3 Liters Daily " (in my case or use any other name and amend the formulas)
Meter reset cycle = Daily
Offset = 0
Supported tariff: " usage " and " refuel "
Net Consumption = ACTIVE
Once created two new sensors shall also be created:
sensor.x3_liters_daily_refuel
sensor.x3_liters_daily_used
2. Add an automation to switch the utility meter tariff created (step 1) based on the connecteddrive lids boolean
alias: X3 Using or Refuelling
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.x3_xdrive30e_door_lock_state
condition: []
action:
- service: select.select_option
target:
entity_id:
- select.x3_liters_daily
data:
option: >-
{{ 'used' if 'off' in
states('binary_sensor.x3_xdrive30e_door_lock_state') else 'refuel' }}
- device_id: 250d13ae635775162bc0f5b00982c340
domain: button
entity_id: button.x3_xdrive30e_refresh_from_cloud
type: press
mode: single
3. create an additional sensor for swapping the liters positive and another for calculating the L/100Km in your configuration.yaml or on your templates file