Add zwave_js support for HeatIt Z-TRM2fx (#50317)

* Add zwave_js support for HeatIt Z-TRM2fx

* fix docstring

* use AwesomeVersion to support firmware version ranges

* add guard against empty firmware range

* switch guard approach to raise exception sooner

* make post init more generic

* Set up firmware range schema as AwesomeVersion during initialization

* Update homeassistant/components/zwave_js/discovery.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Allow min_ver and max_ver to be None

* fix docstring

* reduce import scope

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Raman Gupta 2021-05-09 15:28:35 -04:00 committed by GitHub
parent ba31d7d1b4
commit 1b81849271
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 1610 additions and 4 deletions

View file

@ -28,6 +28,7 @@ from homeassistant.components.climate.const import (
SERVICE_SET_PRESET_MODE,
SERVICE_SET_TEMPERATURE,
SUPPORT_FAN_MODE,
SUPPORT_PRESET_MODE,
SUPPORT_TARGET_TEMPERATURE,
SUPPORT_TARGET_TEMPERATURE_RANGE,
)
@ -436,8 +437,10 @@ 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(hass, client, climate_heatit_z_trm3, integration):
"""Test a thermostat v2 command class entity."""
async def test_thermostat_heatit_z_trm3(
hass, client, climate_heatit_z_trm3, integration
):
"""Test a heatit Z-TRM3 entity."""
node = climate_heatit_z_trm3
state = hass.states.get(CLIMATE_FLOOR_THERMOSTAT_ENTITY)
@ -501,6 +504,53 @@ async def test_thermostat_heatit(hass, client, climate_heatit_z_trm3, integratio
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 25.5
async def test_thermostat_heatit_z_trm2fx(
hass, client, climate_heatit_z_trm2fx, integration
):
"""Test a heatit Z-TRM2fx entity."""
node = climate_heatit_z_trm2fx
state = hass.states.get(CLIMATE_FLOOR_THERMOSTAT_ENTITY)
assert state
assert state.state == HVAC_MODE_HEAT
assert state.attributes[ATTR_HVAC_MODES] == [
HVAC_MODE_OFF,
HVAC_MODE_HEAT,
HVAC_MODE_COOL,
]
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 28.8
assert state.attributes[ATTR_TEMPERATURE] == 29
assert (
state.attributes[ATTR_SUPPORTED_FEATURES]
== SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
)
assert state.attributes[ATTR_MIN_TEMP] == 7
assert state.attributes[ATTR_MAX_TEMP] == 35
# Try switching to external sensor
event = Event(
type="value updated",
data={
"source": "node",
"event": "value updated",
"nodeId": 24,
"args": {
"commandClassName": "Configuration",
"commandClass": 112,
"endpoint": 0,
"property": 2,
"propertyName": "Sensor mode",
"newValue": 4,
"prevValue": 2,
},
},
)
node.receive_event(event)
state = hass.states.get(CLIMATE_FLOOR_THERMOSTAT_ENTITY)
assert state
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 0
async def test_thermostat_srt321_hrt4_zw(hass, client, srt321_hrt4_zw, integration):
"""Test a climate entity from a HRT4-ZW / SRT321 thermostat device.