diff --git a/homeassistant/components/grandstream_home/__init__.py b/homeassistant/components/grandstream_home/__init__.py index 3106faca9ab0..24e31675c628 100755 --- a/homeassistant/components/grandstream_home/__init__.py +++ b/homeassistant/components/grandstream_home/__init__.py @@ -6,7 +6,6 @@ from grandstream_home_api import GDSPhoneAPI, attempt_login, create_device_api_i from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ATTR_SW_VERSION, CONF_HOST, CONF_MODEL, CONF_PASSWORD, @@ -21,7 +20,7 @@ from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import device_registry as dr from homeassistant.helpers.device_registry import DeviceInfo -from .const import DOMAIN +from .const import CONF_SW_VERSION, DOMAIN from .coordinator import ( GrandstreamConfigEntry, GrandstreamCoordinator, @@ -133,7 +132,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: GrandstreamConfigEntry) # 3. Create device info mac_address = api.device_mac - discovery_version = entry.data.get(ATTR_SW_VERSION) + discovery_version = entry.data.get(CONF_SW_VERSION) device_info = _create_device_info( entry=entry, diff --git a/homeassistant/components/grandstream_home/config_flow.py b/homeassistant/components/grandstream_home/config_flow.py index a79e0ced4024..a4587e46b843 100755 --- a/homeassistant/components/grandstream_home/config_flow.py +++ b/homeassistant/components/grandstream_home/config_flow.py @@ -18,7 +18,6 @@ import probatio from homeassistant import config_entries from homeassistant.config_entries import ConfigFlow from homeassistant.const import ( - ATTR_SW_VERSION, CONF_HOST, CONF_MODEL, CONF_PASSWORD, @@ -31,7 +30,7 @@ from homeassistant.helpers import config_validation as cv, selector from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo -from .const import DOMAIN +from .const import CONF_SW_VERSION, DOMAIN _LOGGER = logging.getLogger(__name__) @@ -138,7 +137,7 @@ class GrandstreamConfigFlow(ConfigFlow, domain=DOMAIN): # Prepare updates updates = {CONF_HOST: self._host, CONF_PORT: self._port} if self._firmware_version: - updates[ATTR_SW_VERSION] = self._firmware_version + updates[CONF_SW_VERSION] = self._firmware_version self._abort_if_unique_id_configured(updates=updates) @@ -240,7 +239,7 @@ class GrandstreamConfigFlow(ConfigFlow, domain=DOMAIN): CONF_VERIFY_SSL: verify_ssl, CONF_TYPE: self._device_model, CONF_MODEL: self._product_model, - ATTR_SW_VERSION: self._firmware_version, + CONF_SW_VERSION: self._firmware_version, }, ) diff --git a/homeassistant/components/grandstream_home/const.py b/homeassistant/components/grandstream_home/const.py index 500248a1f27d..aef97c60457f 100755 --- a/homeassistant/components/grandstream_home/const.py +++ b/homeassistant/components/grandstream_home/const.py @@ -2,4 +2,6 @@ DOMAIN = "grandstream_home" +CONF_SW_VERSION = "sw_version" + COORDINATOR_UPDATE_INTERVAL = 10 diff --git a/tests/components/grandstream_home/test_config_flow.py b/tests/components/grandstream_home/test_config_flow.py index 6d11402c6743..d68923033b2c 100644 --- a/tests/components/grandstream_home/test_config_flow.py +++ b/tests/components/grandstream_home/test_config_flow.py @@ -6,10 +6,9 @@ from unittest.mock import MagicMock, patch import pytest from pytest_homeassistant.common import MockConfigEntry -from homeassistant.components.grandstream_home.const import DOMAIN +from homeassistant.components.grandstream_home.const import CONF_SW_VERSION, DOMAIN from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF, ConfigFlowResult from homeassistant.const import ( - ATTR_SW_VERSION, CONF_HOST, CONF_MODEL, CONF_PASSWORD, @@ -38,7 +37,7 @@ def _assert_created_entry(hass: HomeAssistant, result: ConfigFlowResult) -> None CONF_VERIFY_SSL: False, CONF_TYPE: "GDS", CONF_MODEL: None, - ATTR_SW_VERSION: None, + CONF_SW_VERSION: None, } entry = hass.config_entries.async_entries(DOMAIN)[0] assert entry.unique_id == format_mac("00:0B:82:12:34:56") @@ -195,7 +194,7 @@ async def test_full_zeroconf_flow(hass: HomeAssistant) -> None: CONF_VERIFY_SSL: False, CONF_TYPE: "GDS", CONF_MODEL: None, - ATTR_SW_VERSION: "1.0.1.13", + CONF_SW_VERSION: "1.0.1.13", } entry = hass.config_entries.async_entries(DOMAIN)[0] assert entry.unique_id == format_mac("EC74D79753C5") @@ -347,7 +346,7 @@ async def test_zeroconf_gsc_device(hass: HomeAssistant) -> None: CONF_VERIFY_SSL: False, CONF_TYPE: "GSC", CONF_MODEL: None, - ATTR_SW_VERSION: "1.0.1.13", + CONF_SW_VERSION: "1.0.1.13", } entry = hass.config_entries.async_entries(DOMAIN)[0] assert entry.unique_id == format_mac("EC74D79753C5") @@ -430,7 +429,7 @@ async def test_zeroconf_edge_cases( CONF_VERIFY_SSL: False, CONF_TYPE: "GDS", CONF_MODEL: model, - ATTR_SW_VERSION: None, + CONF_SW_VERSION: None, } entry = hass.config_entries.async_entries(DOMAIN)[0] assert entry.unique_id == unique_id