diff --git a/homeassistant/const.py b/homeassistant/const.py index 2f9a90032ef..74fe6adfdfd 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -764,11 +764,9 @@ CLOUD_NEVER_EXPOSED_ENTITIES: Final[list[str]] = ["group.all_locks"] # use the EntityCategory enum instead. ENTITY_CATEGORY_CONFIG: Final = "config" ENTITY_CATEGORY_DIAGNOSTIC: Final = "diagnostic" -ENTITY_CATEGORY_SYSTEM: Final = "system" ENTITY_CATEGORIES: Final[list[str]] = [ ENTITY_CATEGORY_CONFIG, ENTITY_CATEGORY_DIAGNOSTIC, - ENTITY_CATEGORY_SYSTEM, ] # The ID of the Home Assistant Media Player Cast App diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index f07f4c1c7b8..c8faad53b0e 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -200,9 +200,6 @@ class EntityCategory(StrEnum): # Diagnostic: An entity exposing some configuration parameter or diagnostics of a device DIAGNOSTIC = "diagnostic" - # System: An entity which is not useful for the user to interact with - SYSTEM = "system" - ENTITY_CATEGORIES_SCHEMA: Final = vol.Coerce(EntityCategory) diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index 6972dbf7c16..3d57a9c3dc0 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -519,8 +519,8 @@ class EntityPlatform: config_entry=self.config_entry, device_id=device_id, disabled_by=disabled_by, - hidden_by=hidden_by, entity_category=entity.entity_category, + hidden_by=hidden_by, known_object_ids=self.entities.keys(), original_device_class=entity.device_class, original_icon=entity.icon, diff --git a/tests/components/alexa/test_entities.py b/tests/components/alexa/test_entities.py index 5f64879b535..fb364dbf14e 100644 --- a/tests/components/alexa/test_entities.py +++ b/tests/components/alexa/test_entities.py @@ -43,20 +43,13 @@ async def test_categorized_hidden_entities(hass): entity_category=EntityCategory.DIAGNOSTIC, ) entity_entry3 = entity_registry.async_get_or_create( - "switch", - "test", - "switch_system_id", - suggested_object_id="system_switch", - entity_category=EntityCategory.SYSTEM, - ) - entity_entry4 = entity_registry.async_get_or_create( "switch", "test", "switch_hidden_integration_id", suggested_object_id="hidden_integration_switch", hidden_by=er.RegistryEntryHider.INTEGRATION, ) - entity_entry5 = entity_registry.async_get_or_create( + entity_entry4 = entity_registry.async_get_or_create( "switch", "test", "switch_hidden_user_id", @@ -69,7 +62,6 @@ async def test_categorized_hidden_entities(hass): hass.states.async_set(entity_entry2.entity_id, "something_else") hass.states.async_set(entity_entry3.entity_id, "blah") hass.states.async_set(entity_entry4.entity_id, "foo") - hass.states.async_set(entity_entry5.entity_id, "bar") msg = await smart_home.async_handle_message(hass, get_default_config(hass), request) diff --git a/tests/components/cloud/test_alexa_config.py b/tests/components/cloud/test_alexa_config.py index 115d39d3aeb..465ff7dd3d4 100644 --- a/tests/components/cloud/test_alexa_config.py +++ b/tests/components/cloud/test_alexa_config.py @@ -39,20 +39,13 @@ async def test_alexa_config_expose_entity_prefs(hass, cloud_prefs, cloud_stub): entity_category=EntityCategory.DIAGNOSTIC, ) entity_entry3 = entity_registry.async_get_or_create( - "light", - "test", - "light_system_id", - suggested_object_id="system_light", - entity_category=EntityCategory.SYSTEM, - ) - entity_entry4 = entity_registry.async_get_or_create( "light", "test", "light_hidden_integration_id", suggested_object_id="hidden_integration_light", hidden_by=er.RegistryEntryHider.INTEGRATION, ) - entity_entry5 = entity_registry.async_get_or_create( + entity_entry4 = entity_registry.async_get_or_create( "light", "test", "light_hidden_user_id", @@ -77,7 +70,6 @@ async def test_alexa_config_expose_entity_prefs(hass, cloud_prefs, cloud_stub): assert not conf.should_expose(entity_entry2.entity_id) assert not conf.should_expose(entity_entry3.entity_id) assert not conf.should_expose(entity_entry4.entity_id) - assert not conf.should_expose(entity_entry5.entity_id) entity_conf["should_expose"] = True assert conf.should_expose("light.kitchen") @@ -86,7 +78,6 @@ async def test_alexa_config_expose_entity_prefs(hass, cloud_prefs, cloud_stub): assert not conf.should_expose(entity_entry2.entity_id) assert not conf.should_expose(entity_entry3.entity_id) assert not conf.should_expose(entity_entry4.entity_id) - assert not conf.should_expose(entity_entry5.entity_id) entity_conf["should_expose"] = None assert conf.should_expose("light.kitchen") @@ -95,7 +86,6 @@ async def test_alexa_config_expose_entity_prefs(hass, cloud_prefs, cloud_stub): assert not conf.should_expose(entity_entry2.entity_id) assert not conf.should_expose(entity_entry3.entity_id) assert not conf.should_expose(entity_entry4.entity_id) - assert not conf.should_expose(entity_entry5.entity_id) assert "alexa" not in hass.config.components await cloud_prefs.async_update( diff --git a/tests/components/cloud/test_google_config.py b/tests/components/cloud/test_google_config.py index 95746eb67ae..a86f1f3cf8a 100644 --- a/tests/components/cloud/test_google_config.py +++ b/tests/components/cloud/test_google_config.py @@ -298,20 +298,13 @@ async def test_google_config_expose_entity_prefs(hass, mock_conf, cloud_prefs): entity_category=EntityCategory.DIAGNOSTIC, ) entity_entry3 = entity_registry.async_get_or_create( - "light", - "test", - "light_system_id", - suggested_object_id="system_light", - entity_category=EntityCategory.SYSTEM, - ) - entity_entry4 = entity_registry.async_get_or_create( "light", "test", "light_hidden_integration_id", suggested_object_id="hidden_integration_light", hidden_by=er.RegistryEntryHider.INTEGRATION, ) - entity_entry5 = entity_registry.async_get_or_create( + entity_entry4 = entity_registry.async_get_or_create( "light", "test", "light_hidden_user_id", @@ -328,14 +321,12 @@ async def test_google_config_expose_entity_prefs(hass, mock_conf, cloud_prefs): state = State("light.kitchen", "on") state_config = State(entity_entry1.entity_id, "on") state_diagnostic = State(entity_entry2.entity_id, "on") - state_system = State(entity_entry3.entity_id, "on") - state_hidden_integration = State(entity_entry4.entity_id, "on") - state_hidden_user = State(entity_entry5.entity_id, "on") + state_hidden_integration = State(entity_entry3.entity_id, "on") + state_hidden_user = State(entity_entry4.entity_id, "on") assert not mock_conf.should_expose(state) assert not mock_conf.should_expose(state_config) assert not mock_conf.should_expose(state_diagnostic) - assert not mock_conf.should_expose(state_system) assert not mock_conf.should_expose(state_hidden_integration) assert not mock_conf.should_expose(state_hidden_user) @@ -344,7 +335,6 @@ async def test_google_config_expose_entity_prefs(hass, mock_conf, cloud_prefs): # categorized and hidden entities should not be exposed assert not mock_conf.should_expose(state_config) assert not mock_conf.should_expose(state_diagnostic) - assert not mock_conf.should_expose(state_system) assert not mock_conf.should_expose(state_hidden_integration) assert not mock_conf.should_expose(state_hidden_user) @@ -353,7 +343,6 @@ async def test_google_config_expose_entity_prefs(hass, mock_conf, cloud_prefs): # categorized and hidden entities should not be exposed assert not mock_conf.should_expose(state_config) assert not mock_conf.should_expose(state_diagnostic) - assert not mock_conf.should_expose(state_system) assert not mock_conf.should_expose(state_hidden_integration) assert not mock_conf.should_expose(state_hidden_user) diff --git a/tests/components/energy/test_sensor.py b/tests/components/energy/test_sensor.py index 913a2f44d93..997f60a8899 100644 --- a/tests/components/energy/test_sensor.py +++ b/tests/components/energy/test_sensor.py @@ -75,6 +75,40 @@ async def test_cost_sensor_no_states(hass, hass_storage, setup_integration) -> N # TODO: No states, should the cost entity refuse to setup? +async def test_cost_sensor_attributes(hass, hass_storage, setup_integration) -> None: + """Test sensor attributes.""" + energy_data = data.EnergyManager.default_preferences() + energy_data["energy_sources"].append( + { + "type": "grid", + "flow_from": [ + { + "stat_energy_from": "sensor.energy_consumption", + "entity_energy_from": "sensor.energy_consumption", + "stat_cost": None, + "entity_energy_price": None, + "number_energy_price": 1, + } + ], + "flow_to": [], + "cost_adjustment_day": 0, + } + ) + + hass_storage[data.STORAGE_KEY] = { + "version": 1, + "data": energy_data, + } + await setup_integration(hass) + + registry = er.async_get(hass) + cost_sensor_entity_id = "sensor.energy_consumption_cost" + entry = registry.async_get(cost_sensor_entity_id) + assert entry.entity_category is None + assert entry.disabled_by is None + assert entry.hidden_by == er.RegistryEntryHider.INTEGRATION + + @pytest.mark.parametrize("initial_energy,initial_cost", [(0, "0.0"), (None, "unknown")]) @pytest.mark.parametrize( "price_entity,fixed_price", [("sensor.energy_price", None), (None, 1)] diff --git a/tests/components/google_assistant/test_google_assistant.py b/tests/components/google_assistant/test_google_assistant.py index 642ef15451a..8bf0e5573b2 100644 --- a/tests/components/google_assistant/test_google_assistant.py +++ b/tests/components/google_assistant/test_google_assistant.py @@ -147,20 +147,13 @@ async def test_sync_request(hass_fixture, assistant_client, auth_header): entity_category=EntityCategory.DIAGNOSTIC, ) entity_entry3 = entity_registry.async_get_or_create( - "switch", - "test", - "switch_system_id", - suggested_object_id="system_switch", - entity_category=EntityCategory.SYSTEM, - ) - entity_entry4 = entity_registry.async_get_or_create( "switch", "test", "switch_hidden_integration_id", suggested_object_id="hidden_integration_switch", hidden_by=er.RegistryEntryHider.INTEGRATION, ) - entity_entry5 = entity_registry.async_get_or_create( + entity_entry4 = entity_registry.async_get_or_create( "switch", "test", "switch_hidden_user_id", @@ -173,7 +166,6 @@ async def test_sync_request(hass_fixture, assistant_client, auth_header): hass_fixture.states.async_set(entity_entry2.entity_id, "something_else") hass_fixture.states.async_set(entity_entry3.entity_id, "blah") hass_fixture.states.async_set(entity_entry4.entity_id, "foo") - hass_fixture.states.async_set(entity_entry5.entity_id, "bar") reqid = "5711642932632160983" data = {"requestId": reqid, "inputs": [{"intent": "action.devices.SYNC"}]} diff --git a/tests/helpers/test_entity.py b/tests/helpers/test_entity.py index 34cb68403f4..e345d7d7258 100644 --- a/tests/helpers/test_entity.py +++ b/tests/helpers/test_entity.py @@ -913,7 +913,6 @@ async def test_entity_category_property(hass): ( ("config", entity.EntityCategory.CONFIG), ("diagnostic", entity.EntityCategory.DIAGNOSTIC), - ("system", entity.EntityCategory.SYSTEM), ), ) def test_entity_category_schema(value, expected): @@ -930,7 +929,7 @@ def test_entity_category_schema_error(value): schema = vol.Schema(entity.ENTITY_CATEGORIES_SCHEMA) with pytest.raises( vol.Invalid, - match=r"expected EntityCategory or one of 'config', 'diagnostic', 'system'", + match=r"expected EntityCategory or one of 'config', 'diagnostic'", ): schema(value)