Skip to content

"Battery Percentage" state_class: measurement #315

@winkler-winsen

Description

@winkler-winsen

Feature Description

Fist I love your great work. So I don't have to install my Marstek TPM-100CW anymore.

The batteryPercentage "Battery Percentage" should defined with state_class: measurement. After this precondition it gets statistics history and is selectable in Energy Dasboard | Electricity | Home battery storage | Battery state of charge sensor

I did this with a template custom sensor:

template:
  - sensor:
      - name: "Marstek Battery SoC"
        unique_id: marstek_battery_soc_energy_dashboard
        state: "{{ states('sensor.my_hm2mqtt_soc_sensor') | float(0) }}"
        unit_of_measurement: "%"
        device_class: battery
        state_class: measurement

For example B2500, maybe it's inside src/device/b2500Base.ts you can add state_class: measurement there.

field({
  key: 'pe',
  path: ['batteryPercentage'],
  transform: number(),
});

advertise(
  ['batteryPercentage'],
  sensorComponent({
    id: 'battery_percentage',
    name: 'Battery Percentage',
    device_class: 'battery',
    unit_of_measurement: '%',
    state_class: 'measurement',
  }),
);

Device Model (optional)

B2500 HMJ-2

Firmware Version (optional)

110.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions