Accessing attributes of a sensor in Lovelace - broken in 0.98

I have been using a statistics sensor on HA 0.95 and it was working well. I have read many posts that we can’t access the attributes of an entity directly in Lovelace but I somewhere found out that you could do that by appending a underscore to the entity name. This was all working well until I upgraded to 0.98. It seems to be broken now. I know I can create another template sensor based on the desired attribute and then use it in Lovelace but then the earlier method was easier. Was that working by fluke?
My aim is to access the mean (or any other) attribute of the statistics sensor.

My sensor.yaml in HA 0.95

  # Overhead water tank
  - platform: mqtt
    name: "Overhead Tank"
    state_topic: "home/overhead_tank/SENSOR"
    value_template: '{{ value_json.SR04.Distance }}'

  - platform: statistics
    name: "Overhead Tank Stat"
    entity_id: sensor.overhead_tank
    sampling_size: 10

  - platform: template
    sensors:
      water_level:
        friendly_name: "Overhead Tank Level"
        unit_of_measurement: "%"
        value_template: >-
          {{ ((150 - states.sensor.overhead_tank_stat_mean.state | int)/ 125 *100 )| int }}

The way I was using it on Lovelace was

sensor.overhead_tank_stat_mean

New config after upgrade to HA 0.98 that works is:

  # Overhead water tank
  - platform: mqtt
    name: "Overhead Tank"
    state_topic: "home/overhead_tank/SENSOR"
    value_template: '{{ value_json.SR04.Distance }}'

  - platform: statistics
    name: "Overhead Tank Stat"
    entity_id: sensor.overhead_tank
    sampling_size: 10

  - platform: template
    sensors:
      water_level:
        friendly_name: "Overhead Tank Level"
        unit_of_measurement: "%"
        value_template: >-
          {{ ((150 - states.sensor.overhead_tank_stat.state | int)/ 125 *100 )| int }}

And Lovelace config:

sensor.overhead_tank_stat

After the upgrade I cant use “_mean” anymore. I was able to solve this as the default attribute for statistics seems to be mean and hence when I refer to sensor.overhead_tank_stat , it gives me the mean. But then if I have to refer to median , that wouldn’t work.

Any help is appreciated.

Read the breaking changes for the 0.98 update:

Statistics - The names of statistics sensor no longer get mean or count appended automatically, respecting the name configured by the user. If you use this integration, this name change will affect the name of the entity. - (@frenck - #26119 ) (statistics docs )

Thanks for the info @tom_l , I should have read the docs. But I am still not able to figure out the way this should be accessed on lovelace after this change?

Is this really true?

I’m pretty sure Lovelace does not work that way.

Or were you just accessing the default state that happened to be the _mean?

If you want to display an attribute of a sensor you have to create a template sensor from that sensor and attribute.

The entity id will change when you change change the stats sensor and you need to then use that new entity in lovelace… use developer tools to see what the new name is.