mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix roomba 980 position report (#35316)
This commit is contained in:
parent
a38bb5b33b
commit
9d5704307a
@ -98,7 +98,6 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
continuous=config_entry.options[CONF_CONTINUOUS],
|
continuous=config_entry.options[CONF_CONTINUOUS],
|
||||||
delay=config_entry.options[CONF_DELAY],
|
delay=config_entry.options[CONF_DELAY],
|
||||||
)
|
)
|
||||||
roomba.exclude = "wifistat" # ignore wifistat to avoid unnecessary updates
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not await async_connect_or_timeout(hass, roomba):
|
if not await async_connect_or_timeout(hass, roomba):
|
||||||
|
@ -45,3 +45,7 @@ class RoombaBinStatus(IRobotEntity, BinarySensorEntity):
|
|||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return roomba_reported_state(self.vacuum).get("bin", {}).get("full", False)
|
return roomba_reported_state(self.vacuum).get("bin", {}).get("full", False)
|
||||||
|
|
||||||
|
def new_state_filter(self, new_state):
|
||||||
|
"""Filter the new state."""
|
||||||
|
return "bin" in new_state
|
||||||
|
@ -102,9 +102,15 @@ class IRobotEntity(Entity):
|
|||||||
"""Register callback function."""
|
"""Register callback function."""
|
||||||
self.vacuum.register_on_message_callback(self.on_message)
|
self.vacuum.register_on_message_callback(self.on_message)
|
||||||
|
|
||||||
|
def new_state_filter(self, new_state):
|
||||||
|
"""Filter the new state."""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def on_message(self, json_data):
|
def on_message(self, json_data):
|
||||||
"""Update state on message change."""
|
"""Update state on message change."""
|
||||||
self.schedule_update_ha_state()
|
state = json_data.get("state", {}).get("reported", {})
|
||||||
|
if self.new_state_filter(state):
|
||||||
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
|
|
||||||
class IRobotVacuum(IRobotEntity, StateVacuumEntity):
|
class IRobotVacuum(IRobotEntity, StateVacuumEntity):
|
||||||
@ -212,6 +218,11 @@ class IRobotVacuum(IRobotEntity, StateVacuumEntity):
|
|||||||
|
|
||||||
def on_message(self, json_data):
|
def on_message(self, json_data):
|
||||||
"""Update state on message change."""
|
"""Update state on message change."""
|
||||||
|
new_state = json_data.get("state", {}).get("reported", {})
|
||||||
|
if (
|
||||||
|
len(new_state) == 1 and "signal" in new_state
|
||||||
|
): # filter out wifi stat messages
|
||||||
|
return
|
||||||
_LOGGER.debug("Got new state from the vacuum: %s", json_data)
|
_LOGGER.debug("Got new state from the vacuum: %s", json_data)
|
||||||
self.vacuum_state = roomba_reported_state(self.vacuum)
|
self.vacuum_state = roomba_reported_state(self.vacuum)
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
@ -46,3 +46,7 @@ class RoombaBattery(IRobotEntity):
|
|||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return roomba_reported_state(self.vacuum).get("batPct")
|
return roomba_reported_state(self.vacuum).get("batPct")
|
||||||
|
|
||||||
|
def new_state_filter(self, new_state):
|
||||||
|
"""Filter the new state."""
|
||||||
|
return "batPct" in new_state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user