diff --git a/custom_components/powercalc/__init__.py b/custom_components/powercalc/__init__.py index 9771d3469..d96f923e8 100644 --- a/custom_components/powercalc/__init__.py +++ b/custom_components/powercalc/__init__.py @@ -222,7 +222,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: await discovery_manager.start_discovery() sensors: list = domain_config.get(CONF_SENSORS, []) - sorted_sensors = sorted(sensors, key=lambda x: (CONF_INCLUDE in x, x.get(CONF_INCLUDE, False))) + sorted_sensors = sorted( + sensors, key=lambda x: (CONF_INCLUDE in x, x.get(CONF_INCLUDE, False)) + ) for sensor_config in sorted_sensors: sensor_config.update({DISCOVERY_TYPE: PowercalcDiscoveryType.USER_YAML}) hass.async_create_task( diff --git a/custom_components/powercalc/sensor.py b/custom_components/powercalc/sensor.py index 006552e27..d0f0225e8 100644 --- a/custom_components/powercalc/sensor.py +++ b/custom_components/powercalc/sensor.py @@ -604,7 +604,9 @@ async def create_sensors( # noqa: C901 _LOGGER.debug("Found include entities: %s", include_entities) for source_entity in include_entities: if source_entity.entity_id in hass.data[DOMAIN][DATA_CONFIGURED_ENTITIES]: - entities_to_add.existing.extend(hass.data[DOMAIN][DATA_CONFIGURED_ENTITIES][source_entity.entity_id]) + entities_to_add.existing.extend( + hass.data[DOMAIN][DATA_CONFIGURED_ENTITIES][source_entity.entity_id] + ) # Create sensors for each entity for sensor_config in sensor_configs.values(): diff --git a/tests/group_include/test_include.py b/tests/group_include/test_include.py index 1ddcea4ad..49d8ff9a6 100644 --- a/tests/group_include/test_include.py +++ b/tests/group_include/test_include.py @@ -3,7 +3,13 @@ import pytest from homeassistant.components import light -from homeassistant.const import CONF_DOMAIN, CONF_ENTITIES, CONF_ENTITY_ID, CONF_UNIQUE_ID, STATE_OFF +from homeassistant.const import ( + CONF_DOMAIN, + CONF_ENTITIES, + CONF_ENTITY_ID, + CONF_UNIQUE_ID, + STATE_OFF, +) from homeassistant.core import HomeAssistant from homeassistant.helpers.area_registry import AreaRegistry from homeassistant.helpers.device_registry import DeviceEntry @@ -343,8 +349,9 @@ async def test_include_filter_domain( assert group_state.attributes.get(ATTR_ENTITIES) == {"sensor.test_light_power"} -async def test_include_yaml_configured_entity(hass: HomeAssistant, entity_reg: EntityRegistry, - area_reg: AreaRegistry) -> None: +async def test_include_yaml_configured_entity( + hass: HomeAssistant, entity_reg: EntityRegistry, area_reg: AreaRegistry +) -> None: """Test that include also includes entities that the user configured with YAML""" light_a = MockLight("light_a") @@ -393,7 +400,9 @@ async def test_include_yaml_configured_entity(hass: HomeAssistant, entity_reg: E } -def _create_powercalc_config_entry(hass: HomeAssistant, source_entity_id: str) -> MockConfigEntry: +def _create_powercalc_config_entry( + hass: HomeAssistant, source_entity_id: str +) -> MockConfigEntry: unique_id = str(uuid.uuid4()) entry = MockConfigEntry( domain=DOMAIN,