From 6174aa4e5934e7ebd18e6ef8c4210863719c0328 Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Tue, 30 Jan 2024 21:18:54 +0100 Subject: [PATCH] Remove Shelly RSSI sensor if Wi-FI is not configured (#108390) * Remove Shelly RSSI sensor if Wi-FI is not configured * fix tests --- homeassistant/components/shelly/sensor.py | 3 +++ tests/components/shelly/conftest.py | 1 + 2 files changed, 4 insertions(+) diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index 7ae709ae84f..57e60c8fc48 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -907,6 +907,9 @@ RPC_SENSORS: Final = { device_class=SensorDeviceClass.SIGNAL_STRENGTH, state_class=SensorStateClass.MEASUREMENT, entity_registry_enabled_default=False, + removal_condition=lambda config, _status, key: ( + config[key]["sta"]["enable"] is False + ), entity_category=EntityCategory.DIAGNOSTIC, use_polling_coordinator=True, ), diff --git a/tests/components/shelly/conftest.py b/tests/components/shelly/conftest.py index af373f33c23..9d7bb9404f8 100644 --- a/tests/components/shelly/conftest.py +++ b/tests/components/shelly/conftest.py @@ -159,6 +159,7 @@ MOCK_CONFIG = { "ui_data": {}, "device": {"name": "Test name"}, }, + "wifi": {"sta": {"enable": True}}, } MOCK_SHELLY_COAP = {