Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Fixed: expiration slider doesn't update UI state
Browse files Browse the repository at this point in the history
  • Loading branch information
formatBCE committed Jul 24, 2022
1 parent c94ba01 commit c0883db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 0 additions & 2 deletions custom_components/format_ble_tracker/README.md

This file was deleted.

14 changes: 9 additions & 5 deletions custom_components/format_ble_tracker/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ async def async_added_to_hass(self):
"""Entity has been added to hass, restoring state"""
restored = await self.async_get_last_number_data()
native_value = 2 if restored is None else restored.native_value
self._attr_native_value = native_value
await self.coordinator.on_expiration_time_changed(native_value)
self.async_write_ha_state()
await self.update_value(native_value)

async def async_set_native_value(self, value: float) -> None:
"""Update the current value."""
val = min(10, max(1, int(value)))
self._attr_native_value = val
await self.coordinator.on_expiration_time_changed(val)
await self.update_value(val)


async def update_value(self, value: int):
"""Set value to HA and coordinator"""
self._attr_native_value = value
await self.coordinator.on_expiration_time_changed(value)
self.async_write_ha_state()

0 comments on commit c0883db

Please sign in to comment.