Skip to content

Commit

Permalink
2023.11.b2
Browse files Browse the repository at this point in the history
  • Loading branch information
dckiller51 committed Nov 25, 2023
1 parent 5614bd1 commit abb2ee4
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions custom_components/bodymiscale/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
from typing import Any

from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
PERCENTAGE,
UnitOfMass,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
Expand Down Expand Up @@ -63,6 +68,8 @@ async def async_setup_entry(
SensorEntityDescription(
key=ATTR_BMR,
translation_key="basal_metabolism",
suggested_display_precision=0,
native_unit_of_measurement="kcal",
),
Metric.BMR,
),
Expand All @@ -71,6 +78,7 @@ async def async_setup_entry(
SensorEntityDescription(
key=ATTR_VISCERAL,
translation_key="visceral_fat",
suggested_display_precision=0,
),
Metric.VISCERAL_FAT,
),
Expand All @@ -79,8 +87,8 @@ async def async_setup_entry(
SensorEntityDescription(
key=CONF_SENSOR_WEIGHT,
translation_key="weight",
icon="mdi:weight-kilogram",
native_unit_of_measurement="kg",
native_unit_of_measurement=UnitOfMass.KILOGRAMS,
device_class=SensorDeviceClass.WEIGHT,
),
Metric.WEIGHT,
lambda _, config: {ATTR_IDEAL: get_ideal_weight(config)},
Expand All @@ -103,7 +111,7 @@ async def async_setup_entry(
SensorEntityDescription(
key=ATTR_FAT,
translation_key="body_fat",
native_unit_of_measurement="%",
native_unit_of_measurement=PERCENTAGE,
),
Metric.FAT_PERCENTAGE,
),
Expand All @@ -112,7 +120,7 @@ async def async_setup_entry(
SensorEntityDescription(
key=ATTR_PROTEIN,
translation_key="protein",
native_unit_of_measurement="%",
native_unit_of_measurement=PERCENTAGE,
),
Metric.PROTEIN_PERCENTAGE,
),
Expand All @@ -122,7 +130,7 @@ async def async_setup_entry(
key=ATTR_WATER,
translation_key="water",
icon="mdi:water-percent",
native_unit_of_measurement="%",
native_unit_of_measurement=PERCENTAGE,
),
Metric.WATER_PERCENTAGE,
),
Expand All @@ -131,6 +139,8 @@ async def async_setup_entry(
SensorEntityDescription(
key=ATTR_BONES,
translation_key="bone_mass",
native_unit_of_measurement=UnitOfMass.KILOGRAMS,
device_class=SensorDeviceClass.WEIGHT,
),
Metric.BONE_MASS,
),
Expand All @@ -139,6 +149,8 @@ async def async_setup_entry(
SensorEntityDescription(
key=ATTR_MUSCLE,
translation_key="muscle_mass",
native_unit_of_measurement=UnitOfMass.KILOGRAMS,
device_class=SensorDeviceClass.WEIGHT,
),
Metric.MUSCLE_MASS,
),
Expand All @@ -147,6 +159,7 @@ async def async_setup_entry(
SensorEntityDescription(
key=ATTR_METABOLIC,
translation_key="metabolic_age",
suggested_display_precision=0,
),
Metric.METABOLIC_AGE,
),
Expand All @@ -155,6 +168,7 @@ async def async_setup_entry(
SensorEntityDescription(
key=ATTR_BODY_SCORE,
translation_key="body_score",
suggested_display_precision=0,
),
Metric.BODY_SCORE,
),
Expand Down

0 comments on commit abb2ee4

Please sign in to comment.