Skip to content

Commit

Permalink
added sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
dudanov committed Jul 16, 2024
1 parent d062631 commit c79151d
Showing 1 changed file with 85 additions and 18 deletions.
103 changes: 85 additions & 18 deletions custom_components/ftms/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@

_LOGGER = logging.getLogger(__name__)

_CADENCE_INSTANT = SensorEntityDescription(
key=c.CADENCE_INSTANT,
_CADENCE_AVERAGE = SensorEntityDescription(
key=c.CADENCE_AVERAGE,
native_unit_of_measurement="rpm",
state_class=SensorStateClass.MEASUREMENT,
icon="mdi:horizontal-rotate-counterclockwise",
)


_SPEED_INSTANT = SensorEntityDescription(
key=c.SPEED_INSTANT,
device_class=SensorDeviceClass.SPEED,
native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
_CADENCE_INSTANT = SensorEntityDescription(
key=c.CADENCE_INSTANT,
native_unit_of_measurement="rpm",
state_class=SensorStateClass.MEASUREMENT,
icon="mdi:horizontal-rotate-counterclockwise",
)


_DISTANCE_TOTAL = SensorEntityDescription(
key=c.DISTANCE_TOTAL,
device_class=SensorDeviceClass.DISTANCE,
Expand All @@ -38,9 +36,48 @@
icon="mdi:map-marker-distance",
)

_RESISTANCE_LEVEL = SensorEntityDescription(
key=c.RESISTANCE_LEVEL,
icon="mdi:chart-timeline-variant",
_ELEVATION_GAIN_NEGATIVE = SensorEntityDescription(
key=c.ELEVATION_GAIN_NEGATIVE,
device_class=SensorDeviceClass.DISTANCE,
native_unit_of_measurement=UnitOfLength.METERS,
state_class=SensorStateClass.TOTAL,
icon="mdi:map-marker-distance",
)

_ELEVATION_GAIN_POSITIVE = SensorEntityDescription(
key=c.ELEVATION_GAIN_POSITIVE,
device_class=SensorDeviceClass.DISTANCE,
native_unit_of_measurement=UnitOfLength.METERS,
state_class=SensorStateClass.TOTAL,
icon="mdi:map-marker-distance",
)

_ENERGY_PER_HOUR = SensorEntityDescription(
key=c.ENERGY_PER_HOUR,
native_unit_of_measurement="kcal",
state_class=SensorStateClass.MEASUREMENT,
icon="mdi:food",
)

_ENERGY_PER_MINUTE = SensorEntityDescription(
key=c.ENERGY_PER_MINUTE,
native_unit_of_measurement="kcal",
state_class=SensorStateClass.MEASUREMENT,
icon="mdi:food",
)

_ENERGY_TOTAL = SensorEntityDescription(
key=c.ENERGY_TOTAL,
native_unit_of_measurement="kcal",
state_class=SensorStateClass.TOTAL,
icon="mdi:food",
)

_FORCE_ON_BELT = SensorEntityDescription(
key=c.FORCE_ON_BELT,
native_unit_of_measurement="N",
state_class=SensorStateClass.MEASUREMENT,
icon="mdi:food",
)

_HEART_RATE = SensorEntityDescription(
Expand All @@ -50,6 +87,43 @@
state_class=SensorStateClass.MEASUREMENT,
)

_INCLINATION = SensorEntityDescription(
key=c.INCLINATION,
icon="mdi:heart-pulse",
native_unit_of_measurement="%",
state_class=SensorStateClass.MEASUREMENT,
)

_METABOLIC_EQUIVALENT = SensorEntityDescription(
key=c.METABOLIC_EQUIVALENT,
icon="mdi:heart-pulse",
native_unit_of_measurement="meta",
state_class=SensorStateClass.MEASUREMENT,
)

_MOVEMENT_DIRECTION = SensorEntityDescription(
key=c.MOVEMENT_DIRECTION,
icon="mdi:heart-pulse",
device_class=SensorDeviceClass.ENUM,
state_class=SensorStateClass.MEASUREMENT,
options=[],
)



_SPEED_INSTANT = SensorEntityDescription(
key=c.SPEED_INSTANT,
device_class=SensorDeviceClass.SPEED,
native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
state_class=SensorStateClass.MEASUREMENT,
)


_RESISTANCE_LEVEL = SensorEntityDescription(
key=c.RESISTANCE_LEVEL,
icon="mdi:chart-timeline-variant",
)

_POWER_INSTANT = SensorEntityDescription(
key=c.POWER_INSTANT,
device_class=SensorDeviceClass.POWER,
Expand All @@ -65,13 +139,6 @@
icon="mdi:timer-play",
)

_ENERGY_TOTAL = SensorEntityDescription(
key=c.ENERGY_TOTAL,
native_unit_of_measurement="kcal",
state_class=SensorStateClass.TOTAL,
icon="mdi:food",
)

_ENTITIES = {
c.CADENCE_INSTANT: _CADENCE_INSTANT,
c.SPEED_INSTANT: _SPEED_INSTANT,
Expand Down

0 comments on commit c79151d

Please sign in to comment.