From f5b8e09fb4093ed5be1a1f4338be4a8311c2aa35 Mon Sep 17 00:00:00 2001 From: Patrick762 Date: Thu, 30 May 2024 15:03:47 +0200 Subject: [PATCH] prevent binary_sensor if controls enabled --- custom_components/bluetti_bt/binary_sensor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/custom_components/bluetti_bt/binary_sensor.py b/custom_components/bluetti_bt/binary_sensor.py index 7737c63..ab235d4 100644 --- a/custom_components/bluetti_bt/binary_sensor.py +++ b/custom_components/bluetti_bt/binary_sensor.py @@ -22,7 +22,7 @@ from .bluetti_bt_lib.field_attributes import FIELD_ATTRIBUTES, FieldType from .bluetti_bt_lib.utils.device_builder import build_device from . import device_info as dev_info, get_unique_id -from .const import DATA_COORDINATOR, DOMAIN +from .const import DATA_COORDINATOR, DOMAIN, CONF_USE_CONTROLS from .coordinator import PollingCoordinator from .utils import unique_id_loggable @@ -36,6 +36,7 @@ async def async_setup_entry( device_name = entry.data.get(CONF_NAME) address = entry.data.get(CONF_ADDRESS) + use_controls = entry.data.get(CONF_USE_CONTROLS) if address is None: _LOGGER.error("Device has no address") @@ -55,6 +56,10 @@ async def async_setup_entry( if field_config.setter is True: category = EntityCategory.DIAGNOSTIC + # Ignore setters if controls enabled + if field_config.setter is True and use_controls is True: + continue + sensors_to_add.append( BluettiBinarySensor( hass.data[DOMAIN][entry.entry_id][DATA_COORDINATOR],