diff --git a/homeassistant/components/matter/binary_sensor.py b/homeassistant/components/matter/binary_sensor.py index 71e43d6dfffc1..58c6edff0702b 100644 --- a/homeassistant/components/matter/binary_sensor.py +++ b/homeassistant/components/matter/binary_sensor.py @@ -489,6 +489,7 @@ def _update_from_device(self) -> None: platform=Platform.BINARY_SENSOR, entity_description=MatterBinarySensorEntityDescription( key="WindowCoveringConfigStatusOperational", + translation_key="config_status_operational", device_class=BinarySensorDeviceClass.PROBLEM, entity_category=EntityCategory.DIAGNOSTIC, # unset Operational bit from ConfigStatus bitmap means problem diff --git a/homeassistant/components/matter/strings.json b/homeassistant/components/matter/strings.json index 1b7910fbd47e5..abaaf46ef42fe 100644 --- a/homeassistant/components/matter/strings.json +++ b/homeassistant/components/matter/strings.json @@ -56,6 +56,9 @@ "boost_state": { "name": "Boost state" }, + "config_status_operational": { + "name": "Configuration status" + }, "dishwasher_alarm_inflow": { "name": "Inflow alarm" }, diff --git a/homeassistant/components/qwikswitch/__init__.py b/homeassistant/components/qwikswitch/__init__.py index d3cf2ff3d9b67..7dedee0450836 100644 --- a/homeassistant/components/qwikswitch/__init__.py +++ b/homeassistant/components/qwikswitch/__init__.py @@ -24,9 +24,9 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.typing import ConfigType -_LOGGER = logging.getLogger(__name__) +from .const import DATA_QUIKSWITCH, DOMAIN -DOMAIN = "qwikswitch" +_LOGGER = logging.getLogger(__name__) CONF_DIMMER_ADJUST = "dimmer_adjust" CONF_BUTTON_EVENTS = "button_events" @@ -96,7 +96,7 @@ def callback_value_changed(_qsd, qsid, _val): if not await qsusb.update_from_devices(): return False - hass.data[DOMAIN] = qsusb + hass.data[DATA_QUIKSWITCH] = qsusb comps: dict[Platform, list] = { Platform.SWITCH: [], @@ -168,7 +168,7 @@ def async_start(_): @callback def async_stop(_): """Stop the listener.""" - hass.data[DOMAIN].stop() + hass.data[DATA_QUIKSWITCH].stop() hass.bus.async_listen(EVENT_HOMEASSISTANT_STOP, async_stop) diff --git a/homeassistant/components/qwikswitch/binary_sensor.py b/homeassistant/components/qwikswitch/binary_sensor.py index 5f00631f0e4d6..6033b5f584a12 100644 --- a/homeassistant/components/qwikswitch/binary_sensor.py +++ b/homeassistant/components/qwikswitch/binary_sensor.py @@ -14,7 +14,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from . import DOMAIN +from .const import DATA_QUIKSWITCH, DOMAIN from .entity import QSEntity _LOGGER = logging.getLogger(__name__) @@ -30,7 +30,7 @@ async def async_setup_platform( if discovery_info is None: return - qsusb = hass.data[DOMAIN] + qsusb = hass.data[DATA_QUIKSWITCH] _LOGGER.debug("Setup qwikswitch.binary_sensor %s, %s", qsusb, discovery_info) devs = [QSBinarySensor(sensor) for sensor in discovery_info[DOMAIN]] add_entities(devs) diff --git a/homeassistant/components/qwikswitch/const.py b/homeassistant/components/qwikswitch/const.py new file mode 100644 index 0000000000000..2a5cc69af50f5 --- /dev/null +++ b/homeassistant/components/qwikswitch/const.py @@ -0,0 +1,13 @@ +"""Support for Qwikswitch devices.""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +from homeassistant.util.hass_dict import HassKey + +if TYPE_CHECKING: + from pyqwikswitch.async_ import QSUsb + +DOMAIN = "qwikswitch" +DATA_QUIKSWITCH: HassKey[QSUsb] = HassKey(DOMAIN) diff --git a/homeassistant/components/qwikswitch/entity.py b/homeassistant/components/qwikswitch/entity.py index ff7a1d2e98ae4..4df52fda2c4f9 100644 --- a/homeassistant/components/qwikswitch/entity.py +++ b/homeassistant/components/qwikswitch/entity.py @@ -7,7 +7,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity import Entity -from . import DOMAIN +from .const import DATA_QUIKSWITCH class QSEntity(Entity): @@ -67,8 +67,8 @@ def is_on(self): async def async_turn_on(self, **kwargs): """Turn the device on.""" new = kwargs.get(ATTR_BRIGHTNESS, 255) - self.hass.data[DOMAIN].devices.set_value(self.qsid, new) + self.hass.data[DATA_QUIKSWITCH].devices.set_value(self.qsid, new) async def async_turn_off(self, **_): """Turn the device off.""" - self.hass.data[DOMAIN].devices.set_value(self.qsid, 0) + self.hass.data[DATA_QUIKSWITCH].devices.set_value(self.qsid, 0) diff --git a/homeassistant/components/qwikswitch/sensor.py b/homeassistant/components/qwikswitch/sensor.py index e87fae834640a..3a79dd0af98b1 100644 --- a/homeassistant/components/qwikswitch/sensor.py +++ b/homeassistant/components/qwikswitch/sensor.py @@ -12,7 +12,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from . import DOMAIN +from .const import DATA_QUIKSWITCH, DOMAIN from .entity import QSEntity _LOGGER = logging.getLogger(__name__) @@ -28,7 +28,7 @@ async def async_setup_platform( if discovery_info is None: return - qsusb = hass.data[DOMAIN] + qsusb = hass.data[DATA_QUIKSWITCH] _LOGGER.debug("Setup qwikswitch.sensor %s, %s", qsusb, discovery_info) devs = [QSSensor(sensor) for sensor in discovery_info[DOMAIN]] add_entities(devs) diff --git a/homeassistant/components/qwikswitch/switch.py b/homeassistant/components/qwikswitch/switch.py index 6131d9e595ce7..4b3cddee0d951 100644 --- a/homeassistant/components/qwikswitch/switch.py +++ b/homeassistant/components/qwikswitch/switch.py @@ -7,7 +7,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from . import DOMAIN +from .const import DATA_QUIKSWITCH, DOMAIN from .entity import QSToggleEntity @@ -21,7 +21,7 @@ async def async_setup_platform( if discovery_info is None: return - qsusb = hass.data[DOMAIN] + qsusb = hass.data[DATA_QUIKSWITCH] devs = [QSSwitch(qsid, qsusb) for qsid in discovery_info[DOMAIN]] add_entities(devs) diff --git a/tests/components/matter/snapshots/test_binary_sensor.ambr b/tests/components/matter/snapshots/test_binary_sensor.ambr index 771f49e37600c..37a418de9720f 100644 --- a/tests/components/matter/snapshots/test_binary_sensor.ambr +++ b/tests/components/matter/snapshots/test_binary_sensor.ambr @@ -349,7 +349,7 @@ 'state': 'on', }) # --- -# name: test_binary_sensors[eve_shutter][binary_sensor.eve_shutter_switch_20eci1701_problem-entry] +# name: test_binary_sensors[eve_shutter][binary_sensor.eve_shutter_switch_20eci1701_configuration_status-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -362,7 +362,7 @@ 'disabled_by': None, 'domain': 'binary_sensor', 'entity_category': , - 'entity_id': 'binary_sensor.eve_shutter_switch_20eci1701_problem', + 'entity_id': 'binary_sensor.eve_shutter_switch_20eci1701_configuration_status', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -370,29 +370,29 @@ 'labels': set({ }), 'name': None, - 'object_id_base': 'Problem', + 'object_id_base': 'Configuration status', 'options': dict({ }), 'original_device_class': , 'original_icon': None, - 'original_name': 'Problem', + 'original_name': 'Configuration status', 'platform': 'matter', 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'config_status_operational', 'unique_id': '00000000000004D2-0000000000000094-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7', 'unit_of_measurement': None, }) # --- -# name: test_binary_sensors[eve_shutter][binary_sensor.eve_shutter_switch_20eci1701_problem-state] +# name: test_binary_sensors[eve_shutter][binary_sensor.eve_shutter_switch_20eci1701_configuration_status-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'problem', - 'friendly_name': 'Eve Shutter Switch 20ECI1701 Problem', + 'friendly_name': 'Eve Shutter Switch 20ECI1701 Configuration status', }), 'context': , - 'entity_id': 'binary_sensor.eve_shutter_switch_20eci1701_problem', + 'entity_id': 'binary_sensor.eve_shutter_switch_20eci1701_configuration_status', 'last_changed': , 'last_reported': , 'last_updated': , @@ -1942,7 +1942,7 @@ 'state': 'off', }) # --- -# name: test_binary_sensors[window_covering_full][binary_sensor.mock_full_window_covering_problem-entry] +# name: test_binary_sensors[window_covering_full][binary_sensor.mock_full_window_covering_configuration_status-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -1955,7 +1955,7 @@ 'disabled_by': None, 'domain': 'binary_sensor', 'entity_category': , - 'entity_id': 'binary_sensor.mock_full_window_covering_problem', + 'entity_id': 'binary_sensor.mock_full_window_covering_configuration_status', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -1963,36 +1963,36 @@ 'labels': set({ }), 'name': None, - 'object_id_base': 'Problem', + 'object_id_base': 'Configuration status', 'options': dict({ }), 'original_device_class': , 'original_icon': None, - 'original_name': 'Problem', + 'original_name': 'Configuration status', 'platform': 'matter', 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'config_status_operational', 'unique_id': '00000000000004D2-0000000000000032-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7', 'unit_of_measurement': None, }) # --- -# name: test_binary_sensors[window_covering_full][binary_sensor.mock_full_window_covering_problem-state] +# name: test_binary_sensors[window_covering_full][binary_sensor.mock_full_window_covering_configuration_status-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'problem', - 'friendly_name': 'Mock Full Window Covering Problem', + 'friendly_name': 'Mock Full Window Covering Configuration status', }), 'context': , - 'entity_id': 'binary_sensor.mock_full_window_covering_problem', + 'entity_id': 'binary_sensor.mock_full_window_covering_configuration_status', 'last_changed': , 'last_reported': , 'last_updated': , 'state': 'off', }) # --- -# name: test_binary_sensors[window_covering_lift][binary_sensor.mock_lift_window_covering_problem-entry] +# name: test_binary_sensors[window_covering_lift][binary_sensor.mock_lift_window_covering_configuration_status-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -2005,7 +2005,7 @@ 'disabled_by': None, 'domain': 'binary_sensor', 'entity_category': , - 'entity_id': 'binary_sensor.mock_lift_window_covering_problem', + 'entity_id': 'binary_sensor.mock_lift_window_covering_configuration_status', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -2013,36 +2013,36 @@ 'labels': set({ }), 'name': None, - 'object_id_base': 'Problem', + 'object_id_base': 'Configuration status', 'options': dict({ }), 'original_device_class': , 'original_icon': None, - 'original_name': 'Problem', + 'original_name': 'Configuration status', 'platform': 'matter', 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'config_status_operational', 'unique_id': '00000000000004D2-0000000000000032-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7', 'unit_of_measurement': None, }) # --- -# name: test_binary_sensors[window_covering_lift][binary_sensor.mock_lift_window_covering_problem-state] +# name: test_binary_sensors[window_covering_lift][binary_sensor.mock_lift_window_covering_configuration_status-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'problem', - 'friendly_name': 'Mock Lift Window Covering Problem', + 'friendly_name': 'Mock Lift Window Covering Configuration status', }), 'context': , - 'entity_id': 'binary_sensor.mock_lift_window_covering_problem', + 'entity_id': 'binary_sensor.mock_lift_window_covering_configuration_status', 'last_changed': , 'last_reported': , 'last_updated': , 'state': 'off', }) # --- -# name: test_binary_sensors[window_covering_pa_lift][binary_sensor.longan_link_wncv_da01_problem-entry] +# name: test_binary_sensors[window_covering_pa_lift][binary_sensor.longan_link_wncv_da01_configuration_status-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -2055,7 +2055,7 @@ 'disabled_by': None, 'domain': 'binary_sensor', 'entity_category': , - 'entity_id': 'binary_sensor.longan_link_wncv_da01_problem', + 'entity_id': 'binary_sensor.longan_link_wncv_da01_configuration_status', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -2063,36 +2063,36 @@ 'labels': set({ }), 'name': None, - 'object_id_base': 'Problem', + 'object_id_base': 'Configuration status', 'options': dict({ }), 'original_device_class': , 'original_icon': None, - 'original_name': 'Problem', + 'original_name': 'Configuration status', 'platform': 'matter', 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'config_status_operational', 'unique_id': '00000000000004D2-0000000000000001-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7', 'unit_of_measurement': None, }) # --- -# name: test_binary_sensors[window_covering_pa_lift][binary_sensor.longan_link_wncv_da01_problem-state] +# name: test_binary_sensors[window_covering_pa_lift][binary_sensor.longan_link_wncv_da01_configuration_status-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'problem', - 'friendly_name': 'Longan link WNCV DA01 Problem', + 'friendly_name': 'Longan link WNCV DA01 Configuration status', }), 'context': , - 'entity_id': 'binary_sensor.longan_link_wncv_da01_problem', + 'entity_id': 'binary_sensor.longan_link_wncv_da01_configuration_status', 'last_changed': , 'last_reported': , 'last_updated': , 'state': 'off', }) # --- -# name: test_binary_sensors[window_covering_pa_tilt][binary_sensor.mock_pa_tilt_window_covering_problem-entry] +# name: test_binary_sensors[window_covering_pa_tilt][binary_sensor.mock_pa_tilt_window_covering_configuration_status-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -2105,7 +2105,7 @@ 'disabled_by': None, 'domain': 'binary_sensor', 'entity_category': , - 'entity_id': 'binary_sensor.mock_pa_tilt_window_covering_problem', + 'entity_id': 'binary_sensor.mock_pa_tilt_window_covering_configuration_status', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -2113,36 +2113,36 @@ 'labels': set({ }), 'name': None, - 'object_id_base': 'Problem', + 'object_id_base': 'Configuration status', 'options': dict({ }), 'original_device_class': , 'original_icon': None, - 'original_name': 'Problem', + 'original_name': 'Configuration status', 'platform': 'matter', 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'config_status_operational', 'unique_id': '00000000000004D2-0000000000000032-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7', 'unit_of_measurement': None, }) # --- -# name: test_binary_sensors[window_covering_pa_tilt][binary_sensor.mock_pa_tilt_window_covering_problem-state] +# name: test_binary_sensors[window_covering_pa_tilt][binary_sensor.mock_pa_tilt_window_covering_configuration_status-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'problem', - 'friendly_name': 'Mock PA Tilt Window Covering Problem', + 'friendly_name': 'Mock PA Tilt Window Covering Configuration status', }), 'context': , - 'entity_id': 'binary_sensor.mock_pa_tilt_window_covering_problem', + 'entity_id': 'binary_sensor.mock_pa_tilt_window_covering_configuration_status', 'last_changed': , 'last_reported': , 'last_updated': , 'state': 'off', }) # --- -# name: test_binary_sensors[window_covering_tilt][binary_sensor.mock_tilt_window_covering_problem-entry] +# name: test_binary_sensors[window_covering_tilt][binary_sensor.mock_tilt_window_covering_configuration_status-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -2155,7 +2155,7 @@ 'disabled_by': None, 'domain': 'binary_sensor', 'entity_category': , - 'entity_id': 'binary_sensor.mock_tilt_window_covering_problem', + 'entity_id': 'binary_sensor.mock_tilt_window_covering_configuration_status', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -2163,36 +2163,36 @@ 'labels': set({ }), 'name': None, - 'object_id_base': 'Problem', + 'object_id_base': 'Configuration status', 'options': dict({ }), 'original_device_class': , 'original_icon': None, - 'original_name': 'Problem', + 'original_name': 'Configuration status', 'platform': 'matter', 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'config_status_operational', 'unique_id': '00000000000004D2-0000000000000032-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7', 'unit_of_measurement': None, }) # --- -# name: test_binary_sensors[window_covering_tilt][binary_sensor.mock_tilt_window_covering_problem-state] +# name: test_binary_sensors[window_covering_tilt][binary_sensor.mock_tilt_window_covering_configuration_status-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'problem', - 'friendly_name': 'Mock Tilt Window Covering Problem', + 'friendly_name': 'Mock Tilt Window Covering Configuration status', }), 'context': , - 'entity_id': 'binary_sensor.mock_tilt_window_covering_problem', + 'entity_id': 'binary_sensor.mock_tilt_window_covering_configuration_status', 'last_changed': , 'last_reported': , 'last_updated': , 'state': 'off', }) # --- -# name: test_binary_sensors[zemismart_mt25b][binary_sensor.zemismart_mt25b_roller_motor_problem-entry] +# name: test_binary_sensors[zemismart_mt25b][binary_sensor.zemismart_mt25b_roller_motor_configuration_status-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -2205,7 +2205,7 @@ 'disabled_by': None, 'domain': 'binary_sensor', 'entity_category': , - 'entity_id': 'binary_sensor.zemismart_mt25b_roller_motor_problem', + 'entity_id': 'binary_sensor.zemismart_mt25b_roller_motor_configuration_status', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -2213,29 +2213,29 @@ 'labels': set({ }), 'name': None, - 'object_id_base': 'Problem', + 'object_id_base': 'Configuration status', 'options': dict({ }), 'original_device_class': , 'original_icon': None, - 'original_name': 'Problem', + 'original_name': 'Configuration status', 'platform': 'matter', 'previous_unique_id': None, 'suggested_object_id': None, 'supported_features': 0, - 'translation_key': None, + 'translation_key': 'config_status_operational', 'unique_id': '00000000000004D2-000000000000007A-MatterNodeDevice-1-WindowCoveringConfigStatusOperational-258-7', 'unit_of_measurement': None, }) # --- -# name: test_binary_sensors[zemismart_mt25b][binary_sensor.zemismart_mt25b_roller_motor_problem-state] +# name: test_binary_sensors[zemismart_mt25b][binary_sensor.zemismart_mt25b_roller_motor_configuration_status-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'problem', - 'friendly_name': 'Zemismart MT25B Roller Motor Problem', + 'friendly_name': 'Zemismart MT25B Roller Motor Configuration status', }), 'context': , - 'entity_id': 'binary_sensor.zemismart_mt25b_roller_motor_problem', + 'entity_id': 'binary_sensor.zemismart_mt25b_roller_motor_configuration_status', 'last_changed': , 'last_reported': , 'last_updated': , diff --git a/tests/components/matter/test_binary_sensor.py b/tests/components/matter/test_binary_sensor.py index 5b1a52c96c6da..5362d6477ee1a 100644 --- a/tests/components/matter/test_binary_sensor.py +++ b/tests/components/matter/test_binary_sensor.py @@ -424,7 +424,9 @@ async def test_shutter_problem( ) -> None: """Test shutter problem.""" # Eve Shutter default state (ConfigStatus = 9) - state = hass.states.get("binary_sensor.eve_shutter_switch_20eci1701_problem") + state = hass.states.get( + "binary_sensor.eve_shutter_switch_20eci1701_configuration_status" + ) assert state assert state.state == "off" @@ -432,7 +434,9 @@ async def test_shutter_problem( set_node_attribute(matter_node, 1, 258, 7, 8) await trigger_subscription_callback(hass, matter_client) - state = hass.states.get("binary_sensor.eve_shutter_switch_20eci1701_problem") + state = hass.states.get( + "binary_sensor.eve_shutter_switch_20eci1701_configuration_status" + ) assert state assert state.state == "on"