Skip to content

Commit 4405596

Browse files
committed
Added missing feed unit mismatch failsafe to pets entities
1 parent ea35bdf commit 4405596

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

custom_components/petlibro/pets/entity.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ def portions_enabled(self) -> bool:
214214
@property
215215
def enable_for_manual_feed(self) -> bool:
216216
"""Return True if entity should be enabled for manual feed setting."""
217-
if self.desc.petlibro_unit != API.FEED_UNIT:
217+
if (
218+
self.desc.petlibro_unit != API.FEED_UNIT
219+
or "feedingGoal" not in self.desc.key
220+
):
218221
return True
219222

220223
domain = self.platform_data.domain
@@ -232,6 +235,13 @@ async def async_added_to_hass(self) -> None:
232235
self.async_on_remove(self.pet.on(EVENT_UPDATE, self.async_write_ha_state))
233236

234237
def _handle_coordinator_update(self) -> None:
238+
if (
239+
"feedingGoal" in self.desc.key
240+
and self.enabled != self.enable_for_manual_feed
241+
):
242+
self.hub.unit_entities.schedule_manual_feed_sync()
243+
_LOGGER.warning("Feed unit mismatch, reloading integration.")
244+
235245
if self.enabled:
236246
super()._handle_coordinator_update()
237247

0 commit comments

Comments
 (0)