diff --git a/homeassistant/components/smlight/binary_sensor.py b/homeassistant/components/smlight/binary_sensor.py index d273460e20660..b1aba3a52fe2c 100644 --- a/homeassistant/components/smlight/binary_sensor.py +++ b/homeassistant/components/smlight/binary_sensor.py @@ -39,6 +39,12 @@ class SmBinarySensorEntityDescription(BinarySensorEntityDescription): translation_key="ethernet", value_fn=lambda x: x.ethernet, ), + SmBinarySensorEntityDescription( + key="vpn", + translation_key="vpn", + entity_registry_enabled_default=False, + value_fn=lambda x: x.vpn_status, + ), SmBinarySensorEntityDescription( key="wifi", translation_key="wifi", diff --git a/homeassistant/components/smlight/strings.json b/homeassistant/components/smlight/strings.json index 812218287a95f..97797feae2ad2 100644 --- a/homeassistant/components/smlight/strings.json +++ b/homeassistant/components/smlight/strings.json @@ -49,6 +49,9 @@ "internet": { "name": "Internet" }, + "vpn": { + "name": "VPN" + }, "wifi": { "name": "Wi-Fi" } @@ -116,6 +119,9 @@ }, "night_mode": { "name": "LED night mode" + }, + "vpn_enabled": { + "name": "VPN enabled" } }, "update": { diff --git a/homeassistant/components/smlight/switch.py b/homeassistant/components/smlight/switch.py index 930875335d1eb..c1173f2233874 100644 --- a/homeassistant/components/smlight/switch.py +++ b/homeassistant/components/smlight/switch.py @@ -54,6 +54,13 @@ class SmSwitchEntityDescription(SwitchEntityDescription): setting=Settings.ZB_AUTOUPDATE, state_fn=lambda x: x.auto_zigbee, ), + SmSwitchEntityDescription( + key="vpn_enabled", + translation_key="vpn_enabled", + setting=Settings.ENABLE_VPN, + entity_registry_enabled_default=False, + state_fn=lambda x: x.vpn_enabled, + ), ] diff --git a/tests/components/smlight/fixtures/info.json b/tests/components/smlight/fixtures/info.json index 8f1e718ca7441..e3defb4410e5d 100644 --- a/tests/components/smlight/fixtures/info.json +++ b/tests/components/smlight/fixtures/info.json @@ -11,6 +11,7 @@ "sw_version": "v2.3.6", "wifi_mode": 0, "zb_flash_size": 704, + "zb_channel": 0, "zb_hw": "CC2652P7", "zb_ram_size": 152, "zb_version": "20240314", diff --git a/tests/components/smlight/fixtures/sensors.json b/tests/components/smlight/fixtures/sensors.json index 89ec5615f3455..ea1fb9c1899f7 100644 --- a/tests/components/smlight/fixtures/sensors.json +++ b/tests/components/smlight/fixtures/sensors.json @@ -10,5 +10,7 @@ "wifi_status": 255, "disable_leds": false, "night_mode": true, - "auto_zigbee": false + "auto_zigbee": false, + "vpn_enabled": false, + "vpn_status": true } diff --git a/tests/components/smlight/snapshots/test_binary_sensor.ambr b/tests/components/smlight/snapshots/test_binary_sensor.ambr index 17dca1c9784e2..8becf5b2567bc 100644 --- a/tests/components/smlight/snapshots/test_binary_sensor.ambr +++ b/tests/components/smlight/snapshots/test_binary_sensor.ambr @@ -93,6 +93,53 @@ 'state': 'unknown', }) # --- +# name: test_all_binary_sensors[binary_sensor.mock_title_vpn-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.mock_title_vpn', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'VPN', + 'platform': 'smlight', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'vpn', + 'unique_id': 'aa:bb:cc:dd:ee:ff_vpn', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_binary_sensors[binary_sensor.mock_title_vpn-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'connectivity', + 'friendly_name': 'Mock Title VPN', + }), + 'context': , + 'entity_id': 'binary_sensor.mock_title_vpn', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- # name: test_all_binary_sensors[binary_sensor.mock_title_wi_fi-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/smlight/snapshots/test_switch.ambr b/tests/components/smlight/snapshots/test_switch.ambr index b8e1c8357ac47..733d002be0f49 100644 --- a/tests/components/smlight/snapshots/test_switch.ambr +++ b/tests/components/smlight/snapshots/test_switch.ambr @@ -140,3 +140,50 @@ 'state': 'on', }) # --- +# name: test_switch_setup[switch.mock_title_vpn_enabled-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'switch', + 'entity_category': None, + 'entity_id': 'switch.mock_title_vpn_enabled', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'VPN enabled', + 'platform': 'smlight', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'vpn_enabled', + 'unique_id': 'aa:bb:cc:dd:ee:ff-vpn_enabled', + 'unit_of_measurement': None, + }) +# --- +# name: test_switch_setup[switch.mock_title_vpn_enabled-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'switch', + 'friendly_name': 'Mock Title VPN enabled', + }), + 'context': , + 'entity_id': 'switch.mock_title_vpn_enabled', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- diff --git a/tests/components/smlight/test_binary_sensor.py b/tests/components/smlight/test_binary_sensor.py index ce7d4e3ff6d4a..1b1c0358c3706 100644 --- a/tests/components/smlight/test_binary_sensor.py +++ b/tests/components/smlight/test_binary_sensor.py @@ -62,11 +62,14 @@ async def test_disabled_by_default_sensors( """Test wifi sensor is disabled by default .""" await setup_integration(hass, mock_config_entry) - assert not hass.states.get("binary_sensor.mock_title_wi_fi") - - assert (entry := entity_registry.async_get("binary_sensor.mock_title_wi_fi")) - assert entry.disabled - assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION + for sensor in ("wi_fi", "vpn"): + assert not hass.states.get(f"binary_sensor.mock_title_{sensor}") + + assert ( + entry := entity_registry.async_get(f"binary_sensor.mock_title_{sensor}") + ) + assert entry.disabled + assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION async def test_internet_sensor_event( diff --git a/tests/components/smlight/test_switch.py b/tests/components/smlight/test_switch.py index a29dfbc35c2e6..a917a10da08b4 100644 --- a/tests/components/smlight/test_switch.py +++ b/tests/components/smlight/test_switch.py @@ -34,6 +34,7 @@ def platforms() -> list[Platform]: return [Platform.SWITCH] +@pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_switch_setup( hass: HomeAssistant, entity_registry: er.EntityRegistry, @@ -46,12 +47,29 @@ async def test_switch_setup( await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) +async def test_disabled_by_default_switch( + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + mock_config_entry: MockConfigEntry, +) -> None: + """Test vpn enabled switch is disabled by default .""" + await setup_integration(hass, mock_config_entry) + + assert not hass.states.get("switch.mock_title_vpn_enabled") + + assert (entry := entity_registry.async_get("switch.mock_title_vpn_enabled")) + assert entry.disabled + assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION + + +@pytest.mark.usefixtures("entity_registry_enabled_by_default") @pytest.mark.parametrize( ("entity", "setting"), [ ("disable_leds", Settings.DISABLE_LEDS), ("led_night_mode", Settings.NIGHT_MODE), ("auto_zigbee_update", Settings.ZB_AUTOUPDATE), + ("vpn_enabled", Settings.ENABLE_VPN), ], ) async def test_switches(