diff --git a/homeassistant/components/brother/config_flow.py b/homeassistant/components/brother/config_flow.py index 73196302207..20e5938884f 100644 --- a/homeassistant/components/brother/config_flow.py +++ b/homeassistant/components/brother/config_flow.py @@ -90,11 +90,14 @@ class BrotherConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self._async_abort_entries_match({CONF_HOST: self.host}) snmp_engine = get_snmp_engine(self.hass) + model = discovery_info.get("properties", {}).get("product") - self.brother = Brother(self.host, snmp_engine=snmp_engine) try: + self.brother = Brother(self.host, snmp_engine=snmp_engine, model=model) await self.brother.async_update() - except (ConnectionError, SnmpError, UnsupportedModel): + except UnsupportedModel: + return self.async_abort(reason="unsupported_model") + except (ConnectionError, SnmpError): return self.async_abort(reason="cannot_connect") # Check if already configured diff --git a/homeassistant/components/brother/manifest.json b/homeassistant/components/brother/manifest.json index 0365918a78b..77a84c70de8 100644 --- a/homeassistant/components/brother/manifest.json +++ b/homeassistant/components/brother/manifest.json @@ -3,7 +3,7 @@ "name": "Brother Printer", "documentation": "https://www.home-assistant.io/integrations/brother", "codeowners": ["@bieniu"], - "requirements": ["brother==1.0.2"], + "requirements": ["brother==1.1.0"], "zeroconf": [ { "type": "_printer._tcp.local.", diff --git a/requirements_all.txt b/requirements_all.txt index 5d78dc85a89..91c941b8e62 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -431,7 +431,7 @@ bravia-tv==1.0.11 broadlink==0.17.0 # homeassistant.components.brother -brother==1.0.2 +brother==1.1.0 # homeassistant.components.brottsplatskartan brottsplatskartan==0.0.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index fe436c9d569..9c4ebcca511 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -269,7 +269,7 @@ bravia-tv==1.0.11 broadlink==0.17.0 # homeassistant.components.brother -brother==1.0.2 +brother==1.1.0 # homeassistant.components.bsblan bsblan==0.4.0 diff --git a/tests/components/brother/test_config_flow.py b/tests/components/brother/test_config_flow.py index 3a828c97488..b7e4b31cfab 100644 --- a/tests/components/brother/test_config_flow.py +++ b/tests/components/brother/test_config_flow.py @@ -150,6 +150,24 @@ async def test_zeroconf_snmp_error(hass): assert result["reason"] == "cannot_connect" +async def test_zeroconf_unsupported_model(hass): + """Test unsupported printer model error.""" + with patch("brother.Brother._get_data") as mock_get_data: + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": SOURCE_ZEROCONF}, + data={ + "hostname": "example.local.", + "name": "Brother Printer", + "properties": {"product": "MFC-8660DN"}, + }, + ) + + assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT + assert result["reason"] == "unsupported_model" + assert len(mock_get_data.mock_calls) == 0 + + async def test_zeroconf_device_exists_abort(hass): """Test we abort zeroconf flow if Brother printer already configured.""" with patch(