Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dudanov committed Oct 26, 2024
1 parent 594228c commit 8c24ea5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions custom_components/ftms/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
},
"time_remaining": {
"default": "mdi:timer-stop"
},
"training_status": {
"default": "mdi:checkbox-marked-outline"
}
},
"switch": {
Expand Down
13 changes: 10 additions & 3 deletions custom_components/ftms/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from pyftms import TrainingStatusCode
from pyftms import MovementDirection, TrainingStatusCode
from pyftms.client import const as c

from . import FtmsConfigEntry
Expand Down Expand Up @@ -103,7 +103,7 @@
_MOVEMENT_DIRECTION = SensorEntityDescription(
key=c.MOVEMENT_DIRECTION,
device_class=SensorDeviceClass.ENUM,
options=["forward", "backward"],
options=[x.name.lower() for x in MovementDirection],
)

_PACE_AVERAGE = SensorEntityDescription(
Expand Down Expand Up @@ -275,6 +275,11 @@
c.TIME_REMAINING: _TIME_REMAINING,
}

_DEFAULT_VALUES = {
c.MOVEMENT_DIRECTION: "forward",
TRAINING_STATUS: "idle",
}


async def async_setup_entry(
hass: HomeAssistant,
Expand Down Expand Up @@ -306,7 +311,9 @@ async def async_setup_entry(
class FtmsSensorEntity(FtmsEntity, SensorEntity):
"""Representation of FTMS sensors."""

_attr_native_value = 0
def __init__(self, entry, description) -> None:
self._attr_native_value = _DEFAULT_VALUES.get(self.key, 0)
super().__init__(entry, description)

@callback
def _handle_coordinator_update(self) -> None:
Expand Down

0 comments on commit 8c24ea5

Please sign in to comment.