Add zwave config parameter entities (#92223)

* Add zwave config parameter entities

* Remove unused entity const

* remove unusued imports

* review comments

* switch to reserved values

* fix test
This commit is contained in:
Raman Gupta 2023-05-30 11:49:55 -04:00 committed by GitHub
parent 55c2bb59c8
commit 65187c6f11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 431 additions and 106 deletions

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
import pytest
from zwave_js_server.event import Event
from homeassistant.const import STATE_UNKNOWN
from homeassistant.const import STATE_UNKNOWN, EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_registry as er
@ -229,3 +229,37 @@ async def test_disabled_basic_number(
assert entity_entry
assert entity_entry.disabled
assert entity_entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
async def test_config_parameter_number(
hass: HomeAssistant, climate_adc_t3000, integration
) -> None:
"""Test config parameter number is created."""
number_entity_id = "number.adc_t3000_heat_staging_delay"
number_with_states_entity_id = "number.adc_t3000_calibration_temperature"
ent_reg = er.async_get(hass)
for entity_id in (number_entity_id, number_with_states_entity_id):
entity_entry = ent_reg.async_get(entity_id)
assert entity_entry
assert entity_entry.disabled
assert entity_entry.entity_category == EntityCategory.CONFIG
for entity_id in (number_entity_id, number_with_states_entity_id):
updated_entry = ent_reg.async_update_entity(entity_id, **{"disabled_by": None})
assert updated_entry != entity_entry
assert updated_entry.disabled is False
# reload integration and check if entity is correctly there
await hass.config_entries.async_reload(integration.entry_id)
await hass.async_block_till_done()
state = hass.states.get(number_entity_id)
assert state
assert state.state == "30.0"
assert "reserved_values" not in state.attributes
state = hass.states.get(number_with_states_entity_id)
assert state
assert state.state == "0.0"
assert "reserved_values" in state.attributes
assert state.attributes["reserved_values"] == {-1: "Disabled"}