added validation for polling interval

This commit is contained in:
Patrick762 committed 2023-08-26 15:54:33 +02:00
1 parent 15216e1268
commit a5ced35d32
6 files changed
+22 -11

No files matched your search

@@ -35,7 +35,7 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Setup sensor entities."""
"""Setup binary_sensor entities."""
device_name = entry.data.get(CONF_NAME)
address = entry.data.get(CONF_ADDRESS)
@@ -43,7 +43,7 @@ async def async_setup_entry(
_LOGGER.error("Device has no address")
# Generate device info
_LOGGER.info("Creating sensors for device with address %s", address)
_LOGGER.info("Creating binary_sensors for device with address %s", address)
device_info = dev_info(entry)
# Add sensors according to device_info
@@ -105,8 +105,8 @@ class BluettiBinarySensor(CoordinatorEntity, BinarySensorEntity):
"""Handle updated data from the coordinator."""
_LOGGER.debug("Updating state of %s", self._attr_unique_id)
if not isinstance(self.coordinator.data, dict):
_LOGGER.error(
"Invalid data from coordinator (sensor.%s)", self._attr_unique_id
_LOGGER.debug(
"Invalid data from coordinator (binary_sensor.%s)", self._attr_unique_id
)
self._attr_available = False
return
@@ -118,7 +118,7 @@ class BluettiBinarySensor(CoordinatorEntity, BinarySensorEntity):
if not isinstance(response_data, bool):
_LOGGER.warning(
"Invalid response data type from coordinator (sensor.%s): %s",
"Invalid response data type from coordinator (binary_sensor.%s): %s",
self._attr_unique_id,
response_data,
)