diff --git a/homeassistant/components/roomba/__init__.py b/homeassistant/components/roomba/__init__.py index a9efa1f24ab..5e7d47d2d57 100644 --- a/homeassistant/components/roomba/__init__.py +++ b/homeassistant/components/roomba/__init__.py @@ -98,7 +98,6 @@ async def async_setup_entry(hass, config_entry): continuous=config_entry.options[CONF_CONTINUOUS], delay=config_entry.options[CONF_DELAY], ) - roomba.exclude = "wifistat" # ignore wifistat to avoid unnecessary updates try: if not await async_connect_or_timeout(hass, roomba): diff --git a/homeassistant/components/roomba/binary_sensor.py b/homeassistant/components/roomba/binary_sensor.py index fb11a0f9d4c..d1aac7931de 100644 --- a/homeassistant/components/roomba/binary_sensor.py +++ b/homeassistant/components/roomba/binary_sensor.py @@ -45,3 +45,7 @@ class RoombaBinStatus(IRobotEntity, BinarySensorEntity): def state(self): """Return the state of the sensor.""" 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 diff --git a/homeassistant/components/roomba/irobot_base.py b/homeassistant/components/roomba/irobot_base.py index 6c35582c2c2..524b5a915f9 100644 --- a/homeassistant/components/roomba/irobot_base.py +++ b/homeassistant/components/roomba/irobot_base.py @@ -102,9 +102,15 @@ class IRobotEntity(Entity): """Register callback function.""" 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): """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): @@ -212,6 +218,11 @@ class IRobotVacuum(IRobotEntity, StateVacuumEntity): def on_message(self, json_data): """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) self.vacuum_state = roomba_reported_state(self.vacuum) self.schedule_update_ha_state() diff --git a/homeassistant/components/roomba/sensor.py b/homeassistant/components/roomba/sensor.py index 1a10c429321..40dbd52e158 100644 --- a/homeassistant/components/roomba/sensor.py +++ b/homeassistant/components/roomba/sensor.py @@ -46,3 +46,7 @@ class RoombaBattery(IRobotEntity): def state(self): """Return the state of the sensor.""" return roomba_reported_state(self.vacuum).get("batPct") + + def new_state_filter(self, new_state): + """Filter the new state.""" + return "batPct" in new_state