Skip to content

Commit

Permalink
Update sensor.py
Browse files Browse the repository at this point in the history
Remove the unused local variable "e".
Unused local variables should be removed python:S1481
  • Loading branch information
Danieldiazi authored Dec 9, 2024
1 parent eeaba1d commit cec2d7b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions custom_components/honda_recall_check/sensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from homeassistant.components.sensor import SensorEntity
from .honda_api import HondaRecallAPI
from .honda_api import HondaRecallAPI, HondaRecallAPIError # Asumiendo que HondaRecallAPIError está definida allí
from .const import DOMAIN

async def async_setup_entry(hass, config_entry, async_add_entities):
Expand Down Expand Up @@ -41,9 +41,12 @@ def extra_state_attributes(self):
async def async_update(self):
try:
self._recalls = await self.hass.async_add_executor_job(self._api.check_recall)
except Exception as e:
except HondaRecallAPIError as e:
# Aquí podemos hacer un log del error si queremos.
# logger.error(f"Error al obtener recalls: {e}")
self._recalls = []


class HondaRecallBooleanSensor(SensorEntity):
"""Sensor que devuelve True/False si hay recalls."""

Expand All @@ -69,5 +72,7 @@ async def async_update(self):
try:
recalls = await self.hass.async_add_executor_job(self._api.check_recall)
self._state = len(recalls) > 0
except Exception as e:
except HondaRecallAPIError as e:
logger.error(f"Error al obtener el estado de recalls: {e}")
self._state = False

0 comments on commit cec2d7b

Please sign in to comment.