Fix no value error for heatit climate entities (#51392)

This commit is contained in:
Raman Gupta 2021-06-03 00:07:47 -04:00 committed by GitHub
parent 7f6e20dcbc
commit ba6a0b5793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1279 additions and 1 deletions

View File

@ -100,7 +100,7 @@ class DynamicCurrentTempClimateDataTemplate(BaseDiscoverySchemaDataTemplate):
lookup_table: dict[str | int, ZwaveValue | None] = resolved_data["lookup_table"]
dependent_value: ZwaveValue | None = resolved_data["dependent_value"]
if dependent_value:
if dependent_value and dependent_value.value is not None:
lookup_key = dependent_value.metadata.states[
str(dependent_value.value)
].split("-")[0]

View File

@ -261,6 +261,14 @@ def climate_heatit_z_trm2fx_state_fixture():
return json.loads(load_fixture("zwave_js/climate_heatit_z_trm2fx_state.json"))
@pytest.fixture(name="climate_heatit_z_trm3_no_value_state", scope="session")
def climate_heatit_z_trm3_no_value_state_fixture():
"""Load the climate HEATIT Z-TRM3 thermostat node w/no value state fixture data."""
return json.loads(
load_fixture("zwave_js/climate_heatit_z_trm3_no_value_state.json")
)
@pytest.fixture(name="nortek_thermostat_state", scope="session")
def nortek_thermostat_state_fixture():
"""Load the nortek thermostat node state fixture data."""
@ -517,6 +525,16 @@ def climate_eurotronic_spirit_z_fixture(client, climate_eurotronic_spirit_z_stat
return node
@pytest.fixture(name="climate_heatit_z_trm3_no_value")
def climate_heatit_z_trm3_no_value_fixture(
client, climate_heatit_z_trm3_no_value_state
):
"""Mock a climate radio HEATIT Z-TRM3 node."""
node = Node(client, copy.deepcopy(climate_heatit_z_trm3_no_value_state))
client.driver.controller.nodes[node.node_id] = node
return node
@pytest.fixture(name="climate_heatit_z_trm3")
def climate_heatit_z_trm3_fixture(client, climate_heatit_z_trm3_state):
"""Mock a climate radio HEATIT Z-TRM3 node."""

View File

@ -437,6 +437,16 @@ async def test_setpoint_thermostat(hass, client, climate_danfoss_lc_13, integrat
client.async_send_command_no_wait.reset_mock()
async def test_thermostat_heatit_z_trm3_no_value(
hass, client, climate_heatit_z_trm3_no_value, integration
):
"""Test a heatit Z-TRM3 entity that is missing a value."""
# When the config parameter that specifies what sensor to use has no value, we fall
# back to the first temperature sensor found on the device
state = hass.states.get(CLIMATE_FLOOR_THERMOSTAT_ENTITY)
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 22.5
async def test_thermostat_heatit_z_trm3(
hass, client, climate_heatit_z_trm3, integration
):

File diff suppressed because it is too large Load Diff