Add Z-wave climate sensor override for Heatit Z-TRM6 (#103896)

* add some basic overrides for z-trm6

* switched id and type

* add fixtures some lints

* duplicate tests of z-trm3

* add broken test for trm6

* fix tests, remove name from fixtures, fix comment

* lints

* forgot lints

* add better description on pwer mode

* Update comment v2

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

* fix space from github web merge

* lint on fixture

* fix permissions on fixture

---------

Co-authored-by: geir råness <11741725+geirra@users.noreply.github.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Geir Råness 2023-11-24 11:01:15 +01:00 committed by GitHub
parent a3eb44209d
commit d4450c6c55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2267 additions and 0 deletions

View File

@ -530,6 +530,68 @@ DISCOVERY_SCHEMAS = [
primary_value=SWITCH_BINARY_CURRENT_VALUE_SCHEMA,
assumed_state=True,
),
# Heatit Z-TRM6
ZWaveDiscoverySchema(
platform=Platform.CLIMATE,
hint="dynamic_current_temp",
manufacturer_id={0x019B},
product_id={0x3001},
product_type={0x0030},
primary_value=ZWaveValueDiscoverySchema(
command_class={CommandClass.THERMOSTAT_MODE},
property={THERMOSTAT_MODE_PROPERTY},
type={ValueType.NUMBER},
),
data_template=DynamicCurrentTempClimateDataTemplate(
lookup_table={
# Floor sensor
"Floor": ZwaveValueID(
property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
command_class=CommandClass.SENSOR_MULTILEVEL,
endpoint=4,
),
# Internal sensor
"Internal": ZwaveValueID(
property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
command_class=CommandClass.SENSOR_MULTILEVEL,
endpoint=2,
),
# Internal with limit by floor sensor
"Internal with floor limit": ZwaveValueID(
property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
command_class=CommandClass.SENSOR_MULTILEVEL,
endpoint=2,
),
# External sensor (connected to device)
"External": ZwaveValueID(
property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
command_class=CommandClass.SENSOR_MULTILEVEL,
endpoint=3,
),
# External sensor (connected to device) with limit by floor sensor (2x sensors)
"External with floor limit": ZwaveValueID(
property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
command_class=CommandClass.SENSOR_MULTILEVEL,
endpoint=3,
),
# PWER - Power regulator mode (no sensor used).
# This mode is not supported by the climate entity.
# Heating is set by adjusting parameter 25.
# P25: Set % of time the relay should be active when using PWER mode.
# (30-minute duty cycle)
# Use the air temperature as current temperature in the climate entity
# as we have nothing else.
"Power regulator": ZwaveValueID(
property_=THERMOSTAT_CURRENT_TEMP_PROPERTY,
command_class=CommandClass.SENSOR_MULTILEVEL,
endpoint=2,
),
},
dependent_value=ZwaveValueID(
property_=2, command_class=CommandClass.CONFIGURATION, endpoint=0
),
),
),
# Heatit Z-TRM3
ZWaveDiscoverySchema(
platform=Platform.CLIMATE,

View File

@ -385,6 +385,12 @@ def climate_eurotronic_spirit_z_state_fixture():
return json.loads(load_fixture("zwave_js/climate_eurotronic_spirit_z_state.json"))
@pytest.fixture(name="climate_heatit_z_trm6_state", scope="session")
def climate_heatit_z_trm6_state_fixture():
"""Load the climate HEATIT Z-TRM6 thermostat node state fixture data."""
return json.loads(load_fixture("zwave_js/climate_heatit_z_trm6_state.json"))
@pytest.fixture(name="climate_heatit_z_trm3_state", scope="session")
def climate_heatit_z_trm3_state_fixture():
"""Load the climate HEATIT Z-TRM3 thermostat node state fixture data."""
@ -897,6 +903,14 @@ def climate_eurotronic_spirit_z_fixture(client, climate_eurotronic_spirit_z_stat
return node
@pytest.fixture(name="climate_heatit_z_trm6")
def climate_heatit_z_trm6_fixture(client, climate_heatit_z_trm6_state):
"""Mock a climate radio HEATIT Z-TRM6 node."""
node = Node(client, copy.deepcopy(climate_heatit_z_trm6_state))
client.driver.controller.nodes[node.node_id] = node
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

File diff suppressed because it is too large Load Diff

View File

@ -415,6 +415,77 @@ async def test_setpoint_thermostat(
client.async_send_command_no_wait.reset_mock()
async def test_thermostat_heatit_z_trm6(
hass: HomeAssistant, client, climate_heatit_z_trm6, integration
) -> None:
"""Test a heatit Z-TRM6 entity."""
node = climate_heatit_z_trm6
state = hass.states.get(CLIMATE_FLOOR_THERMOSTAT_ENTITY)
assert state
assert state.state == HVACMode.HEAT
assert state.attributes[ATTR_HVAC_MODES] == [
HVACMode.OFF,
HVACMode.HEAT,
HVACMode.COOL,
]
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 22.5
assert state.attributes[ATTR_TEMPERATURE] == 19
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
assert (
state.attributes[ATTR_SUPPORTED_FEATURES]
== ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
)
assert state.attributes[ATTR_MIN_TEMP] == 5
assert state.attributes[ATTR_MAX_TEMP] == 40
# Try switching to external sensor (not connected so defaults to 0)
event = Event(
type="value updated",
data={
"source": "node",
"event": "value updated",
"nodeId": 101,
"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
# Try switching to floor sensor
event = Event(
type="value updated",
data={
"source": "node",
"event": "value updated",
"nodeId": 101,
"args": {
"commandClassName": "Configuration",
"commandClass": 112,
"endpoint": 0,
"property": 2,
"propertyName": "Sensor mode",
"newValue": 0,
"prevValue": 4,
},
},
)
node.receive_event(event)
state = hass.states.get(CLIMATE_FLOOR_THERMOSTAT_ENTITY)
assert state
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 21.9
async def test_thermostat_heatit_z_trm3_no_value(
hass: HomeAssistant, client, climate_heatit_z_trm3_no_value, integration
) -> None: