Skip to content

Commit

Permalink
black and format. coordinator.py shedule_update refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
sca075 committed Oct 16, 2024
1 parent 5565a16 commit 6a1fea4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion custom_components/mqtt_vacuum_camera/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"last_bin_out": 0,
"last_bin_full": 0,
"last_loaded_map": "NoMap",
"robot_in_room": "Unsupported"
"robot_in_room": "Unsupported",
}

DEFAULT_PIXEL_SIZE = 5
Expand Down
10 changes: 6 additions & 4 deletions custom_components/mqtt_vacuum_camera/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import async_timeout
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.event import async_call_later
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed

Expand Down Expand Up @@ -60,16 +61,17 @@ def schedule_refresh(self) -> None:
"""Schedule coordinator refresh after 1 second."""
if self.scheduled_refresh:
self.scheduled_refresh.cancel()
self.scheduled_refresh = self.hass.loop.call_later(
1, lambda: asyncio.create_task(self.async_refresh())
self.scheduled_refresh = async_call_later(
self.hass, 1, lambda: asyncio.create_task(self.async_refresh())
)

async def _async_update_data(self):
"""
Fetch data from the MQTT topics for sensors.
"""
if (self.sensor_data == SENSOR_NO_DATA) or (
self.shared is not None and self.shared.vacuum_state != "docked"
if (
(self.sensor_data == SENSOR_NO_DATA)
or (self.shared is not None and self.shared.vacuum_state != "docked")
) and self.connector:
try:
async with async_timeout.timeout(10):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""
Version: v2024.11.0
- Removed the PNG decode, the json is extracted from map-data instead of map-data-hass.
- Refactoring the subscribe method and decode payload method.
"""

import asyncio
Expand Down Expand Up @@ -327,7 +325,7 @@ async def rrm_handle_active_segments(self, msg) -> None:
self._shared.rand256_active_zone = rrm_active_segments

async def async_fire_event_restart_camera(
self, event_text:str="event_vacuum_start", data:str =""
self, event_text: str = "event_vacuum_start", data: str = ""
):
"""Fire Event to reset the camera trims"""
self._hass.bus.async_fire(
Expand Down

0 comments on commit 6a1fea4

Please sign in to comment.