From cc3d6aa2479af754f4f380b6cf1e81a0b73d0ed3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 22 Apr 2022 03:58:19 -1000 Subject: [PATCH] Ensure rainmachine creates config entry titles as strings (#70417) --- homeassistant/components/rainmachine/config_flow.py | 2 +- tests/components/rainmachine/conftest.py | 4 +++- tests/components/rainmachine/test_config_flow.py | 4 ++-- tests/components/rainmachine/test_diagnostics.py | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/rainmachine/config_flow.py b/homeassistant/components/rainmachine/config_flow.py index 989616f6367..d24dae46c2b 100644 --- a/homeassistant/components/rainmachine/config_flow.py +++ b/homeassistant/components/rainmachine/config_flow.py @@ -132,7 +132,7 @@ class RainMachineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): # access token without using the IP address and password, so we have to # store it: return self.async_create_entry( - title=controller.name, + title=str(controller.name), data={ CONF_IP_ADDRESS: user_input[CONF_IP_ADDRESS], CONF_PASSWORD: user_input[CONF_PASSWORD], diff --git a/tests/components/rainmachine/conftest.py b/tests/components/rainmachine/conftest.py index 3a32b3b7c9a..457df4a3ef2 100644 --- a/tests/components/rainmachine/conftest.py +++ b/tests/components/rainmachine/conftest.py @@ -49,7 +49,9 @@ def controller_fixture( controller = AsyncMock() controller.api_version = "4.5.0" controller.hardware_version = 3 - controller.name = "My RainMachine" + # The api returns a controller with all numbers as numeric + # instead of a string + controller.name = 12345 controller.mac = controller_mac controller.software_version = "4.0.925" diff --git a/tests/components/rainmachine/test_config_flow.py b/tests/components/rainmachine/test_config_flow.py index 5a0e1fc08cc..8b313eb2fb5 100644 --- a/tests/components/rainmachine/test_config_flow.py +++ b/tests/components/rainmachine/test_config_flow.py @@ -124,7 +124,7 @@ async def test_step_user(hass, config, setup_rainmachine): data=config, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY - assert result["title"] == "My RainMachine" + assert result["title"] == "12345" assert result["data"] == { CONF_IP_ADDRESS: "192.168.1.100", CONF_PASSWORD: "password", @@ -232,7 +232,7 @@ async def test_step_homekit_zeroconf_new_controller_when_some_exist( await hass.async_block_till_done() assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY - assert result2["title"] == "My RainMachine" + assert result2["title"] == "12345" assert result2["data"] == { CONF_IP_ADDRESS: "192.168.1.100", CONF_PASSWORD: "password", diff --git a/tests/components/rainmachine/test_diagnostics.py b/tests/components/rainmachine/test_diagnostics.py index 575e596abc2..d770d01fd36 100644 --- a/tests/components/rainmachine/test_diagnostics.py +++ b/tests/components/rainmachine/test_diagnostics.py @@ -585,7 +585,7 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_rainmach "controller": { "api_version": "4.5.0", "hardware_version": 3, - "name": "My RainMachine", + "name": 12345, "software_version": "4.0.925", }, },