diff --git a/tests/components/drop_connect/common.py b/tests/components/drop_connect/common.py index ea96af03617e7..2e4d59fe7b205 100644 --- a/tests/components/drop_connect/common.py +++ b/tests/components/drop_connect/common.py @@ -1,5 +1,20 @@ """Define common test values.""" +from homeassistant.components.drop_connect.const import ( + CONF_COMMAND_TOPIC, + CONF_DATA_TOPIC, + CONF_DEVICE_DESC, + CONF_DEVICE_ID, + CONF_DEVICE_NAME, + CONF_DEVICE_OWNER_ID, + CONF_DEVICE_TYPE, + CONF_HUB_ID, + DOMAIN, +) +from homeassistant.config_entries import ConfigEntry + +from tests.common import MockConfigEntry + TEST_DATA_HUB_TOPIC = "drop_connect/DROP-1_C0FFEE/255" TEST_DATA_HUB = ( '{"curFlow":5.77,"peakFlow":13.8,"usedToday":232.77,"avgUsed":76,"psi":62.2,"psiLow":61,"psiHigh":62,' @@ -49,3 +64,155 @@ TEST_DATA_RO_FILTER_RESET = ( '{"leak":0,"tdsIn":0,"tdsOut":0,"cart1":0,"cart2":0,"cart3":0}' ) + + +def config_entry_hub() -> ConfigEntry: + """Config entry version 1 fixture.""" + return MockConfigEntry( + domain=DOMAIN, + unique_id="DROP-1_C0FFEE_255", + data={ + CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/255/cmd", + CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/255/#", + CONF_DEVICE_DESC: "Hub", + CONF_DEVICE_ID: 255, + CONF_DEVICE_NAME: "Hub DROP-1_C0FFEE", + CONF_DEVICE_TYPE: "hub", + CONF_HUB_ID: "DROP-1_C0FFEE", + CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255", + }, + version=1, + ) + + +def config_entry_salt() -> ConfigEntry: + """Config entry version 1 fixture.""" + return MockConfigEntry( + domain=DOMAIN, + unique_id="DROP-1_C0FFEE_8", + data={ + CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/8/cmd", + CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/8/#", + CONF_DEVICE_DESC: "Salt Sensor", + CONF_DEVICE_ID: 8, + CONF_DEVICE_NAME: "Salt Sensor", + CONF_DEVICE_TYPE: "salt", + CONF_HUB_ID: "DROP-1_C0FFEE", + CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255", + }, + version=1, + ) + + +def config_entry_leak() -> ConfigEntry: + """Config entry version 1 fixture.""" + return MockConfigEntry( + domain=DOMAIN, + unique_id="DROP-1_C0FFEE_20", + data={ + CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/20/cmd", + CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/20/#", + CONF_DEVICE_DESC: "Leak Detector", + CONF_DEVICE_ID: 20, + CONF_DEVICE_NAME: "Leak Detector", + CONF_DEVICE_TYPE: "leak", + CONF_HUB_ID: "DROP-1_C0FFEE", + CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255", + }, + version=1, + ) + + +def config_entry_softener() -> ConfigEntry: + """Config entry version 1 fixture.""" + return MockConfigEntry( + domain=DOMAIN, + unique_id="DROP-1_C0FFEE_0", + data={ + CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/0/cmd", + CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/0/#", + CONF_DEVICE_DESC: "Softener", + CONF_DEVICE_ID: 0, + CONF_DEVICE_NAME: "Softener", + CONF_DEVICE_TYPE: "soft", + CONF_HUB_ID: "DROP-1_C0FFEE", + CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255", + }, + version=1, + ) + + +def config_entry_filter() -> ConfigEntry: + """Config entry version 1 fixture.""" + return MockConfigEntry( + domain=DOMAIN, + unique_id="DROP-1_C0FFEE_4", + data={ + CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/4/cmd", + CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/4/#", + CONF_DEVICE_DESC: "Filter", + CONF_DEVICE_ID: 4, + CONF_DEVICE_NAME: "Filter", + CONF_DEVICE_TYPE: "filt", + CONF_HUB_ID: "DROP-1_C0FFEE", + CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255", + }, + version=1, + ) + + +def config_entry_protection_valve() -> ConfigEntry: + """Config entry version 1 fixture.""" + return MockConfigEntry( + domain=DOMAIN, + unique_id="DROP-1_C0FFEE_78", + data={ + CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/78/cmd", + CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/78/#", + CONF_DEVICE_DESC: "Protection Valve", + CONF_DEVICE_ID: 78, + CONF_DEVICE_NAME: "Protection Valve", + CONF_DEVICE_TYPE: "pv", + CONF_HUB_ID: "DROP-1_C0FFEE", + CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255", + }, + version=1, + ) + + +def config_entry_pump_controller() -> ConfigEntry: + """Config entry version 1 fixture.""" + return MockConfigEntry( + domain=DOMAIN, + unique_id="DROP-1_C0FFEE_83", + data={ + CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/83/cmd", + CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/83/#", + CONF_DEVICE_DESC: "Pump Controller", + CONF_DEVICE_ID: 83, + CONF_DEVICE_NAME: "Pump Controller", + CONF_DEVICE_TYPE: "pc", + CONF_HUB_ID: "DROP-1_C0FFEE", + CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255", + }, + version=1, + ) + + +def config_entry_ro_filter() -> ConfigEntry: + """Config entry version 1 fixture.""" + return MockConfigEntry( + domain=DOMAIN, + unique_id="DROP-1_C0FFEE_255", + data={ + CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/95/cmd", + CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/95/#", + CONF_DEVICE_DESC: "RO Filter", + CONF_DEVICE_ID: 95, + CONF_DEVICE_NAME: "RO Filter", + CONF_DEVICE_TYPE: "ro", + CONF_HUB_ID: "DROP-1_C0FFEE", + CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255", + }, + version=1, + ) diff --git a/tests/components/drop_connect/test_sensor.py b/tests/components/drop_connect/test_sensor.py index 589fd08488cfb..43da49af884a4 100644 --- a/tests/components/drop_connect/test_sensor.py +++ b/tests/components/drop_connect/test_sensor.py @@ -1,8 +1,7 @@ """Test DROP sensor entities.""" -from homeassistant.components.drop_connect.const import DOMAIN + from homeassistant.const import STATE_UNKNOWN from homeassistant.core import HomeAssistant -from homeassistant.setup import async_setup_component from .common import ( TEST_DATA_FILTER, @@ -26,36 +25,41 @@ TEST_DATA_SOFTENER, TEST_DATA_SOFTENER_RESET, TEST_DATA_SOFTENER_TOPIC, + config_entry_filter, + config_entry_hub, + config_entry_leak, + config_entry_protection_valve, + config_entry_pump_controller, + config_entry_ro_filter, + config_entry_softener, ) from tests.common import async_fire_mqtt_message from tests.typing import MqttMockHAClient -async def test_sensors_hub( - hass: HomeAssistant, config_entry_hub, mqtt_mock: MqttMockHAClient -) -> None: +async def test_sensors_hub(hass: HomeAssistant, mqtt_mock: MqttMockHAClient) -> None: """Test DROP sensors for hubs.""" - config_entry_hub.add_to_hass(hass) - assert await async_setup_component(hass, DOMAIN, {}) - await hass.async_block_till_done() + entry = config_entry_hub() + entry.add_to_hass(hass) + assert await hass.config_entries.async_setup(entry.entry_id) current_flow_sensor_name = "sensor.hub_drop_1_c0ffee_water_flow_rate" - hass.states.async_set(current_flow_sensor_name, STATE_UNKNOWN) + assert hass.states.get(current_flow_sensor_name).state == STATE_UNKNOWN peak_flow_sensor_name = "sensor.hub_drop_1_c0ffee_peak_water_flow_rate_today" - hass.states.async_set(peak_flow_sensor_name, STATE_UNKNOWN) + assert hass.states.get(peak_flow_sensor_name).state == STATE_UNKNOWN used_today_sensor_name = "sensor.hub_drop_1_c0ffee_total_water_used_today" - hass.states.async_set(used_today_sensor_name, STATE_UNKNOWN) + assert hass.states.get(used_today_sensor_name).state == STATE_UNKNOWN average_usage_sensor_name = "sensor.hub_drop_1_c0ffee_average_daily_water_usage" - hass.states.async_set(average_usage_sensor_name, STATE_UNKNOWN) + assert hass.states.get(average_usage_sensor_name).state == STATE_UNKNOWN psi_sensor_name = "sensor.hub_drop_1_c0ffee_current_water_pressure" - hass.states.async_set(psi_sensor_name, STATE_UNKNOWN) + assert hass.states.get(psi_sensor_name).state == STATE_UNKNOWN psi_high_sensor_name = "sensor.hub_drop_1_c0ffee_high_water_pressure_today" - hass.states.async_set(psi_high_sensor_name, STATE_UNKNOWN) + assert hass.states.get(psi_high_sensor_name).state == STATE_UNKNOWN psi_low_sensor_name = "sensor.hub_drop_1_c0ffee_low_water_pressure_today" - hass.states.async_set(psi_low_sensor_name, STATE_UNKNOWN) + assert hass.states.get(psi_low_sensor_name).state == STATE_UNKNOWN battery_sensor_name = "sensor.hub_drop_1_c0ffee_battery" - hass.states.async_set(battery_sensor_name, STATE_UNKNOWN) + assert hass.states.get(battery_sensor_name).state == STATE_UNKNOWN async_fire_mqtt_message(hass, TEST_DATA_HUB_TOPIC, TEST_DATA_HUB_RESET) await hass.async_block_till_done() @@ -64,49 +68,47 @@ async def test_sensors_hub( current_flow_sensor = hass.states.get(current_flow_sensor_name) assert current_flow_sensor - assert round(float(current_flow_sensor.state), 1) == 5.8 + assert current_flow_sensor.state == "5.77" peak_flow_sensor = hass.states.get(peak_flow_sensor_name) assert peak_flow_sensor - assert round(float(peak_flow_sensor.state), 1) == 13.8 + assert peak_flow_sensor.state == "13.8" used_today_sensor = hass.states.get(used_today_sensor_name) assert used_today_sensor - assert round(float(used_today_sensor.state), 1) == 881.1 # liters + assert used_today_sensor.state == "881.13030096168" # liters average_usage_sensor = hass.states.get(average_usage_sensor_name) assert average_usage_sensor - assert round(float(average_usage_sensor.state), 1) == 287.7 # liters + assert average_usage_sensor.state == "287.691295584" # liters psi_sensor = hass.states.get(psi_sensor_name) assert psi_sensor - assert round(float(psi_sensor.state), 1) == 428.9 # centibars + assert psi_sensor.state == "428.8538854" # centibars psi_high_sensor = hass.states.get(psi_high_sensor_name) assert psi_high_sensor - assert round(float(psi_high_sensor.state), 1) == 427.5 # centibars + assert psi_high_sensor.state == "427.474934" # centibars psi_low_sensor = hass.states.get(psi_low_sensor_name) assert psi_low_sensor - assert round(float(psi_low_sensor.state), 1) == 420.6 # centibars + assert psi_low_sensor.state == "420.580177" # centibars battery_sensor = hass.states.get(battery_sensor_name) assert battery_sensor - assert int(battery_sensor.state) == 50 + assert battery_sensor.state == "50" -async def test_sensors_leak( - hass: HomeAssistant, config_entry_leak, mqtt_mock: MqttMockHAClient -) -> None: +async def test_sensors_leak(hass: HomeAssistant, mqtt_mock: MqttMockHAClient) -> None: """Test DROP sensors for leak detectors.""" - config_entry_leak.add_to_hass(hass) - assert await async_setup_component(hass, DOMAIN, {}) - await hass.async_block_till_done() + entry = config_entry_leak() + entry.add_to_hass(hass) + assert await hass.config_entries.async_setup(entry.entry_id) battery_sensor_name = "sensor.leak_detector_battery" - hass.states.async_set(battery_sensor_name, STATE_UNKNOWN) + assert hass.states.get(battery_sensor_name).state == STATE_UNKNOWN temp_sensor_name = "sensor.leak_detector_temperature" - hass.states.async_set(temp_sensor_name, STATE_UNKNOWN) + assert hass.states.get(temp_sensor_name).state == STATE_UNKNOWN async_fire_mqtt_message(hass, TEST_DATA_LEAK_TOPIC, TEST_DATA_LEAK_RESET) await hass.async_block_till_done() @@ -115,29 +117,29 @@ async def test_sensors_leak( battery_sensor = hass.states.get(battery_sensor_name) assert battery_sensor - assert int(battery_sensor.state) == 100 + assert battery_sensor.state == "100" temp_sensor = hass.states.get(temp_sensor_name) assert temp_sensor - assert round(float(temp_sensor.state), 1) == 20.1 # C + assert temp_sensor.state == "20.1111111111111" # °C async def test_sensors_softener( - hass: HomeAssistant, config_entry_softener, mqtt_mock: MqttMockHAClient + hass: HomeAssistant, mqtt_mock: MqttMockHAClient ) -> None: """Test DROP sensors for softeners.""" - config_entry_softener.add_to_hass(hass) - assert await async_setup_component(hass, DOMAIN, {}) - await hass.async_block_till_done() + entry = config_entry_softener() + entry.add_to_hass(hass) + assert await hass.config_entries.async_setup(entry.entry_id) battery_sensor_name = "sensor.softener_battery" - hass.states.async_set(battery_sensor_name, STATE_UNKNOWN) + assert hass.states.get(battery_sensor_name).state == STATE_UNKNOWN current_flow_sensor_name = "sensor.softener_water_flow_rate" - hass.states.async_set(current_flow_sensor_name, STATE_UNKNOWN) + assert hass.states.get(current_flow_sensor_name).state == STATE_UNKNOWN psi_sensor_name = "sensor.softener_current_water_pressure" - hass.states.async_set(psi_sensor_name, STATE_UNKNOWN) + assert hass.states.get(psi_sensor_name).state == STATE_UNKNOWN capacity_sensor_name = "sensor.softener_capacity_remaining" - hass.states.async_set(capacity_sensor_name, STATE_UNKNOWN) + assert hass.states.get(capacity_sensor_name).state == STATE_UNKNOWN async_fire_mqtt_message(hass, TEST_DATA_SOFTENER_TOPIC, TEST_DATA_SOFTENER_RESET) await hass.async_block_till_done() @@ -146,35 +148,33 @@ async def test_sensors_softener( battery_sensor = hass.states.get(battery_sensor_name) assert battery_sensor - assert int(battery_sensor.state) == 20 + assert battery_sensor.state == "20" current_flow_sensor = hass.states.get(current_flow_sensor_name) assert current_flow_sensor - assert round(float(current_flow_sensor.state), 1) == 5.0 + assert current_flow_sensor.state == "5.0" psi_sensor = hass.states.get(psi_sensor_name) assert psi_sensor - assert round(float(psi_sensor.state), 1) == 348.2 # centibars + assert psi_sensor.state == "348.1852285" # centibars capacity_sensor = hass.states.get(capacity_sensor_name) assert capacity_sensor - assert round(float(capacity_sensor.state), 1) == 3785.4 # liters + assert capacity_sensor.state == "3785.411784" # liters -async def test_sensors_filter( - hass: HomeAssistant, config_entry_filter, mqtt_mock: MqttMockHAClient -) -> None: +async def test_sensors_filter(hass: HomeAssistant, mqtt_mock: MqttMockHAClient) -> None: """Test DROP sensors for filters.""" - config_entry_filter.add_to_hass(hass) - assert await async_setup_component(hass, DOMAIN, {}) - await hass.async_block_till_done() + entry = config_entry_filter() + entry.add_to_hass(hass) + assert await hass.config_entries.async_setup(entry.entry_id) battery_sensor_name = "sensor.filter_battery" - hass.states.async_set(battery_sensor_name, STATE_UNKNOWN) + assert hass.states.get(battery_sensor_name).state == STATE_UNKNOWN current_flow_sensor_name = "sensor.filter_water_flow_rate" - hass.states.async_set(current_flow_sensor_name, STATE_UNKNOWN) + assert hass.states.get(current_flow_sensor_name).state == STATE_UNKNOWN psi_sensor_name = "sensor.filter_current_water_pressure" - hass.states.async_set(psi_sensor_name, STATE_UNKNOWN) + assert hass.states.get(psi_sensor_name).state == STATE_UNKNOWN async_fire_mqtt_message(hass, TEST_DATA_FILTER_TOPIC, TEST_DATA_FILTER_RESET) await hass.async_block_till_done() @@ -183,33 +183,33 @@ async def test_sensors_filter( battery_sensor = hass.states.get(battery_sensor_name) assert battery_sensor - assert round(float(battery_sensor.state), 1) == 12.0 + assert battery_sensor.state == "12" current_flow_sensor = hass.states.get(current_flow_sensor_name) assert current_flow_sensor - assert round(float(current_flow_sensor.state), 1) == 19.8 + assert current_flow_sensor.state == "19.84" psi_sensor = hass.states.get(psi_sensor_name) assert psi_sensor - assert round(float(psi_sensor.state), 1) == 263.4 # centibars + assert psi_sensor.state == "263.3797174" # centibars async def test_sensors_protection_valve( - hass: HomeAssistant, config_entry_protection_valve, mqtt_mock: MqttMockHAClient + hass: HomeAssistant, mqtt_mock: MqttMockHAClient ) -> None: """Test DROP sensors for protection valves.""" - config_entry_protection_valve.add_to_hass(hass) - assert await async_setup_component(hass, DOMAIN, {}) - await hass.async_block_till_done() + entry = config_entry_protection_valve() + entry.add_to_hass(hass) + assert await hass.config_entries.async_setup(entry.entry_id) battery_sensor_name = "sensor.protection_valve_battery" - hass.states.async_set(battery_sensor_name, STATE_UNKNOWN) + assert hass.states.get(battery_sensor_name).state == STATE_UNKNOWN current_flow_sensor_name = "sensor.protection_valve_water_flow_rate" - hass.states.async_set(current_flow_sensor_name, STATE_UNKNOWN) + assert hass.states.get(current_flow_sensor_name).state == STATE_UNKNOWN psi_sensor_name = "sensor.protection_valve_current_water_pressure" - hass.states.async_set(psi_sensor_name, STATE_UNKNOWN) + assert hass.states.get(psi_sensor_name).state == STATE_UNKNOWN temp_sensor_name = "sensor.protection_valve_temperature" - hass.states.async_set(temp_sensor_name, STATE_UNKNOWN) + assert hass.states.get(temp_sensor_name).state == STATE_UNKNOWN async_fire_mqtt_message( hass, TEST_DATA_PROTECTION_VALVE_TOPIC, TEST_DATA_PROTECTION_VALVE_RESET @@ -222,35 +222,35 @@ async def test_sensors_protection_valve( battery_sensor = hass.states.get(battery_sensor_name) assert battery_sensor - assert int(battery_sensor.state) == 0 + assert battery_sensor.state == "0" current_flow_sensor = hass.states.get(current_flow_sensor_name) assert current_flow_sensor - assert round(float(current_flow_sensor.state), 1) == 7.1 + assert current_flow_sensor.state == "7.1" psi_sensor = hass.states.get(psi_sensor_name) assert psi_sensor - assert round(float(psi_sensor.state), 1) == 422.6 # centibars + assert psi_sensor.state == "422.6486041" # centibars temp_sensor = hass.states.get(temp_sensor_name) assert temp_sensor - assert round(float(temp_sensor.state), 1) == 21.4 # C + assert temp_sensor.state == "21.3888888888889" # °C async def test_sensors_pump_controller( - hass: HomeAssistant, config_entry_pump_controller, mqtt_mock: MqttMockHAClient + hass: HomeAssistant, mqtt_mock: MqttMockHAClient ) -> None: """Test DROP sensors for pump controllers.""" - config_entry_pump_controller.add_to_hass(hass) - assert await async_setup_component(hass, DOMAIN, {}) - await hass.async_block_till_done() + entry = config_entry_pump_controller() + entry.add_to_hass(hass) + assert await hass.config_entries.async_setup(entry.entry_id) current_flow_sensor_name = "sensor.pump_controller_water_flow_rate" - hass.states.async_set(current_flow_sensor_name, STATE_UNKNOWN) + assert hass.states.get(current_flow_sensor_name).state == STATE_UNKNOWN psi_sensor_name = "sensor.pump_controller_current_water_pressure" - hass.states.async_set(psi_sensor_name, STATE_UNKNOWN) + assert hass.states.get(psi_sensor_name).state == STATE_UNKNOWN temp_sensor_name = "sensor.pump_controller_temperature" - hass.states.async_set(temp_sensor_name, STATE_UNKNOWN) + assert hass.states.get(temp_sensor_name).state == STATE_UNKNOWN async_fire_mqtt_message( hass, TEST_DATA_PUMP_CONTROLLER_TOPIC, TEST_DATA_PUMP_CONTROLLER_RESET @@ -263,35 +263,35 @@ async def test_sensors_pump_controller( current_flow_sensor = hass.states.get(current_flow_sensor_name) assert current_flow_sensor - assert round(float(current_flow_sensor.state), 1) == 2.2 + assert current_flow_sensor.state == "2.2" psi_sensor = hass.states.get(psi_sensor_name) assert psi_sensor - assert round(float(psi_sensor.state), 1) == 428.9 # centibars + assert psi_sensor.state == "428.8538854" # centibars temp_sensor = hass.states.get(temp_sensor_name) assert temp_sensor - assert round(float(temp_sensor.state), 1) == 20.4 # C + assert temp_sensor.state == "20.4444444444444" # °C async def test_sensors_ro_filter( - hass: HomeAssistant, config_entry_ro_filter, mqtt_mock: MqttMockHAClient + hass: HomeAssistant, mqtt_mock: MqttMockHAClient ) -> None: """Test DROP sensors for RO filters.""" - config_entry_ro_filter.add_to_hass(hass) - assert await async_setup_component(hass, DOMAIN, {}) - await hass.async_block_till_done() + entry = config_entry_ro_filter() + entry.add_to_hass(hass) + assert await hass.config_entries.async_setup(entry.entry_id) tds_in_sensor_name = "sensor.ro_filter_inlet_tds" - hass.states.async_set(tds_in_sensor_name, STATE_UNKNOWN) + assert hass.states.get(tds_in_sensor_name).state == STATE_UNKNOWN tds_out_sensor_name = "sensor.ro_filter_outlet_tds" - hass.states.async_set(tds_out_sensor_name, STATE_UNKNOWN) + assert hass.states.get(tds_out_sensor_name).state == STATE_UNKNOWN cart1_sensor_name = "sensor.ro_filter_cartridge_1_life_remaining" - hass.states.async_set(cart1_sensor_name, STATE_UNKNOWN) + assert hass.states.get(cart1_sensor_name).state == STATE_UNKNOWN cart2_sensor_name = "sensor.ro_filter_cartridge_2_life_remaining" - hass.states.async_set(cart2_sensor_name, STATE_UNKNOWN) + assert hass.states.get(cart2_sensor_name).state == STATE_UNKNOWN cart3_sensor_name = "sensor.ro_filter_cartridge_3_life_remaining" - hass.states.async_set(cart3_sensor_name, STATE_UNKNOWN) + assert hass.states.get(cart3_sensor_name).state == STATE_UNKNOWN async_fire_mqtt_message(hass, TEST_DATA_RO_FILTER_TOPIC, TEST_DATA_RO_FILTER_RESET) await hass.async_block_till_done() @@ -300,20 +300,20 @@ async def test_sensors_ro_filter( tds_in_sensor = hass.states.get(tds_in_sensor_name) assert tds_in_sensor - assert int(tds_in_sensor.state) == 164 + assert tds_in_sensor.state == "164" tds_out_sensor = hass.states.get(tds_out_sensor_name) assert tds_out_sensor - assert int(tds_out_sensor.state) == 9 + assert tds_out_sensor.state == "9" cart1_sensor = hass.states.get(cart1_sensor_name) assert cart1_sensor - assert int(cart1_sensor.state) == 59 + assert cart1_sensor.state == "59" cart2_sensor = hass.states.get(cart2_sensor_name) assert cart2_sensor - assert int(cart2_sensor.state) == 80 + assert cart2_sensor.state == "80" cart3_sensor = hass.states.get(cart3_sensor_name) assert cart3_sensor - assert int(cart3_sensor.state) == 59 + assert cart3_sensor.state == "59"