Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Set initial state later in the process #129

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions custom_components/aquarea/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ def __init__(
self._attr_unique_id = (
f"{config_entry.entry_id}-{description.heishamon_topic_id}"
)
if self.entity_description.initial_value is not None:
self._attr_native_value = self.entity_description.initial_value
self.async_write_ha_state()

async def async_set_native_value(self, value: float) -> None:
_LOGGER.debug(
Expand All @@ -82,6 +79,10 @@ async def async_set_native_value(self, value: float) -> None:
async def async_added_to_hass(self) -> None:
"""Subscribe to MQTT events."""

if self.entity_description.initial_value is not None:
self._attr_native_value = self.entity_description.initial_value
self.async_write_ha_state()

@callback
def message_received(message):
"""Handle new MQTT messages."""
Expand Down
Loading